summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Robbbert <Robbbert@users.noreply.github.com>2017-07-24 00:54:10 +1000
committer Robbbert <Robbbert@users.noreply.github.com>2017-07-24 00:54:10 +1000
commit05ec40d35a694a22d7c5f21d6a2a4aa57e5f112b (patch)
treeb834cd615586e373e3bf14ceb1495d0ab98bb02f
parentd2949ffb13347ed81a53bf17649c5552c1dc1f9d (diff)
*winui update
-rw-r--r--scripts/src/osd/winui.lua4
-rw-r--r--src/osd/winui/bitmask.cpp8
-rw-r--r--src/osd/winui/columnedit.cpp43
-rw-r--r--src/osd/winui/datamap.cpp88
-rw-r--r--src/osd/winui/dialogs.cpp187
-rw-r--r--src/osd/winui/dijoystick.cpp307
-rw-r--r--src/osd/winui/directdraw.cpp382
-rw-r--r--src/osd/winui/directdraw.h36
-rw-r--r--src/osd/winui/directinput.cpp22
-rw-r--r--src/osd/winui/directories.cpp195
-rw-r--r--src/osd/winui/directories.h2
-rw-r--r--src/osd/winui/dirwatch.cpp46
-rw-r--r--src/osd/winui/dxdecode.cpp194
-rw-r--r--src/osd/winui/dxdecode.h13
-rw-r--r--src/osd/winui/game_opts.h3
-rw-r--r--src/osd/winui/layout.cpp9
-rw-r--r--src/osd/winui/mui_audit.cpp56
-rw-r--r--src/osd/winui/mui_opts.cpp29
-rw-r--r--src/osd/winui/mui_opts.h144
-rw-r--r--src/osd/winui/mui_util.cpp122
-rw-r--r--src/osd/winui/newui.cpp3364
-rw-r--r--src/osd/winui/picker.cpp518
-rw-r--r--src/osd/winui/properties.cpp537
-rw-r--r--src/osd/winui/screenshot.cpp22
-rw-r--r--src/osd/winui/splitters.cpp36
-rw-r--r--src/osd/winui/splitters.h3
-rw-r--r--src/osd/winui/tabview.cpp103
-rw-r--r--src/osd/winui/treeview.h1
-rw-r--r--src/osd/winui/winui.cpp758
-rw-r--r--src/osd/winui/winui.h2
30 files changed, 1486 insertions, 5748 deletions
diff --git a/scripts/src/osd/winui.lua b/scripts/src/osd/winui.lua
index 8cfdd0408e2..c60c44ef7a5 100644
--- a/scripts/src/osd/winui.lua
+++ b/scripts/src/osd/winui.lua
@@ -207,11 +207,11 @@ project ("osd_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/winui/datamap.cpp",
MAME_DIR .. "src/osd/winui/dialogs.cpp",
MAME_DIR .. "src/osd/winui/dijoystick.cpp",
- MAME_DIR .. "src/osd/winui/directdraw.cpp",
+-- MAME_DIR .. "src/osd/winui/directdraw.cpp",
MAME_DIR .. "src/osd/winui/directinput.cpp",
MAME_DIR .. "src/osd/winui/directories.cpp",
MAME_DIR .. "src/osd/winui/dirwatch.cpp",
- MAME_DIR .. "src/osd/winui/dxdecode.cpp",
+-- MAME_DIR .. "src/osd/winui/dxdecode.cpp",
MAME_DIR .. "src/osd/winui/help.cpp",
MAME_DIR .. "src/osd/winui/helpids.cpp",
MAME_DIR .. "src/osd/winui/history.cpp",
diff --git a/src/osd/winui/bitmask.cpp b/src/osd/winui/bitmask.cpp
index c8b542dce5d..dddf1dcd7b0 100644
--- a/src/osd/winui/bitmask.cpp
+++ b/src/osd/winui/bitmask.cpp
@@ -1,4 +1,5 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
/* bitmask.c - Bitmask support routines - MSH 11/19/1998 */
@@ -10,7 +11,6 @@
// MAME/MAMEUI headers
#include "bitmask.h"
-#include "emu.h"
/* Bit routines */
static UCHAR maskTable[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
@@ -59,7 +59,7 @@ BOOL TestBit(LPBITS lpBits, UINT nBit)
UINT offset;
UCHAR mask;
- if (!lpBits || !lpBits->m_lpBits)
+ if (nBit < 0 || !lpBits || !lpBits->m_lpBits)
return FALSE;
offset = nBit >> 3;
@@ -77,7 +77,7 @@ void SetBit(LPBITS lpBits, UINT nBit)
UINT offset;
UCHAR mask;
- if (!lpBits || !lpBits->m_lpBits)
+ if (nBit < 0 || !lpBits || !lpBits->m_lpBits)
return;
offset = nBit >> 3;
@@ -95,7 +95,7 @@ void ClearBit(LPBITS lpBits, UINT nBit)
UINT offset;
UCHAR mask;
- if (!lpBits || !lpBits->m_lpBits)
+ if (nBit < 0 || !lpBits || !lpBits->m_lpBits)
return;
offset = nBit >> 3;
diff --git a/src/osd/winui/columnedit.cpp b/src/osd/winui/columnedit.cpp
index 21cac963e76..43266f0c7bb 100644
--- a/src/osd/winui/columnedit.cpp
+++ b/src/osd/winui/columnedit.cpp
@@ -1,4 +1,5 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
/***************************************************************************
@@ -12,28 +13,16 @@
// standard windows headers
#include <windows.h>
#include <windowsx.h>
-#include <shellapi.h>
-#include <commctrl.h>
-#include <commdlg.h>
-#include <stdlib.h>
-#include <assert.h>
// MAME/MAMEUI headers
-#include <stdlib.h>
#include "resource.h"
#include "mui_opts.h"
-#include "winui.h"
-
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#endif
// Returns TRUE if successful
static int DoExchangeItem(HWND hFrom, HWND hTo, int nMinItem)
{
LV_ITEM lvi;
TCHAR buf[80];
- BOOL b_res = 0;
lvi.iItem = ListView_GetNextItem(hFrom, -1, LVIS_SELECTED | LVIS_FOCUSED);
if (lvi.iItem < nMinItem)
@@ -50,7 +39,8 @@ static int DoExchangeItem(HWND hFrom, HWND hTo, int nMinItem)
if (ListView_GetItem(hFrom, &lvi))
{
// Add this item to the Show and delete it from Available
- b_res = ListView_DeleteItem(hFrom, lvi.iItem);
+ BOOL b_res = ListView_DeleteItem(hFrom, lvi.iItem);
+ b_res++;
lvi.iItem = ListView_GetItemCount(hTo);
(void)ListView_InsertItem(hTo, &lvi);
ListView_SetItemState(hTo, lvi.iItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
@@ -63,12 +53,8 @@ static int DoExchangeItem(HWND hFrom, HWND hTo, int nMinItem)
static void DoMoveItem( HWND hWnd, BOOL bDown)
{
LV_ITEM lvi;
- TCHAR buf[80];
- int nMaxpos = 0;
- BOOL b_res = 0;
-
lvi.iItem = ListView_GetNextItem(hWnd, -1, LVIS_SELECTED | LVIS_FOCUSED);
- nMaxpos = ListView_GetItemCount(hWnd);
+ int nMaxpos = ListView_GetItemCount(hWnd);
if (lvi.iItem == -1 ||
(lvi.iItem < 2 && bDown == FALSE) || // Disallow moving First column
(lvi.iItem == 0 && bDown == TRUE) || // ""
@@ -77,14 +63,17 @@ static void DoMoveItem( HWND hWnd, BOOL bDown)
SetFocus(hWnd);
return;
}
+
+ TCHAR buf[80];
lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM | LVIF_TEXT;
+ lvi.mask = LVIF_PARAM | LVIF_TEXT;
lvi.pszText = buf;
lvi.cchTextMax = ARRAY_LENGTH(buf);
if (ListView_GetItem(hWnd, &lvi))
{
// Add this item to the Show and delete it from Available
- b_res = ListView_DeleteItem(hWnd, lvi.iItem);
+ BOOL b_res = ListView_DeleteItem(hWnd, lvi.iItem);
+ b_res++;
lvi.iItem += (bDown) ? 1 : -1;
(void)ListView_InsertItem(hWnd,&lvi);
ListView_SetItemState(hWnd, lvi.iItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
@@ -116,7 +105,6 @@ INT_PTR InternalColumnDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
int i, nCount = 0;
LV_ITEM lvi;
DWORD dwShowStyle, dwAvailableStyle, dwView = 0;
- BOOL b_res = 0;
switch (Msg)
{
@@ -385,7 +373,8 @@ INT_PTR InternalColumnDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
lvi.mask = LVIF_PARAM;
lvi.pszText = 0;
lvi.iItem = i;
- b_res = ListView_GetItem(hShown, &lvi);
+ BOOL b_res = ListView_GetItem(hShown, &lvi);
+ b_res++;
order[nCount++] = lvi.lParam;
shown[lvi.lParam] = TRUE;
}
@@ -395,7 +384,8 @@ INT_PTR InternalColumnDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
lvi.mask = LVIF_PARAM;
lvi.pszText = 0;
lvi.iItem = i;
- b_res = ListView_GetItem(hAvailable, &lvi);
+ BOOL b_res = ListView_GetItem(hAvailable, &lvi);
+ b_res++;
order[nCount++] = lvi.lParam;
shown[lvi.lParam] = FALSE;
}
@@ -429,11 +419,8 @@ INT_PTR CALLBACK ColumnDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPa
{
static int shown[COLUMN_MAX];
static int order[COLUMN_MAX];
- extern const LPCTSTR column_names[COLUMN_MAX]; // from winui.c, should improve
+ extern const LPCTSTR column_names[COLUMN_MAX]; // from winui.cpp, should improve
- return InternalColumnDialogProc(hDlg, Msg, wParam, lParam, COLUMN_MAX,
- shown, order, column_names, GetRealColumnOrder, GetColumnInfo, SetColumnInfo);
+ return InternalColumnDialogProc(hDlg, Msg, wParam, lParam, COLUMN_MAX, shown, order, column_names, GetRealColumnOrder, GetColumnInfo, SetColumnInfo);
}
-
-
diff --git a/src/osd/winui/datamap.cpp b/src/osd/winui/datamap.cpp
index 696db7fcbad..28d3cc0b854 100644
--- a/src/osd/winui/datamap.cpp
+++ b/src/osd/winui/datamap.cpp
@@ -1,4 +1,5 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
//============================================================
@@ -14,25 +15,18 @@
#include <tchar.h>
// standard C headers
-#include <stdlib.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <assert.h>
-#include <math.h>
// MAME/MAMEUI headers
#include "mui_opts.h"
-#include "corestr.h"
-#include "strconv.h"
#include "datamap.h"
#include "winutf8.h"
-#include "emu.h"
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
+
//============================================================
// TYPE DEFINITIONS
//============================================================
@@ -91,12 +85,9 @@ typedef void (*datamap_default_callback)(datamap *map, HWND control, windows_opt
static datamap_entry *find_entry(datamap *map, int dlgitem);
static control_type get_control_type(HWND control);
-static int control_operation(datamap *map, HWND dialog, windows_options *opts,
- datamap_entry *entry, datamap_callback_type callback_type);
-static void read_control(datamap *map, HWND control, windows_options *opts,
- datamap_entry *entry, const char *option_name);
-static void populate_control(datamap *map, HWND control, windows_options *opts,
- datamap_entry *entry, const char *option_name);
+static int control_operation(datamap *map, HWND dialog, windows_options *opts, datamap_entry *entry, datamap_callback_type callback_type);
+static void read_control(datamap *map, HWND control, windows_options *opts, datamap_entry *entry, const char *option_name);
+static void populate_control(datamap *map, HWND control, windows_options *opts, datamap_entry *entry, const char *option_name);
static char *tztrim(float float_value);
@@ -107,7 +98,6 @@ static char *tztrim(float float_value);
datamap *datamap_create(void)
{
datamap *map = (datamap *)malloc(sizeof(*map));
-
if (!map)
return NULL;
@@ -135,7 +125,11 @@ void datamap_free(datamap *map)
void datamap_add(datamap *map, int dlgitem, datamap_entry_type type, const char *option_name)
{
// sanity check for too many entries
- assert(map->entry_count < ARRAY_LENGTH(map->entries));
+ if (!(map->entry_count < ARRAY_LENGTH(map->entries)))
+ {
+ printf("Datamap.cpp Line __LINE__ too many entries\n");
+ return;
+ }
// add entry to the datamap
memset(&map->entries[map->entry_count], 0, sizeof(map->entries[map->entry_count]));
@@ -295,13 +289,11 @@ void datamap_update_all_controls(datamap *map, HWND dialog, windows_options *opt
static datamap_entry *find_entry(datamap *map, int dlgitem)
{
for (int i = 0; i < map->entry_count; i++)
- {
if (map->entries[i].dlgitem == dlgitem)
return &map->entries[i];
- }
// should not reach here
- assert(FALSE);
+ printf("Datamap.cpp line __LINE__ couldn't find an entry\n");
return NULL;
}
@@ -332,7 +324,6 @@ static control_type get_control_type(HWND control)
else
type = CT_UNKNOWN;
- assert(type != CT_UNKNOWN);
return type;
}
@@ -344,24 +335,24 @@ static control_type get_control_type(HWND control)
static BOOL is_control_displayonly(HWND control)
{
- BOOL displayonly = 0;
+ BOOL displayonly = false;
switch(get_control_type(control))
{
case CT_STATIC:
- displayonly = TRUE;
+ displayonly = true;
break;
case CT_EDIT:
- displayonly = (GetWindowLong(control, GWL_STYLE) & ES_READONLY) ? TRUE : FALSE;
+ displayonly = (GetWindowLong(control, GWL_STYLE) & ES_READONLY) ? true : false;
break;
default:
- displayonly = FALSE;
+ displayonly = false;
break;
}
if (!IsWindowEnabled(control))
- displayonly = TRUE;
+ displayonly = true;
return displayonly;
}
@@ -375,9 +366,8 @@ static void broadcast_changes(datamap *map, HWND dialog, windows_options *opts,
{
HWND other_control;
const char *that_option_name;
- int i;
- for (i = 0; i < map->entry_count; i++)
+ for (int i = 0; i < map->entry_count; i++)
{
// search for an entry with the same option_name, but is not the exact
// same entry
@@ -386,7 +376,7 @@ static void broadcast_changes(datamap *map, HWND dialog, windows_options *opts,
{
// we've found a control sharing the same option; populate it
other_control = GetDlgItem(dialog, map->entries[i].dlgitem);
- if (other_control != NULL)
+ if (other_control)
populate_control(map, other_control, opts, &map->entries[i], that_option_name);
}
}
@@ -398,8 +388,7 @@ static void broadcast_changes(datamap *map, HWND dialog, windows_options *opts,
// control_operation
//============================================================
-static int control_operation(datamap *map, HWND dialog, windows_options *opts,
- datamap_entry *entry, datamap_callback_type callback_type)
+static int control_operation(datamap *map, HWND dialog, windows_options *opts, datamap_entry *entry, datamap_callback_type callback_type)
{
static const datamap_default_callback default_callbacks[DCT_COUNT] =
{
@@ -407,40 +396,37 @@ static int control_operation(datamap *map, HWND dialog, windows_options *opts,
populate_control,
NULL
};
- HWND control;
int result = 0;
const char *option_name;
char option_name_buffer[64];
char option_value[1024] = {0, };
- control = GetDlgItem(dialog, entry->dlgitem);
- if (control != NULL)
+ HWND control = GetDlgItem(dialog, entry->dlgitem);
+ if (control)
{
// don't do anything if we're reading from a display-only control
if ((callback_type != DCT_READ_CONTROL) || !is_control_displayonly(control))
{
// figure out the option_name
- if (entry->get_option_name != NULL)
+ if (entry->get_option_name)
{
option_name_buffer[0] = '\0';
entry->get_option_name(map, dialog, control, option_name_buffer, ARRAY_LENGTH(option_name_buffer));
option_name = option_name_buffer;
}
else
- {
option_name = entry->option_name;
- }
// if reading, get the option value, solely for the purposes of comparison
- if ((callback_type == DCT_READ_CONTROL) && (option_name != NULL))
+ if ((callback_type == DCT_READ_CONTROL) && option_name)
snprintf(option_value, ARRAY_LENGTH(option_value), "%s", opts->value(option_name));
- if (entry->callbacks[callback_type] != NULL)
+ if (entry->callbacks[callback_type])
{
// use custom callback
result = entry->callbacks[callback_type](map, dialog, control, opts, option_name);
}
- else if (default_callbacks[callback_type] && (option_name != NULL))
+ else if (default_callbacks[callback_type] && option_name)
{
// use default callback
default_callbacks[callback_type](map, control, opts, entry, option_name);
@@ -453,7 +439,7 @@ static int control_operation(datamap *map, HWND dialog, windows_options *opts,
// For callbacks that returned TRUE, do not broadcast_changes.
if (!result) {
// do a check to see if the control changed
- result = (option_name != NULL) && (strcmp(option_value, opts->value(option_name)) != 0);
+ result = (option_name) && (strcmp(option_value, opts->value(option_name)) != 0);
if (result)
{
// the value has changed; we may need to broadcast the change
@@ -482,9 +468,8 @@ static float trackbar_value_from_position(datamap_entry *entry, int position)
float position_f = position;
if (entry->use_trackbar_options)
- {
position_f = (position_f * entry->trackbar_increments) + entry->trackbar_min;
- }
+
return position_f;
}
@@ -497,9 +482,8 @@ static float trackbar_value_from_position(datamap_entry *entry, int position)
static int trackbar_position_from_value(datamap_entry *entry, float value)
{
if (entry->use_trackbar_options)
- {
value = floor((value - entry->trackbar_min) / entry->trackbar_increments + 0.5);
- }
+
return (int) value;
}
@@ -521,7 +505,7 @@ static void read_control(datamap *map, HWND control, windows_options *opts, data
switch(get_control_type(control))
{
case CT_BUTTON:
- assert(entry->type == DM_BOOL);
+ //assert(entry->type == DM_BOOL);
bool_value = Button_GetCheck(control);
opts->set_value(option_name, bool_value, OPTION_PRIORITY_CMDLINE);
break;
@@ -754,26 +738,26 @@ static char *tztrim(float float_value)
{
static char tz_string[20];
char float_string[20];
- char *ptr;
int i = 0;
sprintf(float_string, "%f", float_value);
- ptr = float_string;
+ char* ptr = float_string;
// Copy before the '.'
- while (*ptr && *ptr != '.') {
+ while (*ptr && *ptr != '.')
tz_string[i++] = *ptr++;
- }
+
// add the '.' and the next digit
- if (*ptr == '.') {
+ if (*ptr == '.')
+ {
tz_string[i++] = *ptr++;
tz_string[i++] = *ptr++;
}
// Keep copying until we hit a '0'
- while (*ptr && *ptr != '0') {
+ while (*ptr && *ptr != '0')
tz_string[i++] = *ptr++;
- }
+
// Null terminate
tz_string[i] = '\0';
return tz_string;
diff --git a/src/osd/winui/dialogs.cpp b/src/osd/winui/dialogs.cpp
index 45e9804e0b2..c2275f05b46 100644
--- a/src/osd/winui/dialogs.cpp
+++ b/src/osd/winui/dialogs.cpp
@@ -20,15 +20,11 @@
// standard windows headers
#include <windows.h>
#include <windowsx.h>
-#include <shellapi.h>
+#include <shellapi.h> // ShellExecute
#include <commctrl.h>
-#include <commdlg.h>
// standard C headers
-#include <string.h>
#include <tchar.h>
-#include <stdlib.h>
-#include <assert.h>
// MAMEUI headers
#include "bitmask.h"
@@ -36,13 +32,10 @@
#include "resource.h"
#include "mui_opts.h"
#include "help.h"
-#include "winui.h"
#include "properties.h" // For GetHelpIDs
// MAME headers
-#include "strconv.h"
#include "winutf8.h"
-#include "drivenum.h"
#ifdef _MSC_VER
#define snprintf _snprintf
@@ -78,15 +71,15 @@ const char * GetFilterText(void)
INT_PTR CALLBACK ResetDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- BOOL resetFilters = FALSE;
- BOOL resetGames = FALSE;
- BOOL resetUI = FALSE;
- BOOL resetDefaults = FALSE;
+ BOOL resetFilters = false;
+ BOOL resetGames = false;
+ BOOL resetUI = false;
+ BOOL resetDefaults = false;
switch (Msg)
{
case WM_INITDIALOG:
- return TRUE;
+ return true;
case WM_HELP:
/* User clicked the ? from the upper right on a control */
@@ -103,9 +96,9 @@ INT_PTR CALLBACK ResetDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
{
case IDOK :
resetFilters = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_FILTERS));
- resetGames = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_GAMES));
+ resetGames = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_GAMES));
resetDefaults = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_DEFAULT));
- resetUI = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_UI));
+ resetUI = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_UI));
if (resetFilters || resetGames || resetUI || resetDefaults)
{
@@ -145,10 +138,10 @@ INT_PTR CALLBACK ResetDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
{
ResetGUI();
EndDialog(hDlg, 1);
- return TRUE;
+ return true;
} else {
EndDialog(hDlg, 0);
- return TRUE;
+ return true;
}
} else {
// Give the user a chance to change what they want to reset.
@@ -158,7 +151,7 @@ INT_PTR CALLBACK ResetDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
// Nothing was selected but OK, just fall through
case IDCANCEL :
EndDialog(hDlg, 0);
- return TRUE;
+ return true;
}
break;
}
@@ -171,7 +164,7 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
COLORREF choice_colors[16];
TCHAR tmp[4];
int i = 0;
- BOOL bRedrawList = FALSE;
+ BOOL bRedrawList = false;
int nCurSelection = 0;
int nHistoryTab = 0;
int nTabCount = 0;
@@ -188,9 +181,9 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
Button_SetCheck(GetDlgItem(hDlg,IDC_HIDE_MOUSE),GetHideMouseOnStartup());
// Get the current value of the control
- SendDlgItemMessage(hDlg, IDC_CYCLETIMESEC, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, 60)); /* [0, 60] */
+ SendDlgItemMessage(hDlg, IDC_CYCLETIMESEC, TBM_SETRANGE, (WPARAM)false, (LPARAM)MAKELONG(0, 60)); /* [0, 60] */
value = GetCycleScreenshot();
- SendDlgItemMessage(hDlg,IDC_CYCLETIMESEC, TBM_SETPOS, TRUE, value);
+ SendDlgItemMessage(hDlg,IDC_CYCLETIMESEC, TBM_SETPOS, true, value);
_itot(value,tmp,10);
SendDlgItemMessage(hDlg,IDC_CYCLETIMESECTXT,WM_SETTEXT,0, (WPARAM)tmp);
@@ -250,15 +243,13 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
(void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), 4);
}
- SendDlgItemMessage(hDlg, IDC_SCREENSHOT_BORDERSIZE, TBM_SETRANGE,
- (WPARAM)FALSE,
- (LPARAM)MAKELONG(0, 100)); /* [0, 100] */
+ SendDlgItemMessage(hDlg, IDC_SCREENSHOT_BORDERSIZE, TBM_SETRANGE, (WPARAM)false, (LPARAM)MAKELONG(0, 100)); /* [0, 100] */
value = GetScreenshotBorderSize();
- SendDlgItemMessage(hDlg,IDC_SCREENSHOT_BORDERSIZE, TBM_SETPOS, TRUE, value);
+ SendDlgItemMessage(hDlg,IDC_SCREENSHOT_BORDERSIZE, TBM_SETPOS, true, value);
_itot(value,tmp,10);
SendDlgItemMessage(hDlg,IDC_SCREENSHOT_BORDERSIZETXT,WM_SETTEXT,0, (WPARAM)tmp);
- //return TRUE;
+ //return true;
break;
case WM_HELP:
@@ -286,16 +277,16 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
cc.lpCustColors = choice_colors;
cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_SOLIDCOLOR;
if (!ChooseColor(&cc))
- return TRUE;
- for (i=0;i<16;i++)
+ return true;
+ for (i=0; i<16; i++)
SetCustomColor(i,choice_colors[i]);
SetScreenshotBorderColor(cc.rgbResult);
UpdateScreenShot();
- return TRUE;
+ return true;
}
case IDOK :
{
- BOOL checked = FALSE;
+ BOOL checked = false;
SetGameCheck(Button_GetCheck(GetDlgItem(hDlg, IDC_START_GAME_CHECK)));
SetJoyGUI(Button_GetCheck(GetDlgItem(hDlg, IDC_JOY_GUI)));
@@ -305,12 +296,12 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
if( Button_GetCheck(GetDlgItem(hDlg,IDC_RESET_PLAYCOUNT ) ) )
{
ResetPlayCount( -1 );
- bRedrawList = TRUE;
+ bRedrawList = true;
}
if( Button_GetCheck(GetDlgItem(hDlg,IDC_RESET_PLAYTIME ) ) )
{
ResetPlayTime( -1 );
- bRedrawList = TRUE;
+ bRedrawList = true;
}
value = SendDlgItemMessage(hDlg,IDC_CYCLETIMESEC, TBM_GETPOS, 0, 0);
if( GetCycleScreenshot() != value )
@@ -335,14 +326,14 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
{
SetFilterInherit(checked);
// LineUpIcons does just a ResetListView(), which is what we want here
- PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, FALSE),(LPARAM)NULL);
+ PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, false),(LPARAM)NULL);
}
checked = Button_GetCheck(GetDlgItem(hDlg,IDC_NOOFFSET_CLONES));
if (checked != GetOffsetClones())
{
SetOffsetClones(checked);
// LineUpIcons does just a ResetListView(), which is what we want here
- PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, FALSE),(LPARAM)NULL);
+ PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, false),(LPARAM)NULL);
}
nCurSelection = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_SNAPNAME));
if (nCurSelection != CB_ERR) {
@@ -359,7 +350,7 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
EndDialog(hDlg, 0);
if( GetHistoryTab() != nHistoryTab )
{
- SetHistoryTab(nHistoryTab, TRUE);
+ SetHistoryTab(nHistoryTab, true);
ResizePickerControls(GetMainWindow());
UpdateScreenShot();
}
@@ -367,11 +358,11 @@ INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
{
UpdateListView();
}
- return TRUE;
+ return true;
}
case IDCANCEL :
EndDialog(hDlg, 0);
- return TRUE;
+ return true;
}
break;
}
@@ -396,7 +387,7 @@ INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPa
dwFilters = 0;
- if (folder != NULL)
+ if (folder)
{
char tmp[80];
@@ -409,7 +400,7 @@ INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPa
win_set_window_text_utf8(hDlg, tmp);
if ( GetFilterInherit() )
{
- BOOL bShowExplanation = FALSE;
+ BOOL bShowExplanation = false;
lpParent = GetFolder( folder->m_nParent );
if( lpParent )
{
@@ -420,122 +411,107 @@ INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPa
if( (dwpFilters & F_CLONES) && !(dwFilters & F_CLONES) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_RASTER) && !(dwFilters & F_RASTER) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_WORKING) && !(dwFilters & F_WORKING) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_ARCADE) && !(dwFilters & F_ARCADE) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ARCADE));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ARCADE)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ARCADE), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
if( (dwpFilters & F_MESS) && !(dwFilters & F_MESS) )
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
- strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_MESS));
- strText.append(" (*)");
+ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_MESS)).append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_MESS), strText.c_str());
- bShowExplanation = TRUE;
+ bShowExplanation = true;
}
/*Do not or in the Values of the parent, so that the values of the folder still can be set*/
//dwFilters |= dwpFilters;
}
if( ! bShowExplanation )
{
- ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), FALSE );
+ ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false );
}
}
else
- {
- ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), FALSE );
- }
+ ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false );
+
// Find the matching filter record if it exists
lpFilterRecord = FindFilter(folder->m_nFolderId);
// initialize and disable appropriate controls
for (i = 0; g_lpFilterList[i].m_dwFilterType; i++)
- {
DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters);
- }
}
SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT));
- return FALSE;
+ return false;
}
case WM_HELP:
// User clicked the ? from the upper right on a control
@@ -563,10 +539,8 @@ INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPa
// see which buttons are checked
for (i = 0; g_lpFilterList[i].m_dwFilterType; i++)
- {
if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID)))
dwFilters |= g_lpFilterList[i].m_dwFilterType;
- }
// Mask out invalid filters
dwFilters = ValidateFilters(lpFilterRecord, dwFilters);
@@ -578,11 +552,11 @@ INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPa
folder->m_dwFlags |= dwFilters;
EndDialog(hDlg, 1);
- return TRUE;
+ return true;
case IDCANCEL:
EndDialog(hDlg, 0);
- return TRUE;
+ return true;
default:
// Handle unchecking mutually exclusive filters
@@ -602,8 +576,7 @@ INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
case WM_INITDIALOG:
{
HBITMAP hBmp;
- hBmp = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT),
- IMAGE_BITMAP, 0, 0, LR_SHARED);
+ hBmp = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT), IMAGE_BITMAP, 0, 0, LR_SHARED);
SendDlgItemMessage(hDlg, IDC_ABOUT, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBmp);
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_VERSION), GetVersionString());
}
@@ -631,7 +604,7 @@ INT_PTR CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPA
int i = 0;
TVINSERTSTRUCT tvis;
TVITEM tvi;
- BOOL first_entry = TRUE;
+ BOOL first_entry = true;
HIMAGELIST treeview_icons = GetTreeViewIconList();
// current game passed in using DialogBoxParam()
@@ -670,7 +643,7 @@ INT_PTR CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPA
hti = TreeView_InsertItem(GetDlgItem(hDlg,IDC_CUSTOM_TREE),&tvis);
/* look for children of this custom folder */
- for (jj=0;jj<num_folders;jj++)
+ for (jj=0; jj<num_folders; jj++)
{
if (folders[jj]->m_nParent == i)
{
@@ -697,17 +670,16 @@ INT_PTR CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPA
if (first_entry || folders[i] == default_selection)
{
res = TreeView_SelectItem(GetDlgItem(hDlg,IDC_CUSTOM_TREE),hti);
- first_entry = FALSE;
+ first_entry = false;
}
}
}
}
- win_set_window_text_utf8(GetDlgItem(hDlg,IDC_CUSTOMFILE_GAME),
- ModifyThe(driver_list::driver(driver_index).type.fullname()));
+ win_set_window_text_utf8(GetDlgItem(hDlg,IDC_CUSTOMFILE_GAME), ModifyThe(driver_list::driver(driver_index).type.fullname()));
res++;
- return TRUE;
+ return true;
}
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
@@ -717,21 +689,19 @@ INT_PTR CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPA
TVITEM tvi;
tvi.hItem = TreeView_GetSelection(GetDlgItem(hDlg,IDC_CUSTOM_TREE));
tvi.mask = TVIF_PARAM;
- if (TreeView_GetItem(GetDlgItem(hDlg,IDC_CUSTOM_TREE),&tvi) == TRUE)
+ if (TreeView_GetItem(GetDlgItem(hDlg,IDC_CUSTOM_TREE),&tvi) == true)
{
- /* should look for New... */
-
- default_selection = (LPTREEFOLDER)tvi.lParam; /* start here next time */
-
- AddToCustomFolder((LPTREEFOLDER)tvi.lParam,driver_index);
+ /* should look for New... */
+ default_selection = (LPTREEFOLDER)tvi.lParam; /* start here next time */
+ AddToCustomFolder((LPTREEFOLDER)tvi.lParam,driver_index);
}
- EndDialog(hDlg, 0);
- return TRUE;
+ EndDialog(hDlg, 0);
+ return true;
}
case IDCANCEL:
EndDialog(hDlg, 0);
- return TRUE;
+ return true;
}
break;
@@ -755,8 +725,7 @@ INT_PTR CALLBACK DirectXDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lP
case WM_COMMAND:
if (LOWORD(wParam) == IDB_WEB_PAGE)
- ShellExecute(GetMainWindow(), NULL, TEXT("http://www.microsoft.com/directx"),
- NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute(GetMainWindow(), NULL, TEXT("http://www.microsoft.com/directx"), NULL, NULL, SW_SHOWNORMAL);
if (LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDB_WEB_PAGE)
EndDialog(hDlg, 0);
@@ -787,22 +756,21 @@ static void DisableFilterControls(HWND hWnd, LPCFOLDERDATA lpFilterRecord, LPCFI
{
/* uncheck it and disable the control */
Button_SetCheck(hWndCtrl, MF_UNCHECKED);
- EnableWindow(hWndCtrl, FALSE);
+ EnableWindow(hWndCtrl, false);
}
/* If this is an implied filter, check it and disable the control */
if (lpFilterRecord->m_dwSet & dwFilterType)
{
Button_SetCheck(hWndCtrl, MF_CHECKED);
- EnableWindow(hWndCtrl, FALSE);
+ EnableWindow(hWndCtrl, false);
}
}
// Handle disabling mutually exclusive controls
static void EnableFilterExclusions(HWND hWnd, DWORD dwCtrlID)
{
- int i = 0;
- DWORD id = 0;
+ int i;
for (i = 0; i < NUM_EXCLUSIONS; i++)
{
@@ -817,6 +785,7 @@ static void EnableFilterExclusions(HWND hWnd, DWORD dwCtrlID)
// if the control was found
if (i < NUM_EXCLUSIONS)
{
+ DWORD id;
// find the opposing control id
if (i % 2)
id = filterExclusion[i - 1];
diff --git a/src/osd/winui/dijoystick.cpp b/src/osd/winui/dijoystick.cpp
index 1136c7f0179..3350ea2f5d4 100644
--- a/src/osd/winui/dijoystick.cpp
+++ b/src/osd/winui/dijoystick.cpp
@@ -1,9 +1,10 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
/***************************************************************************
- dijoystick.c
+ dijoystick.cpp
***************************************************************************/
@@ -11,8 +12,6 @@
#include <windows.h>
// standard C headers
-#include <stdio.h>
-#include <math.h>
#include <tchar.h>
// MAMEUI headers
@@ -20,7 +19,6 @@
#include "directinput.h"
#include "dijoystick.h"
#include "mui_util.h" // For ErrorMsg
-#include "dxdecode.h" // for DirectXDecodeError
/***************************************************************************
function prototypes
@@ -97,9 +95,9 @@ static BOOL CALLBACK DIJoystick_EnumAxisObjectsProc(LPCDIDEVICEOBJECTINSTANCE lp
static BOOL CALLBACK DIJoystick_EnumPOVObjectsProc(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
static BOOL CALLBACK DIJoystick_EnumButtonObjectsProc(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
static void ClearJoyState(DIJOYSTATE *pdijs);
-
static void InitJoystick(joystick_type *joystick);
static void ExitJoystick(joystick_type *joystick);
+const char * DirectXDecodeError(HRESULT errorval);
/***************************************************************************
Internal variables
@@ -118,25 +116,18 @@ static const GUID guidNULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
*/
static int DIJoystick_init(void)
{
- DWORD i = 0;
- HRESULT hr;
- LPDIRECTINPUT di = GetDirectInput();
-
This.use_count++;
-
This.num_joysticks = 0;
+ LPDIRECTINPUT di = GetDirectInput();
if (di == NULL)
{
ErrorMsg("DirectInput not initialized");
- return 0;
+ return 1;
}
/* enumerate for joystick devices */
- hr = IDirectInput_EnumDevices(di, DIDEVTYPE_JOYSTICK,
- (LPDIENUMDEVICESCALLBACK)DIJoystick_EnumDeviceProc,
- NULL,
- DIEDFL_ATTACHEDONLY );
+ HRESULT hr = IDirectInput_EnumDevices(di, DIDEVTYPE_JOYSTICK, (LPDIENUMDEVICESCALLBACK)DIJoystick_EnumDeviceProc, NULL, DIEDFL_ATTACHEDONLY );
if (FAILED(hr))
{
ErrorMsg("DirectInput EnumDevices() failed: %s", DirectXDecodeError(hr));
@@ -144,17 +135,13 @@ static int DIJoystick_init(void)
}
/* create each joystick device, enumerate each joystick for axes, etc */
- for (i = 0; i < This.num_joysticks; i++)
- {
+ for (DWORD i = 0; i < This.num_joysticks; i++)
InitJoystick(&This.joysticks[i]);
- }
/* Are there any joysticks attached? */
if (This.num_joysticks < 1)
- {
/*ErrorMsg("DirectInput EnumDevices didn't find any joysticks");*/
- return 0;
- }
+ return 1;
return 0;
}
@@ -164,14 +151,11 @@ static int DIJoystick_init(void)
*/
static void DIJoystick_exit(void)
{
- DWORD i = 0;
-
This.use_count--;
-
if (This.use_count > 0)
return;
- for (i = 0; i < This.num_joysticks; i++)
+ for (DWORD i = 0; i < This.num_joysticks; i++)
ExitJoystick(&This.joysticks[i]);
This.num_joysticks = 0;
@@ -180,11 +164,9 @@ static void DIJoystick_exit(void)
static void DIJoystick_poll_joysticks(void)
{
HRESULT hr;
- DWORD i = 0;
-
This.m_bCoinSlot = 0;
- for (i = 0; i < This.num_joysticks; i++)
+ for (DWORD i = 0; i < This.num_joysticks; i++)
{
/* start by clearing the structure, then fill it in if possible */
@@ -202,9 +184,8 @@ static void DIJoystick_poll_joysticks(void)
if (FAILED(hr))
{
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED)
- {
hr = IDirectInputDevice2_Acquire(This.joysticks[i].did);
- }
+
continue;
}
}
@@ -217,17 +198,11 @@ static void DIJoystick_poll_joysticks(void)
static int DIJoystick_is_joy_pressed(int joycode)
{
- int joy_num = 0;
- int stick = 0;
int axis = 0;
int dir = 0;
-
- DIJOYSTATE dijs;
-
int value = 0;
int dz = 60;
-
- joy_num = GET_JOYCODE_JOY(joycode);
+ int joy_num = GET_JOYCODE_JOY(joycode);
/* do we have as many sticks? */
if (joy_num == 0 || This.num_joysticks < joy_num)
@@ -237,9 +212,9 @@ static int DIJoystick_is_joy_pressed(int joycode)
if (This.joysticks[joy_num].use_joystick == FALSE)
return 0;
- dijs = This.joysticks[joy_num].dijs;
+ DIJOYSTATE dijs = This.joysticks[joy_num].dijs;
- stick = GET_JOYCODE_STICK(joycode);
+ int stick = GET_JOYCODE_STICK(joycode);
if (stick == JOYCODE_STICK_BTN)
{
@@ -310,52 +285,43 @@ static int DIJoystick_is_joy_pressed(int joycode)
static BOOL DIJoystick_Available(void)
{
- static BOOL bBeenHere = FALSE;
- static BOOL bAvailable = FALSE;
- HRESULT hr;
- GUID guidDevice = guidNULL;
- LPDIRECTINPUTDEVICE didTemp;
- LPDIRECTINPUTDEVICE didJoystick;
+ static BOOL bBeenHere = false;
+ static BOOL bAvailable = false;
LPDIRECTINPUT di = GetDirectInput();
if (di == NULL)
- {
- return FALSE;
- }
+ return false;
- if (bBeenHere == FALSE)
- bBeenHere = TRUE;
+ if (bBeenHere == false)
+ bBeenHere = true;
else
return bAvailable;
/* enumerate for joystick devices */
- hr = IDirectInput_EnumDevices(di, DIDEVTYPE_JOYSTICK, inputEnumDeviceProc, &guidDevice, DIEDFL_ATTACHEDONLY);
+ GUID guidDevice = guidNULL;
+ HRESULT hr = IDirectInput_EnumDevices(di, DIDEVTYPE_JOYSTICK, inputEnumDeviceProc, &guidDevice, DIEDFL_ATTACHEDONLY );
if (FAILED(hr))
{
- return FALSE;
+ return false;
}
/* Are there any joysticks attached? */
if (IsEqualGUID(guidDevice, guidNULL))
- {
- return FALSE;
- }
+ return false;
+ LPDIRECTINPUTDEVICE didTemp;
hr = IDirectInput_CreateDevice(di, guidDevice, &didTemp, NULL);
if (FAILED(hr))
- {
- return FALSE;
- }
+ return false;
/* Determine if DX5 is available by a QI for a DX5 interface. */
+ LPDIRECTINPUTDEVICE didJoystick;
hr = IDirectInputDevice_QueryInterface(didTemp, IID_IDirectInputDevice2, (void**)&didJoystick);
if (FAILED(hr))
- {
- bAvailable = FALSE;
- }
+ bAvailable = false;
else
{
- bAvailable = TRUE;
+ bAvailable = true;
IDirectInputDevice_Release(didJoystick);
}
@@ -407,18 +373,14 @@ BOOL CALLBACK DIJoystick_EnumDeviceProc(LPDIDEVICEINSTANCE pdidi, LPVOID pv)
static BOOL CALLBACK DIJoystick_EnumAxisObjectsProc(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
{
joystick_type* joystick = (joystick_type*)pvRef;
- DIPROPRANGE diprg;
- HRESULT hr;
-
joystick->axes[joystick->num_axes].guid = lpddoi->guidType;
-
joystick->axes[joystick->num_axes].name = (TCHAR *)malloc((_tcslen(lpddoi->tszName) + 1) * sizeof(TCHAR));
_tcscpy(joystick->axes[joystick->num_axes].name, lpddoi->tszName);
-
joystick->axes[joystick->num_axes].offset = lpddoi->dwOfs;
/*ErrorMsg("got axis %s, offset %i",lpddoi->tszName, lpddoi->dwOfs);*/
+ DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(diprg);
diprg.diph.dwHeaderSize = sizeof(diprg.diph);
diprg.diph.dwObj = lpddoi->dwOfs;
@@ -426,7 +388,7 @@ static BOOL CALLBACK DIJoystick_EnumAxisObjectsProc(LPCDIDEVICEOBJECTINSTANCE lp
diprg.lMin = 0;
diprg.lMax = 255;
- hr = IDirectInputDevice2_SetProperty(joystick->did, DIPROP_RANGE, &diprg.diph);
+ HRESULT hr = IDirectInputDevice2_SetProperty(joystick->did, DIPROP_RANGE, &diprg.diph);
if (FAILED(hr)) /* if this fails, don't use this axis */
{
free(joystick->axes[joystick->num_axes].name);
@@ -436,10 +398,7 @@ static BOOL CALLBACK DIJoystick_EnumAxisObjectsProc(LPCDIDEVICEOBJECTINSTANCE lp
#ifdef JOY_DEBUG
if (FAILED(hr))
- {
- ErrorMsg("DirectInput SetProperty() joystick axis %s failed - %s\n",
- joystick->axes[joystick->num_axes].name, DirectXDecodeError(hr));
- }
+ ErrorMsg("DirectInput SetProperty() joystick axis %s failed - %s\n", joystick->axes[joystick->num_axes].name, DirectXDecodeError(hr));
#endif
/* Set axis dead zone to 0; we need accurate #'s for analog joystick reading. */
@@ -448,10 +407,7 @@ static BOOL CALLBACK DIJoystick_EnumAxisObjectsProc(LPCDIDEVICEOBJECTINSTANCE lp
#ifdef JOY_DEBUG
if (FAILED(hr))
- {
- ErrorMsg("DirectInput SetProperty() joystick axis %s dead zone failed - %s\n",
- joystick->axes[joystick->num_axes].name, DirectXDecodeError(hr));
- }
+ ErrorMsg("DirectInput SetProperty() joystick axis %s dead zone failed - %s\n", joystick->axes[joystick->num_axes].name, DirectXDecodeError(hr));
#endif
joystick->num_axes++;
@@ -494,19 +450,15 @@ static void ClearJoyState(DIJOYSTATE *pdijs)
static void InitJoystick(joystick_type *joystick)
{
- LPDIRECTINPUTDEVICE didTemp;
- HRESULT hr;
- LPDIRECTINPUT di = GetDirectInput();
-
- joystick->use_joystick = FALSE;
-
+ joystick->use_joystick = false;
joystick->did = NULL;
joystick->num_axes = 0;
-
joystick->is_light_gun = (_tcscmp(joystick->name, TEXT("ACT LABS GS (ACT LABS GS)")) == 0);
/* get a did1 interface first... */
- hr = IDirectInput_CreateDevice(di, joystick->guidDevice, &didTemp, NULL);
+ LPDIRECTINPUT di = GetDirectInput();
+ LPDIRECTINPUTDEVICE didTemp;
+ HRESULT hr = IDirectInput_CreateDevice(di, joystick->guidDevice, &didTemp, NULL);
if (FAILED(hr))
{
ErrorMsg("DirectInput CreateDevice() joystick failed: %s\n", DirectXDecodeError(hr));
@@ -604,26 +556,203 @@ static void InitJoystick(joystick_type *joystick)
static void ExitJoystick(joystick_type *joystick)
{
- DWORD i = 0;
-
- if (joystick->did != NULL)
+ if (joystick->did)
{
IDirectInputDevice_Unacquire(joystick->did);
IDirectInputDevice_Release(joystick->did);
joystick->did = NULL;
}
- for (i = 0; i < joystick->num_axes; i++)
+ for (DWORD i = 0; i < joystick->num_axes; i++)
{
if (joystick->axes[i].name)
free(joystick->axes[i].name);
joystick->axes[i].name = NULL;
}
- if (joystick->name != NULL)
+ if (joystick->name)
{
free(joystick->name);
joystick->name = NULL;
}
}
+/***************************************************************************
+ DXdecode stuff
+ ***************************************************************************/
+
+typedef struct tagERRORCODE
+{
+ HRESULT hr;
+ const char *szError;
+} ERRORCODE, * LPERRORCODE;
+
+#include <ddraw.h>
+static const ERRORCODE g_ErrorCode[] =
+{
+ { DDERR_ALREADYINITIALIZED, "DDERR_ALREADYINITIALIZED"},
+ { DDERR_CANNOTATTACHSURFACE, "DDERR_CANNOTATTACHSURFACE"},
+ { DDERR_CANNOTDETACHSURFACE, "DDERR_CANNOTDETACHSURFACE"},
+ { DDERR_CURRENTLYNOTAVAIL, "DDERR_CURRENTLYNOTAVAIL"},
+ { DDERR_EXCEPTION, "DDERR_EXCEPTION"},
+ { DDERR_GENERIC, "DDERR_GENERIC"},
+ { DDERR_HEIGHTALIGN, "DDERR_HEIGHTALIGN"},
+ { DDERR_INCOMPATIBLEPRIMARY, "DDERR_INCOMPATIBLEPRIMARY"},
+ { DDERR_INVALIDCAPS, "DDERR_INVALIDCAPS"},
+ { DDERR_INVALIDCLIPLIST, "DDERR_INVALIDCLIPLIST"},
+ { DDERR_INVALIDMODE, "DDERR_INVALIDMODE"},
+ { DDERR_INVALIDOBJECT, "DDERR_INVALIDOBJECT"},
+ { DDERR_INVALIDPARAMS, "DDERR_INVALIDPARAMS"},
+ { DDERR_INVALIDPIXELFORMAT, "DDERR_INVALIDPIXELFORMAT"},
+ { DDERR_INVALIDRECT, "DDERR_INVALIDRECT"},
+ { DDERR_LOCKEDSURFACES, "DDERR_LOCKEDSURFACES"},
+ { DDERR_NO3D, "DDERR_NO3D"},
+ { DDERR_NOALPHAHW, "DDERR_NOALPHAHW"},
+ { DDERR_NOCLIPLIST, "DDERR_NOCLIPLIST"},
+ { DDERR_NOCOLORCONVHW, "DDERR_NOCOLORCONVHW"},
+ { DDERR_NOCOOPERATIVELEVELSET, "DDERR_NOCOOPERATIVELEVELSET"},
+ { DDERR_NOCOLORKEY, "DDERR_NOCOLORKEY"},
+ { DDERR_NOCOLORKEYHW, "DDERR_NOCOLORKEYHW"},
+ { DDERR_NODIRECTDRAWSUPPORT, "DDERR_NODIRECTDRAWSUPPORT"},
+ { DDERR_NOEXCLUSIVEMODE, "DDERR_NOEXCLUSIVEMODE"},
+ { DDERR_NOFLIPHW, "DDERR_NOFLIPHW"},
+ { DDERR_NOGDI, "DDERR_NOGDI"},
+ { DDERR_NOMIRRORHW, "DDERR_NOMIRRORHW"},
+ { DDERR_NOTFOUND, "DDERR_NOTFOUND"},
+ { DDERR_NOOVERLAYHW, "DDERR_NOOVERLAYHW"},
+ { DDERR_NORASTEROPHW, "DDERR_NORASTEROPHW"},
+ { DDERR_NOROTATIONHW, "DDERR_NOROTATIONHW"},
+ { DDERR_NOSTRETCHHW, "DDERR_NOSTRETCHHW"},
+ { DDERR_NOT4BITCOLOR, "DDERR_NOT4BITCOLOR"},
+ { DDERR_NOT4BITCOLORINDEX, "DDERR_NOT4BITCOLORINDEX"},
+ { DDERR_NOT8BITCOLOR, "DDERR_NOT8BITCOLOR"},
+ { DDERR_NOTEXTUREHW, "DDERR_NOTEXTUREHW"},
+ { DDERR_NOVSYNCHW, "DDERR_NOVSYNCHW"},
+ { DDERR_NOZBUFFERHW, "DDERR_NOZBUFFERHW"},
+ { DDERR_NOZOVERLAYHW, "DDERR_NOZOVERLAYHW"},
+ { DDERR_OUTOFCAPS, "DDERR_OUTOFCAPS"},
+ { DDERR_OUTOFMEMORY, "DDERR_OUTOFMEMORY"},
+ { DDERR_OUTOFVIDEOMEMORY, "DDERR_OUTOFVIDEOMEMORY"},
+ { DDERR_OVERLAYCANTCLIP, "DDERR_OVERLAYCANTCLIP"},
+ { DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "DDERR_OVERLAYCOLORKEYONLYONEACTIVE"},
+ { DDERR_PALETTEBUSY, "DDERR_PALETTEBUSY"},
+ { DDERR_COLORKEYNOTSET, "DDERR_COLORKEYNOTSET"},
+ { DDERR_SURFACEALREADYATTACHED, "DDERR_SURFACEALREADYATTACHED"},
+ { DDERR_SURFACEALREADYDEPENDENT, "DDERR_SURFACEALREADYDEPENDENT"},
+ { DDERR_SURFACEBUSY, "DDERR_SURFACEBUSY"},
+ { DDERR_CANTLOCKSURFACE, "DDERR_CANTLOCKSURFACE"},
+ { DDERR_SURFACEISOBSCURED, "DDERR_SURFACEISOBSCURED"},
+ { DDERR_SURFACELOST, "DDERR_SURFACELOST"},
+ { DDERR_SURFACENOTATTACHED, "DDERR_SURFACENOTATTACHED"},
+ { DDERR_TOOBIGHEIGHT, "DDERR_TOOBIGHEIGHT"},
+ { DDERR_TOOBIGSIZE, "DDERR_TOOBIGSIZE"},
+ { DDERR_TOOBIGWIDTH, "DDERR_TOOBIGWIDTH"},
+ { DDERR_UNSUPPORTED, "DDERR_UNSUPPORTED"},
+ { DDERR_UNSUPPORTEDFORMAT, "DDERR_UNSUPPORTEDFORMAT"},
+ { DDERR_UNSUPPORTEDMASK, "DDERR_UNSUPPORTEDMASK"},
+ { DDERR_VERTICALBLANKINPROGRESS, "DDERR_VERTICALBLANKINPROGRESS"},
+ { DDERR_WASSTILLDRAWING, "DDERR_WASSTILLDRAWING"},
+ { DDERR_XALIGN, "DDERR_XALIGN"},
+ { DDERR_INVALIDDIRECTDRAWGUID, "DDERR_INVALIDDIRECTDRAWGUID"},
+ { DDERR_DIRECTDRAWALREADYCREATED, "DDERR_DIRECTDRAWALREADYCREATED"},
+ { DDERR_NODIRECTDRAWHW, "DDERR_NODIRECTDRAWHW"},
+ { DDERR_PRIMARYSURFACEALREADYEXISTS, "DDERR_PRIMARYSURFACEALREADYEXISTS"},
+ { DDERR_NOEMULATION, "DDERR_NOEMULATION"},
+ { DDERR_REGIONTOOSMALL, "DDERR_REGIONTOOSMALL"},
+ { DDERR_CLIPPERISUSINGHWND, "DDERR_CLIPPERISUSINGHWND"},
+ { DDERR_NOCLIPPERATTACHED, "DDERR_NOCLIPPERATTACHED"},
+ { DDERR_NOHWND, "DDERR_NOHWND"},
+ { DDERR_HWNDSUBCLASSED, "DDERR_HWNDSUBCLASSED"},
+ { DDERR_HWNDALREADYSET, "DDERR_HWNDALREADYSET"},
+ { DDERR_NOPALETTEATTACHED, "DDERR_NOPALETTEATTACHED"},
+ { DDERR_NOPALETTEHW, "DDERR_NOPALETTEHW"},
+ { DDERR_BLTFASTCANTCLIP, "DDERR_BLTFASTCANTCLIP"},
+ { DDERR_NOBLTHW, "DDERR_NOBLTHW"},
+ { DDERR_NODDROPSHW, "DDERR_NODDROPSHW"},
+ { DDERR_OVERLAYNOTVISIBLE, "DDERR_OVERLAYNOTVISIBLE"},
+ { DDERR_NOOVERLAYDEST, "DDERR_NOOVERLAYDEST"},
+ { DDERR_INVALIDPOSITION, "DDERR_INVALIDPOSITION"},
+ { DDERR_NOTAOVERLAYSURFACE, "DDERR_NOTAOVERLAYSURFACE"},
+ { DDERR_EXCLUSIVEMODEALREADYSET, "DDERR_EXCLUSIVEMODEALREADYSET"},
+ { DDERR_NOTFLIPPABLE, "DDERR_NOTFLIPPABLE"},
+ { DDERR_CANTDUPLICATE, "DDERR_CANTDUPLICATE"},
+ { DDERR_NOTLOCKED, "DDERR_NOTLOCKED"},
+ { DDERR_CANTCREATEDC, "DDERR_CANTCREATEDC"},
+ { DDERR_NODC, "DDERR_NODC"},
+ { DDERR_WRONGMODE, "DDERR_WRONGMODE"},
+ { DDERR_IMPLICITLYCREATED, "DDERR_IMPLICITLYCREATED"},
+ { DDERR_NOTPALETTIZED, "DDERR_NOTPALETTIZED"},
+ { DDERR_UNSUPPORTEDMODE, "DDERR_UNSUPPORTEDMODE"},
+ { DDERR_NOMIPMAPHW, "DDERR_NOMIPMAPHW"},
+ { DDERR_INVALIDSURFACETYPE, "DDERR_INVALIDSURFACETYPE"},
+
+ { DDERR_NOOPTIMIZEHW, "DDERR_NOOPTIMIZEHW"},
+ { DDERR_NOTLOADED, "DDERR_NOTLOADED"},
+
+ { DDERR_DCALREADYCREATED, "DDERR_DCALREADYCREATED"},
+
+ { DDERR_NONONLOCALVIDMEM, "DDERR_NONONLOCALVIDMEM"},
+ { DDERR_CANTPAGELOCK, "DDERR_CANTPAGELOCK"},
+ { DDERR_CANTPAGEUNLOCK, "DDERR_CANTPAGEUNLOCK"},
+ { DDERR_NOTPAGELOCKED, "DDERR_NOTPAGELOCKED"},
+
+ { DDERR_MOREDATA, "DDERR_MOREDATA"},
+ { DDERR_VIDEONOTACTIVE, "DDERR_VIDEONOTACTIVE"},
+ { DDERR_DEVICEDOESNTOWNSURFACE, "DDERR_DEVICEDOESNTOWNSURFACE"},
+ { DDERR_NOTINITIALIZED, "DDERR_NOTINITIALIZED"},
+
+ { DIERR_OLDDIRECTINPUTVERSION, "DIERR_OLDDIRECTINPUTVERSION" },
+ { DIERR_BETADIRECTINPUTVERSION, "DIERR_BETADIRECTINPUTVERSION" },
+ { DIERR_BADDRIVERVER, "DIERR_BADDRIVERVER" },
+ { DIERR_DEVICENOTREG, "DIERR_DEVICENOTREG" },
+ { DIERR_NOTFOUND, "DIERR_NOTFOUND" },
+ { DIERR_OBJECTNOTFOUND, "DIERR_OBJECTNOTFOUND" },
+ { DIERR_INVALIDPARAM, "DIERR_INVALIDPARAM" },
+ { DIERR_NOINTERFACE, "DIERR_NOINTERFACE" },
+ { DIERR_GENERIC, "DIERR_GENERIC" },
+ { DIERR_OUTOFMEMORY, "DIERR_OUTOFMEMORY" },
+ { DIERR_UNSUPPORTED, "DIERR_UNSUPPORTED" },
+ { DIERR_NOTINITIALIZED, "DIERR_NOTINITIALIZED" },
+ { DIERR_ALREADYINITIALIZED, "DIERR_ALREADYINITIALIZED" },
+ { DIERR_NOAGGREGATION, "DIERR_NOAGGREGATION" },
+ { DIERR_OTHERAPPHASPRIO, "DIERR_OTHERAPPHASPRIO" },
+ { DIERR_INPUTLOST, "DIERR_INPUTLOST" },
+ { DIERR_ACQUIRED, "DIERR_ACQUIRED" },
+ { DIERR_NOTACQUIRED, "DIERR_NOTACQUIRED" },
+ { DIERR_READONLY, "DIERR_READONLY" },
+ { DIERR_HANDLEEXISTS, "DIERR_HANDLEEXISTS" },
+ { E_PENDING, "E_PENDING" },
+ { (HRESULT)DIERR_INSUFFICIENTPRIVS, "DIERR_INSUFFICIENTPRIVS" },
+ { (HRESULT)DIERR_DEVICEFULL, "DIERR_DEVICEFULL" },
+ { (HRESULT)DIERR_MOREDATA, "DIERR_MOREDATA" },
+ { (HRESULT)DIERR_NOTDOWNLOADED, "DIERR_NOTDOWNLOADED" },
+ { (HRESULT)DIERR_HASEFFECTS, "DIERR_HASEFFECTS" },
+ { (HRESULT)DIERR_NOTEXCLUSIVEACQUIRED,"DIERR_NOTEXCLUSIVEACQUIRED" },
+ { (HRESULT)DIERR_INCOMPLETEEFFECT, "DIERR_INCOMPLETEEFFECT" },
+ { (HRESULT)DIERR_NOTBUFFERED, "DIERR_NOTBUFFERED" },
+ { (HRESULT)DIERR_EFFECTPLAYING, "DIERR_EFFECTPLAYING" },
+ //{ (HRESULT)DIERR_UNPLUGGED, "DIERR_UNPLUGGED" },
+
+ { E_NOINTERFACE, "E_NOINTERFACE" }
+
+};
+
+
+/****************************************************************************
+ DirectXDecodeError: Return a string description of the given DirectX
+ error code.
+*****************************************************************************/
+const char * DirectXDecodeError(HRESULT errorval)
+{
+ for (int i = 0; i < (sizeof(g_ErrorCode) / sizeof(g_ErrorCode[0])); i++)
+ {
+ if (g_ErrorCode[i].hr == errorval)
+ {
+ return g_ErrorCode[i].szError;
+ }
+ }
+ static char tmp[64];
+ sprintf(tmp, "UNKNOWN: 0x%x", (unsigned int)errorval);
+ return tmp;
+}
+
diff --git a/src/osd/winui/directdraw.cpp b/src/osd/winui/directdraw.cpp
deleted file mode 100644
index c85f97f8a76..00000000000
--- a/src/osd/winui/directdraw.cpp
+++ /dev/null
@@ -1,382 +0,0 @@
-// For licensing and usage information, read docs/winui_license.txt
-//****************************************************************************
-/***************************************************************************
-
- directdraw.c
-
- Direct Draw routines.
-
- ***************************************************************************/
-
-// standard windows headers
-#include <windows.h>
-
-// MAME/MAMEUI headers
-#include "emu.h"
-#include "winui.h"
-#include "directdraw.h"
-#include "mui_util.h" // For ErrorMsg
-#include "dxdecode.h" // For DirectXDecodeError
-
-// standard C headers
-#include <ddraw.h>
-#include <tchar.h>
-
-/***************************************************************************
- function prototypes
- ***************************************************************************/
-
-static BOOL WINAPI DDEnumInfo(GUID FAR *lpGUID, LPTSTR lpDriverDescription,
- LPTSTR lpDriverName, LPVOID lpContext, HMONITOR hm);
-
-static BOOL WINAPI DDEnumOldInfo(GUID FAR *lpGUID, LPTSTR lpDriverDescription,
- LPTSTR lpDriverName, LPVOID lpContext);
-
-static void CalculateDisplayModes(void);
-static HRESULT CALLBACK EnumDisplayModesCallback(LPDDSURFACEDESC pddsd, LPVOID Context);
-static HRESULT CALLBACK EnumDisplayModesCallback2(DDSURFACEDESC2* pddsd, LPVOID Context);
-
-/***************************************************************************
- External variables
- ***************************************************************************/
-
-/***************************************************************************
- Internal structures
- ***************************************************************************/
-
-typedef struct
-{
- TCHAR* name;
- GUID* lpguid;
-} display_type;
-
-typedef HRESULT (WINAPI *ddc_proc)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter);
-
-/***************************************************************************
- Internal variables
- ***************************************************************************/
-
-#define MAX_DISPLAYS 100
-static int g_nNumDisplays = 0;
-static display_type g_Displays[MAX_DISPLAYS];
-
-static HANDLE g_hDLL;
-static BOOL g_bHWStretch = 0;
-static BOOL g_bRefresh = 0;
-static struct tDisplayModes g_DisplayModes;
-static IDirectDraw2* g_pDirectDraw2;
-static IDirectDraw4* g_pDirectDraw4;
-
-/***************************************************************************
- External functions
- ***************************************************************************/
-
-/****************************************************************************
- * DirectDrawInitialize
- *
- * Initialize the DirectDraw variables.
- *
- * This entails the following functions:
- *
- * DirectDrawCreate
- *
- ****************************************************************************/
-
-#if !defined(LPDIRECTDRAWENUMERATE)
-#if defined(UNICODE)
-
-typedef HRESULT (WINAPI* LPDIRECTDRAWENUMERATEW)(LPDDENUMCALLBACKW lpCallback, LPVOID lpContext);
-
-#define LPDIRECTDRAWENUMERATE LPDIRECTDRAWENUMERATEW
-
-#define SDirectDrawEnumerateEx "DirectDrawEnumerateExW"
-#define SDirectDrawEnumerate "DirectDrawEnumerateW"
-
-#else
-
-typedef HRESULT (WINAPI* LPDIRECTDRAWENUMERATEA)(LPDDENUMCALLBACKA lpCallback, LPVOID lpContext);
-
-#define LPDIRECTDRAWENUMERATE LPDIRECTDRAWENUMERATEA
-
-#define SDirectDrawEnumerateEx "DirectDrawEnumerateExA"
-#define SDirectDrawEnumerate "DirectDrawEnumerateA"
-
-#endif
-#endif /* LPDIRECTDRAWENUMERATE */
-
-/****************************************************************************/
-
-BOOL DirectDraw_Initialize(void)
-{
- HRESULT hr;
- UINT error_mode = 0;
- ddc_proc ddc;
- DDCAPS ddCaps;
- DDCAPS ddHelCaps;
- IDirectDraw* pDirectDraw1;
- LPDIRECTDRAWENUMERATEEX pDDEnumEx;
-
- if (g_hDLL != NULL)
- return TRUE;
-
- g_nNumDisplays = 0;
- g_hDLL = NULL;
- g_bHWStretch = FALSE;
- g_bRefresh = FALSE;
- g_pDirectDraw2 = NULL;
- g_pDirectDraw4 = NULL;
-
- /* Turn off error dialog for this call */
- error_mode = SetErrorMode(0);
- g_hDLL = LoadLibrary(TEXT("ddraw.dll"));
- SetErrorMode(error_mode);
-
- if (g_hDLL == NULL)
- return FALSE;
-
- ddc = (ddc_proc)GetProcAddress((HINSTANCE)g_hDLL, "DirectDrawCreate");
- if (ddc == NULL)
- return FALSE;
-
- pDirectDraw1 = NULL;
- g_pDirectDraw2 = NULL;
- g_pDirectDraw4 = NULL;
- hr = ddc(NULL, &pDirectDraw1, NULL);
- if (FAILED(hr))
- {
- ErrorMsg("DirectDrawCreate failed: %s", DirectXDecodeError(hr));
- return FALSE;
- }
-
- hr = IDirectDraw_QueryInterface(pDirectDraw1, IID_IDirectDraw4, (void**)&g_pDirectDraw4);
- if (FAILED(hr))
- {
- g_pDirectDraw4 = NULL;
- hr = IDirectDraw_QueryInterface(pDirectDraw1, IID_IDirectDraw2, (void**)&g_pDirectDraw2);
- if (FAILED(hr))
- {
- ErrorMsg("Query Interface for DirectDraw 2 failed: %s", DirectXDecodeError(hr));
- g_pDirectDraw2 = NULL;
- IDirectDraw_Release(pDirectDraw1);
- return FALSE;
- }
- }
-
- memset(&ddCaps, 0, sizeof(DDCAPS));
- memset(&ddHelCaps, 0, sizeof(DDCAPS));
- ddCaps.dwSize = sizeof(DDCAPS);
- ddHelCaps.dwSize = sizeof(DDCAPS);
- hr = IDirectDraw_GetCaps(pDirectDraw1, &ddCaps, &ddHelCaps); /* 1 2 or 4? */
- if (FAILED(hr))
- {
- ErrorMsg("Error getting DirectDraw capabilities: %s", DirectXDecodeError(hr));
- }
- else
- g_bHWStretch = ((ddCaps.dwCaps & DDCAPS_BLTSTRETCH) != 0) ? TRUE : FALSE;
-
- IDirectDraw_Release(pDirectDraw1);
-
- /*
- Note that you must know which version of the
- function to retrieve (see the following text).
- For this example, we use the ANSI version.
- */
- pDDEnumEx = (LPDIRECTDRAWENUMERATEEX) GetProcAddress((HINSTANCE)g_hDLL, SDirectDrawEnumerateEx);
-
- /*
- If the function is there, call it to enumerate all display devices
- attached to the desktop, and any non-display DirectDraw devices.
- */
- if (pDDEnumEx)
- {
- pDDEnumEx(DDEnumInfo, NULL, DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_DETACHEDSECONDARYDEVICES);
- }
- else
- {
- LPDIRECTDRAWENUMERATE lpDDEnum;
-
- lpDDEnum = (LPDIRECTDRAWENUMERATE) GetProcAddress((HINSTANCE)g_hDLL, SDirectDrawEnumerate);
- /*
- * We must be running on an old version of ddraw. Therefore,
- * by definiton, multimon isn't supported. Fall back on
- * DirectDrawEnumerate to enumerate standard devices on a
- * single monitor system.
- */
- if (lpDDEnum)
- {
- lpDDEnum(DDEnumOldInfo, NULL);
- }
- else
- {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-/****************************************************************************
- *
- * DirectDraw_Close
- *
- * Terminate our usage of DirectDraw.
- *
- ****************************************************************************/
-
-void DirectDraw_Close(void)
-{
- int i;
-
- for (i = 0; i < g_nNumDisplays; i++)
- {
- free(g_Displays[i].name);
- g_Displays[i].name = NULL;
- if (g_Displays[i].lpguid != NULL)
- {
- free(g_Displays[i].lpguid);
- g_Displays[i].lpguid = NULL;
- }
-
- }
- g_nNumDisplays = 0;
-
- /*
- Destroy any lingering IDirectDraw object.
- */
- if (g_pDirectDraw2)
- {
- IDirectDraw2_Release(g_pDirectDraw2);
- g_pDirectDraw2 = NULL;
- }
-
- if (g_pDirectDraw4)
- {
- IDirectDraw4_Release(g_pDirectDraw4);
- g_pDirectDraw4 = NULL;
- }
-
- if (g_hDLL)
- {
- FreeLibrary((HINSTANCE)g_hDLL);
- g_hDLL = NULL;
- }
-}
-
-/****************************************************************************/
-/*
- Return a list of 16, 24 and 32 bit DirectDraw modes.
-*/
-struct tDisplayModes* DirectDraw_GetDisplayModes(void)
-{
- if (g_DisplayModes.m_nNumModes == 0)
- CalculateDisplayModes();
-
- return &g_DisplayModes;
-}
-
-int DirectDraw_GetNumDisplays(void)
-{
- return g_nNumDisplays;
-}
-
-BOOL DirectDraw_HasHWStretch(void)
-{
- return g_bHWStretch;
-}
-
-BOOL DirectDraw_HasRefresh(void)
-{
- return g_bRefresh;
-}
-
-LPCTSTR DirectDraw_GetDisplayName(int num_display)
-{
- return g_Displays[num_display].name;
-}
-
-/****************************************************************************/
-/* internal functions */
-/****************************************************************************/
-
-static BOOL WINAPI DDEnumInfo(GUID FAR *lpGUID, LPTSTR lpDriverDescription,
- LPTSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
-{
- g_Displays[g_nNumDisplays].name = (TCHAR*)malloc((_tcslen(lpDriverDescription) + 1) * sizeof(TCHAR));
- _tcscpy(g_Displays[g_nNumDisplays].name, lpDriverDescription);
-
- if (lpGUID == NULL)
- g_Displays[g_nNumDisplays].lpguid = NULL;
- else
- {
- g_Displays[g_nNumDisplays].lpguid = (LPGUID)malloc(sizeof(GUID));
- memcpy(g_Displays[g_nNumDisplays].lpguid, lpGUID, sizeof(GUID));
- }
-
- g_nNumDisplays++;
- if (g_nNumDisplays == MAX_DISPLAYS)
- return DDENUMRET_CANCEL;
- else
- return DDENUMRET_OK;
-}
-
-static BOOL WINAPI DDEnumOldInfo(GUID FAR *lpGUID, LPTSTR lpDriverDescription, LPTSTR lpDriverName, LPVOID lpContext)
-{
- return DDEnumInfo(lpGUID, lpDriverDescription, lpDriverName, lpContext, NULL);
-}
-
-static HRESULT CALLBACK EnumDisplayModesCallback(LPDDSURFACEDESC pddsd, LPVOID Context)
-{
- DWORD dwDepth = pddsd->ddpfPixelFormat.dwRGBBitCount;
-
- struct tDisplayModes* pDisplayModes = (struct tDisplayModes*)Context;
- if (dwDepth == 16 || dwDepth == 24 || dwDepth == 32)
- {
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwWidth = pddsd->dwWidth;
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwHeight = pddsd->dwHeight;
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwBPP = dwDepth;
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwRefresh = 0;
- pDisplayModes->m_nNumModes++;
- }
-
- if (pDisplayModes->m_nNumModes == MAXMODES)
- return DDENUMRET_CANCEL;
- else
- return DDENUMRET_OK;
-}
-
-static HRESULT CALLBACK EnumDisplayModesCallback2(DDSURFACEDESC2* pddsd2, LPVOID Context)
-{
- struct tDisplayModes* pDisplayModes = (struct tDisplayModes*)Context;
-
- DWORD dwDepth = pddsd2->ddpfPixelFormat.dwRGBBitCount;
-
- if (dwDepth == 16 || dwDepth == 24 || dwDepth == 32)
- {
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwWidth = pddsd2->dwWidth;
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwHeight = pddsd2->dwHeight;
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwBPP = dwDepth;
- pDisplayModes->m_Modes[pDisplayModes->m_nNumModes].m_dwRefresh = pddsd2->dwRefreshRate;
- pDisplayModes->m_nNumModes++;
-
- if (pddsd2->dwRefreshRate != 0)
- g_bRefresh = TRUE;
- }
-
- if (pDisplayModes->m_nNumModes == MAXMODES)
- return DDENUMRET_CANCEL;
- else
- return DDENUMRET_OK;
-}
-
-static void CalculateDisplayModes(void)
-{
- g_DisplayModes.m_nNumModes = 0;
-
- if (g_pDirectDraw4)
- IDirectDraw4_EnumDisplayModes(g_pDirectDraw4, DDEDM_REFRESHRATES, NULL, &g_DisplayModes, EnumDisplayModesCallback2);
- else
- if (g_pDirectDraw2)
- IDirectDraw2_EnumDisplayModes(g_pDirectDraw2, 0, NULL, &g_DisplayModes, EnumDisplayModesCallback);
-}
-
-
diff --git a/src/osd/winui/directdraw.h b/src/osd/winui/directdraw.h
deleted file mode 100644
index 95140a54ab5..00000000000
--- a/src/osd/winui/directdraw.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// For licensing and usage information, read docs/winui_license.txt
-//****************************************************************************
-
-#ifndef DIRECTDRAW_H
-#define DIRECTDRAW_H
-
-#include <ddraw.h>
-
-#define MAXMODES 256 /* Maximum number of DirectDraw Display modes. */
-
-/* Display mode node */
-struct tDisplayMode
-{
- DWORD m_dwWidth;
- DWORD m_dwHeight;
- DWORD m_dwBPP;
- DWORD m_dwRefresh;
-};
-
-/* EnumDisplayMode Context */
-struct tDisplayModes
-{
- struct tDisplayMode m_Modes[MAXMODES];
- int m_nNumModes;
-};
-
-extern BOOL DirectDraw_Initialize(void);
-extern void DirectDraw_Close(void);
-
-extern struct tDisplayModes* DirectDraw_GetDisplayModes(void);
-extern int DirectDraw_GetNumDisplays(void);
-extern BOOL DirectDraw_HasHWStretch(void);
-extern BOOL DirectDraw_HasRefresh(void);
-extern LPCTSTR DirectDraw_GetDisplayName(int num_display);
-
-#endif
diff --git a/src/osd/winui/directinput.cpp b/src/osd/winui/directinput.cpp
index 5e5c554a95c..33977913b14 100644
--- a/src/osd/winui/directinput.cpp
+++ b/src/osd/winui/directinput.cpp
@@ -4,7 +4,7 @@
/***************************************************************************
- directinput.c
+ directinput.cpp
Direct Input routines.
@@ -13,7 +13,6 @@
#include <windows.h>
// MAME/MAMEUI headers
-#include "emu.h"
#include "mui_util.h" // For ErrorMsg
#include "directinput.h"
@@ -56,32 +55,27 @@ typedef HRESULT (WINAPI *dic_proc)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINP
BOOL DirectInputInitialize()
{
- HRESULT hr;
- UINT error_mode = 0;
- dic_proc dic;
-
- if (hDLL != NULL)
+ if (hDLL)
return TRUE;
- hDLL = NULL;
-
/* Turn off error dialog for this call */
- error_mode = SetErrorMode(0);
+ UINT error_mode = SetErrorMode(0);
hDLL = LoadLibrary(TEXT("dinput.dll"));
SetErrorMode(error_mode);
if (hDLL == NULL)
return FALSE;
+ dic_proc dic;
#ifdef UNICODE
dic = (dic_proc)GetProcAddress((HINSTANCE)hDLL, "DirectInputCreateW");
#else
dic = (dic_proc)GetProcAddress((HINSTANCE)hDLL, "DirectInputCreateA");
#endif
if (dic == NULL)
- return FALSE;
+ return false;
- hr = dic(GetModuleHandle(NULL), 0x0700, &di, NULL); // setup DIRECT INPUT 7 for the GUI
+ HRESULT hr = dic(GetModuleHandle(NULL), 0x0700, &di, NULL); // setup DIRECT INPUT 7 for the GUI
if (FAILED(hr))
{
@@ -91,10 +85,10 @@ BOOL DirectInputInitialize()
{
ErrorMsg("DirectInputCreate failed! error=%x\n", (unsigned int)hr);
di = NULL;
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
/****************************************************************************
diff --git a/src/osd/winui/directories.cpp b/src/osd/winui/directories.cpp
index 5fa20784950..7479ee7d2f8 100644
--- a/src/osd/winui/directories.cpp
+++ b/src/osd/winui/directories.cpp
@@ -13,15 +13,12 @@
#include <windowsx.h>
// standard C headers
-#include <sys/stat.h>
-#include <assert.h>
+#include <sys/stat.h> // S_IFDIR
#include <tchar.h>
// MAME/MAMEUI headers
-#include "winui.h"
#include "directories.h"
#include "resource.h"
-#include "strconv.h"
#include "mui_util.h"
// SHELL DIR header
@@ -92,7 +89,7 @@ static tDirInfo *g_pDirInfo;
INT_PTR CALLBACK DirectoriesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- BOOL bReturn = FALSE;
+ BOOL bReturn = false;
switch (Msg)
{
@@ -101,7 +98,7 @@ INT_PTR CALLBACK DirectoriesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARA
case WM_COMMAND:
HANDLE_WM_COMMAND(hDlg, wParam, lParam, Directories_OnCommand);
- bReturn = TRUE;
+ bReturn = true;
break;
case WM_NOTIFY:
@@ -116,7 +113,7 @@ INT_PTR CALLBACK DirectoriesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARA
break;
default:
- bReturn = FALSE;
+ break;
}
return bReturn;
}
@@ -132,30 +129,28 @@ static BOOL IsMultiDir(int nType)
static void DirInfo_SetDir(tDirInfo *pInfo, int nType, int nItem, LPCTSTR pText)
{
- TCHAR *t_s;
- TCHAR *t_pOldText;
-
if (IsMultiDir(nType))
{
- assert(nItem >= 0);
+ //assert(nItem >= 0);
_tcscpy(DirInfo_Path(pInfo, nType, nItem), pText);
- DirInfo_SetModified(pInfo, nType, TRUE);
+ DirInfo_SetModified(pInfo, nType, true);
}
else
{
- t_s = win_tstring_strdup(pText);
+ TCHAR* t_s = win_tstring_strdup(pText);
if (!t_s)
return;
- t_pOldText = pInfo[nType].m_tDirectory;
+ TCHAR* t_pOldText = pInfo[nType].m_tDirectory;
if (t_pOldText)
free(t_pOldText);
pInfo[nType].m_tDirectory = t_s;
+ free(t_s);
}
}
static TCHAR* DirInfo_Dir(tDirInfo *pInfo, int nType)
{
- assert(!IsMultiDir(nType));
+ //assert(!IsMultiDir(nType));
TCHAR* t = pInfo[nType].m_tDirectory;
// if a multipath exists in a single-path-only area then truncate it
TCHAR* i = _tcstok(t, TEXT(";"));
@@ -170,13 +165,13 @@ static TCHAR* DirInfo_Path(tDirInfo *pInfo, int nType, int nItem)
static void DirInfo_SetModified(tDirInfo *pInfo, int nType, BOOL bModified)
{
- assert(IsMultiDir(nType));
+ //assert(IsMultiDir(nType));
pInfo[nType].m_Path->m_bModified = bModified;
}
static BOOL DirInfo_Modified(tDirInfo *pInfo, int nType)
{
- assert(IsMultiDir(nType));
+ //assert(IsMultiDir(nType));
return pInfo[nType].m_Path->m_bModified;
}
@@ -199,28 +194,25 @@ static TCHAR * FixSlash(TCHAR *s)
static void UpdateDirectoryList(HWND hDlg)
{
- bool b_res = 0;
- int i = 0;
- int nType = 0;
- LV_ITEM Item;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
HWND hCombo = GetDlgItem(hDlg, IDC_DIR_COMBO);
/* Remove previous */
- b_res = ListView_DeleteAllItems(hList);
+ bool b_res = ListView_DeleteAllItems(hList);
/* Update list */
+ LV_ITEM Item;
memset(&Item, 0, sizeof(LV_ITEM));
Item.mask = LVIF_TEXT;
- nType = ComboBox_GetCurSel(hCombo);
+ int nType = ComboBox_GetCurSel(hCombo);
if (IsMultiDir(nType))
{
Item.pszText = (TCHAR*) TEXT(DIRLIST_NEWENTRYTEXT); // puts the < > empty entry in
(void)ListView_InsertItem(hList, &Item);
int t = DirInfo_NumDir(g_pDirInfo, nType);
// directories are inserted in reverse order
- for (i = t; 0 < i; i--)
+ for (int i = t; 0 < i; i--)
{
Item.pszText = DirInfo_Path(g_pDirInfo, nType, i-1);
(void)ListView_InsertItem(hList, &Item);
@@ -261,7 +253,6 @@ static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
RECT rectClient;
LVCOLUMN LVCol;
int i = 0;
- int nDirInfoCount = 0;
LPCSTR s;
TCHAR *token;
TCHAR buf[MAX_PATH * MAX_DIRS];
@@ -269,7 +260,7 @@ static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
HRESULT res = 0;
/* count how many dirinfos there are */
- nDirInfoCount = 0;
+ int nDirInfoCount = 0;
while(g_directoryInfo[nDirInfoCount].lpName)
nDirInfoCount++;
@@ -305,7 +296,7 @@ static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
s = g_directoryInfo[i].pfnGetTheseDirs();
t_s = ui_wstring_from_utf8(s);
if( !t_s )
- return FALSE;
+ return false;
/* Copy the string to our own buffer so that we can mutilate it */
_tcscpy(buf, t_s);
@@ -339,28 +330,26 @@ static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
}
UpdateDirectoryList(hDlg);
- return TRUE;
+ return true;
error:
if( t_s )
free(t_s);
Directories_OnDestroy(hDlg);
EndDialog(hDlg, -1);
- return FALSE;
+ return false;
}
static void Directories_OnDestroy(HWND hDlg)
{
- int nDirInfoCount = 0, i = 0;
-
if (g_pDirInfo)
{
/* count how many dirinfos there are */
- nDirInfoCount = 0;
+ int nDirInfoCount = 0;
while(g_directoryInfo[nDirInfoCount].lpName)
nDirInfoCount++;
- for (i = 0; i < nDirInfoCount; i++)
+ for (int i = 0; i < nDirInfoCount; i++)
{
if (g_pDirInfo[i].m_Path)
free(g_pDirInfo[i].m_Path);
@@ -379,24 +368,21 @@ static void Directories_OnClose(HWND hDlg)
static int RetrieveDirList(int nDir, int nFlagResult, void (*SetTheseDirs)(const char *s))
{
- int i = 0;
int nResult = 0;
- int nPaths = 0;
- TCHAR buf[MAX_PATH * MAX_DIRS];
- char* utf8_buf;
if (DirInfo_Modified(g_pDirInfo, nDir))
{
+ TCHAR buf[MAX_PATH * MAX_DIRS];
memset(buf, 0, sizeof(buf));
- nPaths = DirInfo_NumDir(g_pDirInfo, nDir);
- for (i = 0; i < nPaths; i++)
+ int nPaths = DirInfo_NumDir(g_pDirInfo, nDir);
+ for (int i = 0; i < nPaths; i++)
{
_tcscat(buf, FixSlash(DirInfo_Path(g_pDirInfo, nDir, i)));
if (i < nPaths - 1)
_tcscat(buf, TEXT(";"));
}
- utf8_buf = ui_utf8_from_wstring(buf);
+ char* utf8_buf = ui_utf8_from_wstring(buf);
SetTheseDirs(utf8_buf);
free(utf8_buf);
@@ -407,21 +393,16 @@ static int RetrieveDirList(int nDir, int nFlagResult, void (*SetTheseDirs)(const
static void Directories_OnOk(HWND hDlg)
{
- int i = 0;
int nResult = 0;
- LPTSTR s;
- char* utf8_s;
- for (i = 0; g_directoryInfo[i].lpName; i++)
+ for (int i = 0; g_directoryInfo[i].lpName; i++)
{
if (IsMultiDir(i))
- {
nResult |= RetrieveDirList(i, g_directoryInfo[i].nDirDlgFlags, g_directoryInfo[i].pfnSetTheseDirs);
- }
else
{
- s = FixSlash(DirInfo_Dir(g_pDirInfo, i));
- utf8_s = ui_utf8_from_wstring(s);
+ LPTSTR s = FixSlash(DirInfo_Dir(g_pDirInfo, i));
+ char* utf8_s = ui_utf8_from_wstring(s);
g_directoryInfo[i].pfnSetTheseDirs(utf8_s);
free(utf8_s);
}
@@ -436,34 +417,28 @@ static void Directories_OnCancel(HWND hDlg)
static void Directories_OnInsert(HWND hDlg)
{
- int nItem = 0;
- TCHAR buf[MAX_PATH];
- HWND hList = 0;
-
- hList = GetDlgItem(hDlg, IDC_DIR_LIST);
- nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
+ HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
+ int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
- if (BrowseForDirectory(hDlg, NULL, buf) == TRUE)
+ TCHAR buf[MAX_PATH];
+ if (BrowseForDirectory(hDlg, NULL, buf) == true)
{
- int i = 0;
- int nType = 0;
-
/* list was empty */
if (nItem == -1)
nItem = 0;
- nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
+ int nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
if (IsMultiDir(nType))
{
if (MAX_DIRS <= DirInfo_NumDir(g_pDirInfo, nType))
return;
- for (i = DirInfo_NumDir(g_pDirInfo, nType); nItem < i; i--)
+ for (int i = DirInfo_NumDir(g_pDirInfo, nType); nItem < i; i--)
_tcscpy(DirInfo_Path(g_pDirInfo, nType, i), DirInfo_Path(g_pDirInfo, nType, i - 1));
_tcscpy(DirInfo_Path(g_pDirInfo, nType, nItem), buf);
DirInfo_NumDir(g_pDirInfo, nType)++;
- DirInfo_SetModified(g_pDirInfo, nType, TRUE);
+ DirInfo_SetModified(g_pDirInfo, nType, true);
}
UpdateDirectoryList(hDlg);
@@ -474,19 +449,13 @@ static void Directories_OnInsert(HWND hDlg)
static void Directories_OnBrowse(HWND hDlg)
{
- int nType = 0;
- int nItem = 0;
- TCHAR inbuf[MAX_PATH];
- TCHAR outbuf[MAX_PATH];
- HWND hList = 0;
-
- hList = GetDlgItem(hDlg, IDC_DIR_LIST);
- nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
+ HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
+ int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
if (nItem == -1)
return;
- nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
+ int nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
if (IsMultiDir(nType))
{
/* Last item is placeholder for append */
@@ -497,9 +466,10 @@ static void Directories_OnBrowse(HWND hDlg)
}
}
+ TCHAR inbuf[MAX_PATH], outbuf[MAX_PATH];
ListView_GetItemText(hList, nItem, 0, inbuf, MAX_PATH);
- if (BrowseForDirectory(hDlg, inbuf, outbuf) == TRUE)
+ if (BrowseForDirectory(hDlg, inbuf, outbuf) == true)
{
nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
DirInfo_SetDir(g_pDirInfo, nType, nItem, outbuf);
@@ -509,14 +479,8 @@ static void Directories_OnBrowse(HWND hDlg)
static void Directories_OnDelete(HWND hDlg)
{
- int nType = 0;
- int nCount = 0;
- int nSelect = 0;
- int i = 0;
- int nItem = 0;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
-
- nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);
+ int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);
if (nItem == -1)
return;
@@ -525,12 +489,11 @@ static void Directories_OnDelete(HWND hDlg)
if (nItem == ListView_GetItemCount(hList) - 1)
return;
- nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
+ int nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
if (IsMultiDir(nType))
{
- for (i = nItem; i < DirInfo_NumDir(g_pDirInfo, nType) - 1; i++)
- _tcscpy(DirInfo_Path(g_pDirInfo, nType, i),
- DirInfo_Path(g_pDirInfo, nType, i + 1));
+ for (int i = nItem; i < DirInfo_NumDir(g_pDirInfo, nType) - 1; i++)
+ _tcscpy(DirInfo_Path(g_pDirInfo, nType, i), DirInfo_Path(g_pDirInfo, nType, i + 1));
_tcscpy(DirInfo_Path(g_pDirInfo, nType, DirInfo_NumDir(g_pDirInfo, nType) - 1), TEXT(""));
DirInfo_NumDir(g_pDirInfo, nType)--;
@@ -540,12 +503,12 @@ static void Directories_OnDelete(HWND hDlg)
UpdateDirectoryList(hDlg);
-
- nCount = ListView_GetItemCount(hList);
+ int nCount = ListView_GetItemCount(hList);
if (nCount <= 1)
return;
/* If the last item was removed, select the item above. */
+ int nSelect;
if (nItem == nCount - 1)
nSelect = nCount - 2;
else
@@ -556,19 +519,18 @@ static void Directories_OnDelete(HWND hDlg)
static BOOL Directories_OnBeginLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
- int nType = 0;
- BOOL bResult = FALSE;
+ BOOL bResult = false;
NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
LVITEM* pItem = &pDispInfo->item;
- nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
+ int nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
if (IsMultiDir(nType))
{
/* Last item is placeholder for append */
if (pItem->iItem == ListView_GetItemCount(GetDlgItem(hDlg, IDC_DIR_LIST)) - 1)
{
if (MAX_DIRS <= DirInfo_NumDir(g_pDirInfo, nType))
- return TRUE; /* don't edit */
+ return true; /* don't edit */
HWND hEdit = (HWND)(LRESULT)(int)SendDlgItemMessage(hDlg, IDC_DIR_LIST, LVM_GETEDITCONTROL, 0, 0);
Edit_SetText(hEdit, TEXT(""));
@@ -580,68 +542,54 @@ static BOOL Directories_OnBeginLabelEdit(HWND hDlg, NMHDR* pNMHDR)
static BOOL Directories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
- BOOL bResult = FALSE;
+ BOOL bResult = false;
NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
LVITEM* pItem = &pDispInfo->item;
- if (pItem->pszText != NULL)
+ if (pItem->pszText)
{
struct _stat file_stat;
/* Don't allow empty entries. */
if (!_tcscmp(pItem->pszText, TEXT("")))
- {
- return FALSE;
- }
+ return false;
/* Check validity of edited directory. */
if (_tstat(pItem->pszText, &file_stat) == 0
&& (file_stat.st_mode & S_IFDIR))
- {
- bResult = TRUE;
- }
+ bResult = true;
else
- {
- if (MessageBox(NULL, TEXT("Directory does not exist, continue anyway?"), TEXT(MAMEUINAME), MB_OKCANCEL) == IDOK)
- bResult = TRUE;
- }
+ if (MessageBox(NULL, TEXT("Directory does not exist, continue anyway?"), TEXT(MAMEUINAME), MB_OKCANCEL) == IDOK)
+ bResult = true;
}
- if (bResult == TRUE)
+ if (bResult == true)
{
- int nType = 0;
- int i = 0;
-
- nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
+ int nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
if (IsMultiDir(nType))
{
/* Last item is placeholder for append */
if (pItem->iItem == ListView_GetItemCount(GetDlgItem(hDlg, IDC_DIR_LIST)) - 1)
{
if (MAX_DIRS <= DirInfo_NumDir(g_pDirInfo, nType))
- return FALSE;
+ return false;
- for (i = DirInfo_NumDir(g_pDirInfo, nType); pItem->iItem < i; i--)
- _tcscpy(DirInfo_Path(g_pDirInfo, nType, i),
- DirInfo_Path(g_pDirInfo, nType, i - 1));
+ for (int i = DirInfo_NumDir(g_pDirInfo, nType); pItem->iItem < i; i--)
+ _tcscpy(DirInfo_Path(g_pDirInfo, nType, i), DirInfo_Path(g_pDirInfo, nType, i - 1));
_tcscpy(DirInfo_Path(g_pDirInfo, nType, pItem->iItem), pItem->pszText);
- DirInfo_SetModified(g_pDirInfo, nType, TRUE);
+ DirInfo_SetModified(g_pDirInfo, nType, true);
DirInfo_NumDir(g_pDirInfo, nType)++;
}
else
DirInfo_SetDir(g_pDirInfo, nType, pItem->iItem, pItem->pszText);
}
else
- {
DirInfo_SetDir(g_pDirInfo, nType, pItem->iItem, pItem->pszText);
- }
UpdateDirectoryList(hDlg);
- ListView_SetItemState(GetDlgItem(hDlg, IDC_DIR_LIST), pItem->iItem,
- LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
-
+ ListView_SetItemState(GetDlgItem(hDlg, IDC_DIR_LIST), pItem->iItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
}
return bResult;
@@ -718,7 +666,7 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPAR
*/
if (uMsg == BFFM_INITIALIZED)
{
- if ((const char*)lpData != NULL)
+ if ((const char*)lpData)
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}
@@ -727,11 +675,10 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPAR
BOOL BrowseForDirectory(HWND hwnd, LPCTSTR pStartDir, TCHAR* pResult)
{
- BOOL bResult = FALSE;
- BROWSEINFO Info;
- LPITEMIDLIST pItemIDList = NULL;
+ BOOL bResult = false;
TCHAR buf[MAX_PATH];
+ BROWSEINFO Info;
Info.hwndOwner = hwnd;
Info.pidlRoot = NULL;
Info.pszDisplayName = buf;
@@ -740,18 +687,18 @@ BOOL BrowseForDirectory(HWND hwnd, LPCTSTR pStartDir, TCHAR* pResult)
Info.lpfn = BrowseCallbackProc;
Info.lParam = (LPARAM)pStartDir;
- pItemIDList = SHBrowseForFolder(&Info);
+ LPITEMIDLIST pItemIDList = SHBrowseForFolder(&Info);
- if (pItemIDList != NULL)
+ if (pItemIDList)
{
- if (SHGetPathFromIDList(pItemIDList, buf) == TRUE)
+ if (SHGetPathFromIDList(pItemIDList, buf) == true)
{
_sntprintf(pResult, MAX_PATH, TEXT("%s"), buf);
- bResult = TRUE;
+ bResult = true;
}
}
else
- bResult = FALSE;
+ bResult = false;
return bResult;
}
diff --git a/src/osd/winui/directories.h b/src/osd/winui/directories.h
index d38d3caa932..14fa3a69c06 100644
--- a/src/osd/winui/directories.h
+++ b/src/osd/winui/directories.h
@@ -36,7 +36,7 @@ const DIRECTORYINFO g_directoryInfo[] =
{ "ROMs", GetRomDirs, SetRomDirs, TRUE, DIRDLG_ROMS },
{ "Samples", GetSampleDirs, SetSampleDirs, TRUE, DIRDLG_SAMPLES },
{ "Software File Base", GetSWDir, SetSWDir, FALSE, DIRDLG_SW }, // core cannot handle multiple path, even though we can.
- { "Software List Base", GetSLDir, SetSLDir, FALSE, DIRDLG_SL },
+// { "Software List Base", GetSLDir, SetSLDir, FALSE, DIRDLG_SL }, // no longer used, 2017-07-14
{ "Artwork", GetArtDir, SetArtDir, TRUE, 0 },
{ "Cabinets", GetCabinetDir, SetCabinetDir, TRUE, 0 },
{ "Cheats", GetCheatDir, SetCheatDir, TRUE, DIRDLG_CHEAT },
diff --git a/src/osd/winui/dirwatch.cpp b/src/osd/winui/dirwatch.cpp
index 62d0ac7d7e9..5ae56b48e72 100644
--- a/src/osd/winui/dirwatch.cpp
+++ b/src/osd/winui/dirwatch.cpp
@@ -1,18 +1,13 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
// standard windows headers
#include <windows.h>
-// standard C headers
-#include <string.h>
-#include <tchar.h>
-
// MAME/MAMEUI headers
#include "dirwatch.h"
-#include "emu.h"
#include "mui_util.h"
-#include "strconv.h"
typedef BOOL (WINAPI *READDIRECTORYCHANGESFUNC)(HANDLE hDirectory, LPVOID lpBuffer,
DWORD nBufferLength, BOOL bWatchSubtree, DWORD dwNotifyFilter,
@@ -90,8 +85,7 @@ static void DirWatcher_FreeEntry(struct DirWatcherEntry *pEntry)
-static BOOL DirWatcher_WatchDirectory(PDIRWATCHER pWatcher, int nIndex, int nSubIndex,
- LPCSTR pszPath, BOOL bWatchSubtree)
+static BOOL DirWatcher_WatchDirectory(PDIRWATCHER pWatcher, int nIndex, int nSubIndex, LPCSTR pszPath, BOOL bWatchSubtree)
{
struct DirWatcherEntry *pEntry;
HANDLE hDir;
@@ -121,12 +115,12 @@ static BOOL DirWatcher_WatchDirectory(PDIRWATCHER pWatcher, int nIndex, int nSub
pWatcher->pEntries = pEntry;
DirWatcher_SetupWatch(pWatcher, pEntry);
- return TRUE;
+ return true;
error:
if (pEntry)
DirWatcher_FreeEntry(pEntry);
- return FALSE;
+ return false;
}
@@ -134,37 +128,31 @@ error:
static void DirWatcher_Signal(PDIRWATCHER pWatcher, struct DirWatcherEntry *pEntry)
{
LPSTR pszFileName;
- LPSTR pszFullFileName;
BOOL bPause = 0;
HANDLE hFile;
- int nTries = 0;
- TCHAR* t_filename;
{
- int nLength;
- nLength = WideCharToMultiByte(CP_ACP, 0, pEntry->u.notify.FileName, -1, NULL, 0, NULL, NULL);
+ int nLength = WideCharToMultiByte(CP_ACP, 0, pEntry->u.notify.FileName, -1, NULL, 0, NULL, NULL);
pszFileName = (LPSTR) alloca(nLength * sizeof(*pszFileName));
WideCharToMultiByte(CP_ACP, 0, pEntry->u.notify.FileName, -1, pszFileName, nLength, NULL, NULL);
}
// get the full path to this new file
- pszFullFileName = (LPSTR) alloca(strlen(pEntry->szDirPath) + strlen(pszFileName) + 2);
+ LPSTR pszFullFileName = (LPSTR) alloca(strlen(pEntry->szDirPath) + strlen(pszFileName) + 2);
strcpy(pszFullFileName, pEntry->szDirPath);
strcat(pszFullFileName, "\\");
strcat(pszFullFileName, pszFileName);
// attempt to busy wait until any result other than ERROR_SHARING_VIOLATION
// is generated
- nTries = 100;
+ int nTries = 100;
do
{
- hFile = win_create_file_utf8(pszFullFileName, GENERIC_READ,
- FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ hFile = win_create_file_utf8(pszFullFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
- bPause = (nTries--) && (hFile == INVALID_HANDLE_VALUE)
- && (GetLastError() == ERROR_SHARING_VIOLATION);
+ bPause = (nTries--) && (hFile == INVALID_HANDLE_VALUE) && (GetLastError() == ERROR_SHARING_VIOLATION);
if (bPause)
Sleep(10);
}
@@ -173,13 +161,10 @@ static void DirWatcher_Signal(PDIRWATCHER pWatcher, struct DirWatcherEntry *pEnt
// send the message (assuming that we have a target)
if (pWatcher->hwndTarget)
{
- t_filename = ui_wstring_from_utf8(pszFileName);
+ TCHAR* t_filename = ui_wstring_from_utf8(pszFileName);
if( !t_filename )
return;
- SendMessage(pWatcher->hwndTarget,
- pWatcher->nMessage,
- (pEntry->nIndex << 16) | (pEntry->nSubIndex << 0),
- (LPARAM)(LPCTSTR) win_tstring_strdup(t_filename));
+ SendMessage(pWatcher->hwndTarget, pWatcher->nMessage, (pEntry->nIndex << 16) | (pEntry->nSubIndex << 0), (LPARAM)(LPCTSTR) win_tstring_strdup(t_filename));
free(t_filename);
}
@@ -190,8 +175,7 @@ static void DirWatcher_Signal(PDIRWATCHER pWatcher, struct DirWatcherEntry *pEnt
static DWORD WINAPI DirWatcher_ThreadProc(LPVOID lpParameter)
{
- LPSTR pszPathList;
- LPSTR s;
+ LPSTR pszPathList, s;
int nSubIndex = 0;
PDIRWATCHER pWatcher = (PDIRWATCHER) lpParameter;
struct DirWatcherEntry *pEntry;
@@ -265,8 +249,8 @@ static DWORD WINAPI DirWatcher_ThreadProc(LPVOID lpParameter)
PDIRWATCHER DirWatcher_Init(HWND hwndTarget, UINT nMessage)
{
- struct DirWatcher *pWatcher = NULL;
DWORD nThreadID = 0;
+ struct DirWatcher *pWatcher = NULL;
// This feature does not exist on Win9x
if (GetVersion() >= 0x80000000)
@@ -321,7 +305,7 @@ BOOL DirWatcher_Watch(PDIRWATCHER pWatcher, WORD nIndex, LPCSTR pszPathList, BOO
WaitForSingleObject(pWatcher->hResponseEvent, INFINITE);
LeaveCriticalSection(&pWatcher->crit);
- return TRUE;
+ return true;
}
@@ -334,7 +318,7 @@ void DirWatcher_Free(PDIRWATCHER pWatcher)
if (pWatcher->hThread)
{
EnterCriticalSection(&pWatcher->crit);
- pWatcher->bQuit = TRUE;
+ pWatcher->bQuit = true;
SetEvent(pWatcher->hRequestEvent);
WaitForSingleObject(pWatcher->hThread, 1000);
LeaveCriticalSection(&pWatcher->crit);
diff --git a/src/osd/winui/dxdecode.cpp b/src/osd/winui/dxdecode.cpp
deleted file mode 100644
index 7fd82828fe8..00000000000
--- a/src/osd/winui/dxdecode.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-// For licensing and usage information, read docs/winui_license.txt
-//****************************************************************************
-
-// standard windows headers
-#include <windows.h>
-#include <ddraw.h>
-
-// standard C headers
-#include <stdio.h>
-
-// MAME/MAMEUI headers
-#include "directinput.h"
-#include "dxdecode.h"
-
-/***************************************************************/
-
-typedef struct tagERRORCODE
-{
- HRESULT hr;
- const char *szError;
-} ERRORCODE, * LPERRORCODE;
-
-/***************************************************************/
-static const ERRORCODE g_ErrorCode[] =
-{
- { DDERR_ALREADYINITIALIZED, "DDERR_ALREADYINITIALIZED"},
- { DDERR_CANNOTATTACHSURFACE, "DDERR_CANNOTATTACHSURFACE"},
- { DDERR_CANNOTDETACHSURFACE, "DDERR_CANNOTDETACHSURFACE"},
- { DDERR_CURRENTLYNOTAVAIL, "DDERR_CURRENTLYNOTAVAIL"},
- { DDERR_EXCEPTION, "DDERR_EXCEPTION"},
- { DDERR_GENERIC, "DDERR_GENERIC"},
- { DDERR_HEIGHTALIGN, "DDERR_HEIGHTALIGN"},
- { DDERR_INCOMPATIBLEPRIMARY, "DDERR_INCOMPATIBLEPRIMARY"},
- { DDERR_INVALIDCAPS, "DDERR_INVALIDCAPS"},
- { DDERR_INVALIDCLIPLIST, "DDERR_INVALIDCLIPLIST"},
- { DDERR_INVALIDMODE, "DDERR_INVALIDMODE"},
- { DDERR_INVALIDOBJECT, "DDERR_INVALIDOBJECT"},
- { DDERR_INVALIDPARAMS, "DDERR_INVALIDPARAMS"},
- { DDERR_INVALIDPIXELFORMAT, "DDERR_INVALIDPIXELFORMAT"},
- { DDERR_INVALIDRECT, "DDERR_INVALIDRECT"},
- { DDERR_LOCKEDSURFACES, "DDERR_LOCKEDSURFACES"},
- { DDERR_NO3D, "DDERR_NO3D"},
- { DDERR_NOALPHAHW, "DDERR_NOALPHAHW"},
- { DDERR_NOCLIPLIST, "DDERR_NOCLIPLIST"},
- { DDERR_NOCOLORCONVHW, "DDERR_NOCOLORCONVHW"},
- { DDERR_NOCOOPERATIVELEVELSET, "DDERR_NOCOOPERATIVELEVELSET"},
- { DDERR_NOCOLORKEY, "DDERR_NOCOLORKEY"},
- { DDERR_NOCOLORKEYHW, "DDERR_NOCOLORKEYHW"},
- { DDERR_NODIRECTDRAWSUPPORT, "DDERR_NODIRECTDRAWSUPPORT"},
- { DDERR_NOEXCLUSIVEMODE, "DDERR_NOEXCLUSIVEMODE"},
- { DDERR_NOFLIPHW, "DDERR_NOFLIPHW"},
- { DDERR_NOGDI, "DDERR_NOGDI"},
- { DDERR_NOMIRRORHW, "DDERR_NOMIRRORHW"},
- { DDERR_NOTFOUND, "DDERR_NOTFOUND"},
- { DDERR_NOOVERLAYHW, "DDERR_NOOVERLAYHW"},
- { DDERR_NORASTEROPHW, "DDERR_NORASTEROPHW"},
- { DDERR_NOROTATIONHW, "DDERR_NOROTATIONHW"},
- { DDERR_NOSTRETCHHW, "DDERR_NOSTRETCHHW"},
- { DDERR_NOT4BITCOLOR, "DDERR_NOT4BITCOLOR"},
- { DDERR_NOT4BITCOLORINDEX, "DDERR_NOT4BITCOLORINDEX"},
- { DDERR_NOT8BITCOLOR, "DDERR_NOT8BITCOLOR"},
- { DDERR_NOTEXTUREHW, "DDERR_NOTEXTUREHW"},
- { DDERR_NOVSYNCHW, "DDERR_NOVSYNCHW"},
- { DDERR_NOZBUFFERHW, "DDERR_NOZBUFFERHW"},
- { DDERR_NOZOVERLAYHW, "DDERR_NOZOVERLAYHW"},
- { DDERR_OUTOFCAPS, "DDERR_OUTOFCAPS"},
- { DDERR_OUTOFMEMORY, "DDERR_OUTOFMEMORY"},
- { DDERR_OUTOFVIDEOMEMORY, "DDERR_OUTOFVIDEOMEMORY"},
- { DDERR_OVERLAYCANTCLIP, "DDERR_OVERLAYCANTCLIP"},
- { DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "DDERR_OVERLAYCOLORKEYONLYONEACTIVE"},
- { DDERR_PALETTEBUSY, "DDERR_PALETTEBUSY"},
- { DDERR_COLORKEYNOTSET, "DDERR_COLORKEYNOTSET"},
- { DDERR_SURFACEALREADYATTACHED, "DDERR_SURFACEALREADYATTACHED"},
- { DDERR_SURFACEALREADYDEPENDENT, "DDERR_SURFACEALREADYDEPENDENT"},
- { DDERR_SURFACEBUSY, "DDERR_SURFACEBUSY"},
- { DDERR_CANTLOCKSURFACE, "DDERR_CANTLOCKSURFACE"},
- { DDERR_SURFACEISOBSCURED, "DDERR_SURFACEISOBSCURED"},
- { DDERR_SURFACELOST, "DDERR_SURFACELOST"},
- { DDERR_SURFACENOTATTACHED, "DDERR_SURFACENOTATTACHED"},
- { DDERR_TOOBIGHEIGHT, "DDERR_TOOBIGHEIGHT"},
- { DDERR_TOOBIGSIZE, "DDERR_TOOBIGSIZE"},
- { DDERR_TOOBIGWIDTH, "DDERR_TOOBIGWIDTH"},
- { DDERR_UNSUPPORTED, "DDERR_UNSUPPORTED"},
- { DDERR_UNSUPPORTEDFORMAT, "DDERR_UNSUPPORTEDFORMAT"},
- { DDERR_UNSUPPORTEDMASK, "DDERR_UNSUPPORTEDMASK"},
- { DDERR_VERTICALBLANKINPROGRESS, "DDERR_VERTICALBLANKINPROGRESS"},
- { DDERR_WASSTILLDRAWING, "DDERR_WASSTILLDRAWING"},
- { DDERR_XALIGN, "DDERR_XALIGN"},
- { DDERR_INVALIDDIRECTDRAWGUID, "DDERR_INVALIDDIRECTDRAWGUID"},
- { DDERR_DIRECTDRAWALREADYCREATED, "DDERR_DIRECTDRAWALREADYCREATED"},
- { DDERR_NODIRECTDRAWHW, "DDERR_NODIRECTDRAWHW"},
- { DDERR_PRIMARYSURFACEALREADYEXISTS, "DDERR_PRIMARYSURFACEALREADYEXISTS"},
- { DDERR_NOEMULATION, "DDERR_NOEMULATION"},
- { DDERR_REGIONTOOSMALL, "DDERR_REGIONTOOSMALL"},
- { DDERR_CLIPPERISUSINGHWND, "DDERR_CLIPPERISUSINGHWND"},
- { DDERR_NOCLIPPERATTACHED, "DDERR_NOCLIPPERATTACHED"},
- { DDERR_NOHWND, "DDERR_NOHWND"},
- { DDERR_HWNDSUBCLASSED, "DDERR_HWNDSUBCLASSED"},
- { DDERR_HWNDALREADYSET, "DDERR_HWNDALREADYSET"},
- { DDERR_NOPALETTEATTACHED, "DDERR_NOPALETTEATTACHED"},
- { DDERR_NOPALETTEHW, "DDERR_NOPALETTEHW"},
- { DDERR_BLTFASTCANTCLIP, "DDERR_BLTFASTCANTCLIP"},
- { DDERR_NOBLTHW, "DDERR_NOBLTHW"},
- { DDERR_NODDROPSHW, "DDERR_NODDROPSHW"},
- { DDERR_OVERLAYNOTVISIBLE, "DDERR_OVERLAYNOTVISIBLE"},
- { DDERR_NOOVERLAYDEST, "DDERR_NOOVERLAYDEST"},
- { DDERR_INVALIDPOSITION, "DDERR_INVALIDPOSITION"},
- { DDERR_NOTAOVERLAYSURFACE, "DDERR_NOTAOVERLAYSURFACE"},
- { DDERR_EXCLUSIVEMODEALREADYSET, "DDERR_EXCLUSIVEMODEALREADYSET"},
- { DDERR_NOTFLIPPABLE, "DDERR_NOTFLIPPABLE"},
- { DDERR_CANTDUPLICATE, "DDERR_CANTDUPLICATE"},
- { DDERR_NOTLOCKED, "DDERR_NOTLOCKED"},
- { DDERR_CANTCREATEDC, "DDERR_CANTCREATEDC"},
- { DDERR_NODC, "DDERR_NODC"},
- { DDERR_WRONGMODE, "DDERR_WRONGMODE"},
- { DDERR_IMPLICITLYCREATED, "DDERR_IMPLICITLYCREATED"},
- { DDERR_NOTPALETTIZED, "DDERR_NOTPALETTIZED"},
- { DDERR_UNSUPPORTEDMODE, "DDERR_UNSUPPORTEDMODE"},
- { DDERR_NOMIPMAPHW, "DDERR_NOMIPMAPHW"},
- { DDERR_INVALIDSURFACETYPE, "DDERR_INVALIDSURFACETYPE"},
-
- { DDERR_NOOPTIMIZEHW, "DDERR_NOOPTIMIZEHW"},
- { DDERR_NOTLOADED, "DDERR_NOTLOADED"},
-
- { DDERR_DCALREADYCREATED, "DDERR_DCALREADYCREATED"},
-
- { DDERR_NONONLOCALVIDMEM, "DDERR_NONONLOCALVIDMEM"},
- { DDERR_CANTPAGELOCK, "DDERR_CANTPAGELOCK"},
- { DDERR_CANTPAGEUNLOCK, "DDERR_CANTPAGEUNLOCK"},
- { DDERR_NOTPAGELOCKED, "DDERR_NOTPAGELOCKED"},
-
- { DDERR_MOREDATA, "DDERR_MOREDATA"},
- { DDERR_VIDEONOTACTIVE, "DDERR_VIDEONOTACTIVE"},
- { DDERR_DEVICEDOESNTOWNSURFACE, "DDERR_DEVICEDOESNTOWNSURFACE"},
- { DDERR_NOTINITIALIZED, "DDERR_NOTINITIALIZED"},
-
- { DIERR_OLDDIRECTINPUTVERSION, "DIERR_OLDDIRECTINPUTVERSION" },
- { DIERR_BETADIRECTINPUTVERSION, "DIERR_BETADIRECTINPUTVERSION" },
- { DIERR_BADDRIVERVER, "DIERR_BADDRIVERVER" },
- { DIERR_DEVICENOTREG, "DIERR_DEVICENOTREG" },
- { DIERR_NOTFOUND, "DIERR_NOTFOUND" },
- { DIERR_OBJECTNOTFOUND, "DIERR_OBJECTNOTFOUND" },
- { DIERR_INVALIDPARAM, "DIERR_INVALIDPARAM" },
- { DIERR_NOINTERFACE, "DIERR_NOINTERFACE" },
- { DIERR_GENERIC, "DIERR_GENERIC" },
- { DIERR_OUTOFMEMORY, "DIERR_OUTOFMEMORY" },
- { DIERR_UNSUPPORTED, "DIERR_UNSUPPORTED" },
- { DIERR_NOTINITIALIZED, "DIERR_NOTINITIALIZED" },
- { DIERR_ALREADYINITIALIZED, "DIERR_ALREADYINITIALIZED" },
- { DIERR_NOAGGREGATION, "DIERR_NOAGGREGATION" },
- { DIERR_OTHERAPPHASPRIO, "DIERR_OTHERAPPHASPRIO" },
- { DIERR_INPUTLOST, "DIERR_INPUTLOST" },
- { DIERR_ACQUIRED, "DIERR_ACQUIRED" },
- { DIERR_NOTACQUIRED, "DIERR_NOTACQUIRED" },
- { DIERR_READONLY, "DIERR_READONLY" },
- { DIERR_HANDLEEXISTS, "DIERR_HANDLEEXISTS" },
- { E_PENDING, "E_PENDING" },
- { (HRESULT)DIERR_INSUFFICIENTPRIVS, "DIERR_INSUFFICIENTPRIVS" },
- { (HRESULT)DIERR_DEVICEFULL, "DIERR_DEVICEFULL" },
- { (HRESULT)DIERR_MOREDATA, "DIERR_MOREDATA" },
- { (HRESULT)DIERR_NOTDOWNLOADED, "DIERR_NOTDOWNLOADED" },
- { (HRESULT)DIERR_HASEFFECTS, "DIERR_HASEFFECTS" },
- { (HRESULT)DIERR_NOTEXCLUSIVEACQUIRED,"DIERR_NOTEXCLUSIVEACQUIRED" },
- { (HRESULT)DIERR_INCOMPLETEEFFECT, "DIERR_INCOMPLETEEFFECT" },
- { (HRESULT)DIERR_NOTBUFFERED, "DIERR_NOTBUFFERED" },
- { (HRESULT)DIERR_EFFECTPLAYING, "DIERR_EFFECTPLAYING" },
- //{ (HRESULT)DIERR_UNPLUGGED, "DIERR_UNPLUGGED" },
-
- { E_NOINTERFACE, "E_NOINTERFACE" }
-
-};
-
-/***************************************************************/
-
-/*
- DirectXDecodeError: Return a string description of the given DirectX
- error code.
-*/
-
-const char * DirectXDecodeError(HRESULT errorval)
-{
- int i;
- static char tmp[64];
-
- for (i = 0; i < (sizeof(g_ErrorCode) / sizeof(g_ErrorCode[0])); i++)
- {
- if (g_ErrorCode[i].hr == errorval)
- {
- return g_ErrorCode[i].szError;
- }
- }
- sprintf(tmp, "UNKNOWN: 0x%x", (unsigned int)errorval);
- return tmp;
-}
diff --git a/src/osd/winui/dxdecode.h b/src/osd/winui/dxdecode.h
deleted file mode 100644
index 0de32e83623..00000000000
--- a/src/osd/winui/dxdecode.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// For licensing and usage information, read docs/winui_license.txt
-//****************************************************************************
-
-/* dxdecode.h for client */
-
-/* Main header file for dxdecode.cpp */
-
-#ifndef DXDECODE_H
-#define DXDECODE_H
-
-extern const char* DirectXDecodeError(HRESULT errorval);
-
-#endif /* DXDECODE_H */
diff --git a/src/osd/winui/game_opts.h b/src/osd/winui/game_opts.h
index 632577a1a36..6a481785531 100644
--- a/src/osd/winui/game_opts.h
+++ b/src/osd/winui/game_opts.h
@@ -1,4 +1,5 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
#ifndef __GAME_OPTS_H__
@@ -146,7 +147,7 @@ public:
private:
core_options m_info;
- int m_total;
+ int m_total;
struct driver_options
{
diff --git a/src/osd/winui/layout.cpp b/src/osd/winui/layout.cpp
index a4ced439c48..1b12db10721 100644
--- a/src/osd/winui/layout.cpp
+++ b/src/osd/winui/layout.cpp
@@ -4,7 +4,7 @@
/***************************************************************************
- layout.c
+ layout.cpp
MAME specific TreeView definitions (and maybe more in the future)
@@ -24,7 +24,7 @@
#include "help.h"
#include "mui_audit.h"
#include "properties.h"
-//#define MESS
+
static BOOL FilterAvailable(int driver_index);
@@ -95,7 +95,7 @@ extern const FOLDERDATA g_folderData[] =
// {"CPU", "cpu", FOLDER_CPU, IDI_CPU, 0, 0, CreateCPUFolders },
// {"Sound", "sound", FOLDER_SND, IDI_SOUND, 0, 0, CreateSoundFolders },
// {"Dumping Status", "dumping", FOLDER_DUMPING, IDI_FOLDER, 0, 0, CreateDumpingFolders },
- {"BIOS", "bios", FOLDER_BIOS, IDI_FOLDER, 0, 0, CreateBIOSFolders, DriverIsBios, TRUE },
+// {"BIOS", "bios", FOLDER_BIOS, IDI_FOLDER, 0, 0, CreateBIOSFolders, DriverIsBios, TRUE },
{"CHD", "harddisk", FOLDER_HARDDISK, IDI_HARDDISK, 0, 0, NULL, DriverIsHarddisk, TRUE },
{"Samples", "samples", FOLDER_SAMPLES, IDI_FOLDER, 0, 0, NULL, DriverUsesSamples, TRUE },
{"Working", "working", FOLDER_WORKING, IDI_WORKING, F_WORKING, F_NONWORKING, NULL, DriverIsBroken, FALSE },
@@ -237,6 +237,7 @@ extern const ICONDATA g_iconData[] =
{ IDI_WIN_SNAP, "snapshot" },
{ IDI_WIN_PRIN, "printer" },
{ IDI_WIN_HARD, "hard" },
+ { IDI_WIN_MIDI, "midi" },
{ 0 }
};
#else
@@ -253,7 +254,7 @@ extern const ICONDATA g_iconData[] =
#ifdef MESS
extern const TCHAR g_szPlayGameString[] = TEXT("&Run %s");
-extern const char g_szGameCountString[] = "%d systems";
+extern const char g_szGameCountString[] = "%d machines";
#else
extern const TCHAR g_szPlayGameString[] = TEXT("&Play %s");
extern const char g_szGameCountString[] = "%d games";
diff --git a/src/osd/winui/mui_audit.cpp b/src/osd/winui/mui_audit.cpp
index fe0a1fd0ac0..ccadf04e489 100644
--- a/src/osd/winui/mui_audit.cpp
+++ b/src/osd/winui/mui_audit.cpp
@@ -13,16 +13,13 @@
// standard windows headers
#include <windows.h>
#include <windowsx.h>
-#include <commctrl.h>
// standard C headers
-#include <stdio.h>
#include <tchar.h>
// MAME/MAMEUI headers
#include "winui.h"
#include "winutf8.h"
-#include "strconv.h"
#include "audit.h"
#include "resource.h"
#include "mui_opts.h"
@@ -50,7 +47,7 @@ static const char * StatusString(int iStatus);
Internal variables
***************************************************************************/
-#define MAX_AUDITBOX_TEXT 0x7FFFFFFE
+#define MAX_AUDITBOX_TEXT 0x7FFFFFFE
static volatile HWND hAudit;
static volatile int rom_index = 0;
@@ -78,7 +75,6 @@ static int strcatprintf(std::string &str, const char *format, ...)
void AuditDialog(HWND hParent, int choice)
{
- HMODULE hModule = NULL;
rom_index = 0;
roms_correct = -1; // ___empty must not be counted
roms_incorrect = 0;
@@ -88,7 +84,7 @@ void AuditDialog(HWND hParent, int choice)
m_choice = choice;
//RS use Riched32.dll
- hModule = LoadLibrary(TEXT("Riched32.dll"));
+ HMODULE hModule = LoadLibrary(TEXT("Riched32.dll"));
if( hModule )
{
DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_AUDIT),hParent,AuditWindowProc);
@@ -96,9 +92,7 @@ void AuditDialog(HWND hParent, int choice)
hModule = NULL;
}
else
- {
MessageBox(GetMainWindow(),TEXT("Unable to Load Riched32.dll"),TEXT("Error"), MB_OK | MB_ICONERROR);
- }
}
void InitGameAudit(int gameIndex)
@@ -218,16 +212,14 @@ static DWORD WINAPI AuditThreadProc(LPVOID hDlg)
{
if (rom_index != -1)
{
- sprintf(buffer, "Checking Set %s - %s",
- driver_list::driver(rom_index).name, driver_list::driver(rom_index).type.fullname());
+ sprintf(buffer, "Checking Set %s - %s", driver_list::driver(rom_index).name, driver_list::driver(rom_index).type.fullname());
win_set_window_text_utf8((HWND)hDlg, buffer);
ProcessNextRom();
}
else
if (sample_index != -1)
{
- sprintf(buffer, "Checking Set %s - %s",
- driver_list::driver(sample_index).name, driver_list::driver(sample_index).type.fullname());
+ sprintf(buffer, "Checking Set %s - %s", driver_list::driver(sample_index).name, driver_list::driver(sample_index).type.fullname());
win_set_window_text_utf8((HWND)hDlg, buffer);
ProcessNextSample();
}
@@ -246,7 +238,6 @@ static INT_PTR CALLBACK AuditWindowProc(HWND hDlg, UINT Msg, WPARAM wParam, LPAR
{
static HANDLE hThread;
static DWORD dwThreadID = 0;
- DWORD dwExitCode = 0;
HWND hEdit;
switch (Msg)
@@ -255,17 +246,17 @@ static INT_PTR CALLBACK AuditWindowProc(HWND hDlg, UINT Msg, WPARAM wParam, LPAR
hAudit = hDlg;
//RS 20030613 Set Bkg of RichEdit Ctrl
hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS);
- if (hEdit != NULL)
+ if (hEdit)
{
SendMessage( hEdit, EM_SETBKGNDCOLOR, FALSE, GetSysColor(COLOR_BTNFACE) );
// MSH - Set to max
SendMessage( hEdit, EM_SETLIMITTEXT, MAX_AUDITBOX_TEXT, 0 );
-
}
+
SendDlgItemMessage(hDlg, IDC_ROMS_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0, driver_list::total()));
SendDlgItemMessage(hDlg, IDC_SAMPLES_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0, driver_list::total()));
- bPaused = FALSE;
- bCancel = FALSE;
+ bPaused = false;
+ bCancel = false;
rom_index = 0;
hThread = CreateThread(NULL, 0, AuditThreadProc, hDlg, 0, &dwThreadID);
return 1;
@@ -273,10 +264,11 @@ static INT_PTR CALLBACK AuditWindowProc(HWND hDlg, UINT Msg, WPARAM wParam, LPAR
switch (LOWORD(wParam))
{
case IDCANCEL:
- bPaused = FALSE;
+ bPaused = false;
if (hThread)
{
- bCancel = TRUE;
+ bCancel = true;
+ DWORD dwExitCode = 0;
if (GetExitCodeThread(hThread, &dwExitCode) && (dwExitCode == STILL_ACTIVE))
{
PostMessage(hDlg, WM_COMMAND, wParam, lParam);
@@ -292,12 +284,12 @@ static INT_PTR CALLBACK AuditWindowProc(HWND hDlg, UINT Msg, WPARAM wParam, LPAR
if (bPaused)
{
SendDlgItemMessage(hAudit, IDPAUSE, WM_SETTEXT, 0, (LPARAM)TEXT("Pause"));
- bPaused = FALSE;
+ bPaused = false;
}
else
{
SendDlgItemMessage(hAudit, IDPAUSE, WM_SETTEXT, 0, (LPARAM)TEXT("Continue"));
- bPaused = TRUE;
+ bPaused = true;
}
break;
}
@@ -429,15 +421,9 @@ static void ProcessNextSample()
static void CLIB_DECL DetailsPrintf(const char *fmt, ...)
{
- HWND hEdit;
- va_list marker;
- char buffer[8000];
- TCHAR* t_s;
- int textLength = 0;
-
//RS 20030613 Different Ids for Property Page and Dialog
// so see which one's currently instantiated
- hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS);
+ HWND hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS);
if (hEdit == NULL)
hEdit = GetDlgItem(hAudit, IDC_AUDIT_DETAILS_PROP);
@@ -447,28 +433,26 @@ static void CLIB_DECL DetailsPrintf(const char *fmt, ...)
return;
}
+ va_list marker;
va_start(marker, fmt);
-
+ char buffer[8000];
vsprintf(buffer, fmt, marker);
-
va_end(marker);
- t_s = ui_wstring_from_utf8(ConvertToWindowsNewlines(buffer));
+ TCHAR* t_s = ui_wstring_from_utf8(ConvertToWindowsNewlines(buffer));
if( !t_s || _tcscmp(TEXT(""), t_s) == 0)
return;
- textLength = Edit_GetTextLength(hEdit);
+ int textLength = Edit_GetTextLength(hEdit);
Edit_SetSel(hEdit, textLength, textLength);
- SendMessage( hEdit, EM_REPLACESEL, FALSE, (WPARAM)(LPCTSTR)win_tstring_strdup(t_s) );
+ SendMessage( hEdit, EM_REPLACESEL, false, (WPARAM)(LPCTSTR)win_tstring_strdup(t_s) );
free(t_s);
}
static const char * StatusString(int iStatus)
{
- static const char *ptr;
-
- ptr = "Unknown";
+ static const char *ptr = "Unknown";
switch (iStatus)
{
diff --git a/src/osd/winui/mui_opts.cpp b/src/osd/winui/mui_opts.cpp
index d55074a0360..19becf80135 100644
--- a/src/osd/winui/mui_opts.cpp
+++ b/src/osd/winui/mui_opts.cpp
@@ -202,7 +202,7 @@ static void ResetToDefaults(windows_options &opts, int priority);
#define MESSUI_SW_SORT_REVERSED "sw_sort_reversed"
#define MESSUI_SW_SORT_COLUMN "sw_sort_column"
#define MESSUI_SOFTWARE_TAB "current_software_tab"
-#define MESSUI_SLPATH "slpath"
+//#define MESSUI_SLPATH "slpath"
/***************************************************************************
@@ -286,7 +286,7 @@ const options_entry winui_options::s_option_entries[] =
{ MUIOPTION_BACKGROUND_DIRECTORY, "bkground", OPTION_STRING, NULL },
{ MUIOPTION_ICONS_DIRECTORY, "icons", OPTION_STRING, NULL },
{ MUIOPTION_DATS_DIRECTORY, "dats", OPTION_STRING, NULL },
- { MESSUI_SLPATH, "software", OPTION_STRING, NULL },
+// { MESSUI_SLPATH, "software", OPTION_STRING, NULL },
{ NULL, NULL, OPTION_HEADER, "NAVIGATION KEY CODES" },
{ MUIOPTION_UI_KEY_UP, "KEYCODE_UP", OPTION_STRING, NULL },
{ MUIOPTION_UI_KEY_DOWN, "KEYCODE_DOWN", OPTION_STRING, NULL },
@@ -2311,7 +2311,7 @@ void LoadFolderFlags(void)
ptr = folder_name;
while (*ptr && *ptr != '\0')
{
- if (*ptr == ' ')
+ if ((*ptr == ' ') || (*ptr == '-'))
{
*ptr = '_';
}
@@ -2345,7 +2345,7 @@ void LoadFolderFlags(void)
ptr = folder_name;
while (*ptr && *ptr != '\0')
{
- if (*ptr == ' ')
+ if ((*ptr == ' ') || (*ptr == '-'))
{
*ptr = '_';
}
@@ -2393,7 +2393,7 @@ static void AddFolderFlags(winui_options &opts)
ptr = folder_name;
while (*ptr && *ptr != '\0')
{
- if (*ptr == ' ')
+ if ((*ptr == ' ') || (*ptr == '-'))
{
*ptr = '_';
}
@@ -2450,7 +2450,6 @@ void load_options(windows_options &opts, OPTIONS_TYPE opt_type, int game_num)
const game_driver *driver = NULL;
if (game_num > -1)
driver = &driver_list::driver(game_num);
- CreateGameOptions(opts, opt_type, game_num);
// Try base ini first
std::string fname = std::string(emulator_info::get_configname()).append(".ini");
@@ -2692,6 +2691,8 @@ void SetSelectedSoftware(int driver_index, const device_image_interface *dev, co
dprintf("SetSelectedSoftware(): dev=%p (\'%s\') software='%s'\n", dev, driver_list::driver(driver_index).name, software);
}
+ const char* name = driver_list::driver(driver_index).name;
+ o.set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE);
load_options(o, OPTIONS_GAME, driver_index);
o.set_value(opt_name.c_str(), software, OPTION_PRIORITY_CMDLINE);
//o.image_option(opt_name).specify(software);
@@ -2708,15 +2709,15 @@ const char *GetCurrentSoftwareTab(void)
return MameUISettings().value(MESSUI_SOFTWARE_TAB);
}
-const char* GetSLDir(void)
-{
- return MameUISettings().value(MESSUI_SLPATH);
-}
+//const char* GetSLDir(void)
+//{
+// return MameUISettings().value(MESSUI_SLPATH);
+//}
-void SetSLDir(const char* paths)
-{
- MameUISettings().set_value(MESSUI_SLPATH, paths, OPTION_PRIORITY_CMDLINE);
-}
+//void SetSLDir(const char* paths)
+//{
+// MameUISettings().set_value(MESSUI_SLPATH, paths, OPTION_PRIORITY_CMDLINE);
+//}
bool AreOptionsEqual(windows_options &opts1, windows_options &opts2)
{
diff --git a/src/osd/winui/mui_opts.h b/src/osd/winui/mui_opts.h
index 268d1c6255e..069c16cc771 100644
--- a/src/osd/winui/mui_opts.h
+++ b/src/osd/winui/mui_opts.h
@@ -45,12 +45,8 @@ enum
COLUMN_PLAYTIME,
COLUMN_CLONE,
COLUMN_TRACKBALL,
-#ifdef SHOW_COLUMN_SAMPLES
COLUMN_SAMPLES,
-#endif
-#ifdef SHOW_COLUMN_ROMS
COLUMN_ROMS,
-#endif
COLUMN_MAX
};
@@ -64,17 +60,17 @@ typedef struct
typedef struct
{
- char* screen;
- char* aspect;
- char* resolution;
- char* view;
+ char *screen;
+ char *aspect;
+ char *resolution;
+ char *view;
} ScreenParams;
// List of artwork types to display in the screen shot area
enum
{
- // these must match array of strings image_tabs_long_name in options.c
- // if you add new Tabs, be sure to also add them to the ComboBox init in dialogs.c
+ // these must match array of strings image_tabs_long_name in mui_opts.cpp
+ // if you add new Tabs, be sure to also add them to the ComboBox init in dialogs.cpp
TAB_SCREENSHOT = 0,
TAB_FLYER,
TAB_CABINET,
@@ -117,94 +113,92 @@ void save_options(windows_options &opts, OPTIONS_TYPE opt_type, int game_num);
void CreateGameOptions(windows_options &opts, OPTIONS_TYPE opt_type, int driver_index);
-winui_options & MameUISettings(void);
-windows_options & MameUIGlobal(void);
+winui_options &MameUISettings(void);
+windows_options &MameUIGlobal(void);
void LoadFolderFlags(void);
// Start interface to directories.h
-const char* GetRomDirs(void);
-void SetRomDirs(const char* paths);
+const char *GetRomDirs(void);
+void SetRomDirs(const char *paths);
-const char* GetSampleDirs(void);
-void SetSampleDirs(const char* paths);
+const char *GetSampleDirs(void);
+void SetSampleDirs(const char *paths);
-const char* GetArtDir(void);
-void SetArtDir(const char* path);
+const char *GetArtDir(void);
+void SetArtDir(const char *path);
-const char* GetCabinetDir(void);
-void SetCabinetDir(const char* path);
+const char *GetCabinetDir(void);
+void SetCabinetDir(const char *path);
-const char* GetCheatDir(void);
-void SetCheatDir(const char* path);
+const char *GetCheatDir(void);
+void SetCheatDir(const char *path);
-const char* GetCfgDir(void);
-void SetCfgDir(const char* path);
+const char *GetCfgDir(void);
+void SetCfgDir(const char *path);
-const char* GetControlPanelDir(void);
-void SetControlPanelDir(const char* path);
+const char *GetControlPanelDir(void);
+void SetControlPanelDir(const char *path);
-const char* GetCtrlrDir(void);
-void SetCtrlrDir(const char* path);
+const char *GetCtrlrDir(void);
+void SetCtrlrDir(const char *path);
-const char* GetCrosshairDir(void);
-void SetCrosshairDir(const char* paths);
+const char *GetCrosshairDir(void);
+void SetCrosshairDir(const char *paths);
-const char* GetDatsDir(void);
+const char *GetDatsDir(void);
void SetDatsDir(const char *path);
-const char* GetFlyerDir(void);
-void SetFlyerDir(const char* path);
+const char *GetFlyerDir(void);
+void SetFlyerDir(const char *path);
-const char* GetFolderDir(void);
-void SetFolderDir(const char* path);
+const char *GetFolderDir(void);
+void SetFolderDir(const char *path);
-const char* GetFontDir(void);
-void SetFontDir(const char* paths);
+const char *GetFontDir(void);
+void SetFontDir(const char *paths);
-const char* GetHashDirs(void);
-void SetHashDirs(const char* paths);
+const char *GetHashDirs(void);
+void SetHashDirs(const char *paths);
-const char* GetDiffDir(void);
-void SetDiffDir(const char* path);
+const char *GetDiffDir(void);
+void SetDiffDir(const char *path);
-const char* GetIconsDir(void);
-void SetIconsDir(const char* path);
+const char *GetIconsDir(void);
+void SetIconsDir(const char *path);
-const char* GetIniDir(void);
+const char *GetIniDir(void);
void SetIniDir(const char *path);
-const char* GetInpDir(void);
-void SetInpDir(const char* path);
+const char *GetInpDir(void);
+void SetInpDir(const char *path);
-const char* GetLangDir(void);
-void SetLangDir(const char* path);
+const char *GetLangDir(void);
+void SetLangDir(const char *path);
-const char* GetMarqueeDir(void);
-void SetMarqueeDir(const char* path);
+const char *GetMarqueeDir(void);
+void SetMarqueeDir(const char *path);
-const char* GetNvramDir(void);
-void SetNvramDir(const char* path);
+const char *GetNvramDir(void);
+void SetNvramDir(const char *path);
-const char* GetPcbDir(void);
-void SetPcbDir(const char* path);
+const char *GetPcbDir(void);
+void SetPcbDir(const char *path);
-const char* GetPluginsDir(void);
-void SetPluginsDir(const char* path);
+const char *GetPluginsDir(void);
+void SetPluginsDir(const char *path);
-const char* GetImgDir(void);
-void SetImgDir(const char* path);
+const char *GetImgDir(void);
+void SetImgDir(const char *path);
-const char* GetStateDir(void);
-void SetStateDir(const char* path);
+const char *GetStateDir(void);
+void SetStateDir(const char *path);
-const char* GetTitlesDir(void);
-void SetTitlesDir(const char* path);
+const char *GetTitlesDir(void);
+void SetTitlesDir(const char *path);
-const char* GetSLDir(void);
-void SetSLDir(const char* path);
-const char* GetSWDir(void);
-void SetSWDir(const char* path);
+const char *GetSWDir(void);
+void SetSWDir(const char *path);
// End interface to directories.h
void SaveOptions(void);
@@ -326,17 +320,17 @@ int GetSortColumn(void);
void SetSortReverse(BOOL reverse);
BOOL GetSortReverse(void);
-const char* GetLanguageUI(void);
+const char *GetLanguageUI(void);
bool GetEnablePlugins(void);
-const char* GetPlugins(void);
+const char *GetPlugins(void);
-const char* GetSnapName(void);
-void SetSnapName(const char* pattern);
+const char *GetSnapName(void);
+void SetSnapName(const char *pattern);
-const char* GetBgDir(void);
-void SetBgDir(const char* path);
+const char *GetBgDir(void);
+void SetBgDir(const char *path);
void ResetGameOptions(int driver_index);
@@ -441,8 +435,8 @@ void SetUIJoyHistoryDown(int joycodeIndex, int val);
int GetUIJoyExec(int joycodeIndex);
void SetUIJoyExec(int joycodeIndex, int val);
-const char* GetExecCommand(void);
-void SetExecCommand(char* cmd);
+const char *GetExecCommand(void);
+void SetExecCommand(char *cmd);
int GetExecWait(void);
void SetExecWait(int wait);
@@ -454,7 +448,7 @@ BOOL GetRunFullScreen(void);
void SetRunFullScreen(BOOL fullScreen);
void ColumnEncodeStringWithCount(const int *value, char *str, int count);
-void ColumnDecodeStringWithCount(const char* str, int *value, int count);
+void ColumnDecodeStringWithCount(const char *str, int *value, int count);
int GetDriverCache(int driver_index);
void SetDriverCache(int driver_index, int val);
diff --git a/src/osd/winui/mui_util.cpp b/src/osd/winui/mui_util.cpp
index aae41652ef2..685217ae420 100644
--- a/src/osd/winui/mui_util.cpp
+++ b/src/osd/winui/mui_util.cpp
@@ -13,7 +13,6 @@
#include <shellapi.h>
// standard C headers
-#include <stdio.h>
#include <tchar.h>
// MAME/MAMEUI headers
@@ -23,7 +22,6 @@
#include "unzip.h"
#include "sound/samples.h"
#include "winutf8.h"
-#include "strconv.h"
#include "winui.h"
#include "mui_util.h"
#include "mui_opts.h"
@@ -31,7 +29,6 @@
#include "machine/ram.h"
#include <shlwapi.h>
-#include <vector>
/***************************************************************************
function prototypes
@@ -91,11 +88,11 @@ enum
*/
void __cdecl ErrorMsg(const char* fmt, ...)
{
- static FILE* pFile = NULL;
- DWORD dwWritten;
- char buf[5000];
- char buf2[5000];
- va_list va;
+ static FILE* pFile = NULL;
+ DWORD dwWritten;
+ char buf[5000];
+ char buf2[5000];
+ va_list va;
va_start(va, fmt);
@@ -123,7 +120,7 @@ void __cdecl ErrorMsg(const char* fmt, ...)
void __cdecl dprintf(const char* fmt, ...)
{
- char buf[5000];
+ char buf[5000];
va_list va;
va_start(va, fmt);
@@ -137,8 +134,8 @@ void __cdecl dprintf(const char* fmt, ...)
UINT GetDepth(HWND hWnd)
{
- UINT nBPP;
- HDC hDC;
+ UINT nBPP;
+ HDC hDC;
hDC = GetDC(hWnd);
@@ -206,21 +203,18 @@ LONG GetCommonControlVersion()
void DisplayTextFile(HWND hWnd, const char *cName)
{
- HINSTANCE hErr;
- LPCTSTR msg = 0;
- LPTSTR tName;
-
- tName = ui_wstring_from_utf8(cName);
+ LPTSTR tName = ui_wstring_from_utf8(cName);
if( !tName )
return;
- hErr = ShellExecute(hWnd, NULL, tName, NULL, NULL, SW_SHOWNORMAL);
+ HINSTANCE hErr = ShellExecute(hWnd, NULL, tName, NULL, NULL, SW_SHOWNORMAL);
if ((uintptr_t)hErr > 32)
{
free(tName);
return;
}
+ LPCTSTR msg = 0;
switch((uintptr_t)hErr)
{
case 0:
@@ -337,26 +331,36 @@ int numberOfSpeakers(const machine_config *config)
static void SetDriversInfo(void)
{
- int ndriver;
int cache = -1;
int total = driver_list::total();
struct DriversInfo *gameinfo = NULL;
- for (ndriver = 0; ndriver < total; ndriver++)
+ for (int ndriver = 0; ndriver < total; ndriver++)
{
gameinfo = &drivers_info[ndriver];
- cache = (gameinfo->screenCount & DRIVER_CACHE_SCREEN);
- if (gameinfo->isClone) cache += DRIVER_CACHE_CLONE;
- if (gameinfo->isHarddisk) cache += DRIVER_CACHE_HARDDISK;
- if (gameinfo->hasOptionalBIOS) cache += DRIVER_CACHE_BIOS;
- if (gameinfo->isStereo) cache += DRIVER_CACHE_STEREO;
- if (gameinfo->isVector) cache += DRIVER_CACHE_VECTOR;
- if (gameinfo->usesRoms) cache += DRIVER_CACHE_ROMS;
- if (gameinfo->usesSamples) cache += DRIVER_CACHE_SAMPLES;
- if (gameinfo->usesTrackball) cache += DRIVER_CACHE_TRACKBALL;
- if (gameinfo->usesLightGun) cache += DRIVER_CACHE_LIGHTGUN;
- if (gameinfo->usesMouse) cache += DRIVER_CACHE_MOUSE;
- if (gameinfo->hasRam) cache += DRIVER_CACHE_RAM;
+ cache = (gameinfo->screenCount & DRIVER_CACHE_SCREEN);
+ if (gameinfo->isClone)
+ cache += DRIVER_CACHE_CLONE;
+ if (gameinfo->isHarddisk)
+ cache += DRIVER_CACHE_HARDDISK;
+ if (gameinfo->hasOptionalBIOS)
+ cache += DRIVER_CACHE_BIOS;
+ if (gameinfo->isStereo)
+ cache += DRIVER_CACHE_STEREO;
+ if (gameinfo->isVector)
+ cache += DRIVER_CACHE_VECTOR;
+ if (gameinfo->usesRoms)
+ cache += DRIVER_CACHE_ROMS;
+ if (gameinfo->usesSamples)
+ cache += DRIVER_CACHE_SAMPLES;
+ if (gameinfo->usesTrackball)
+ cache += DRIVER_CACHE_TRACKBALL;
+ if (gameinfo->usesLightGun)
+ cache += DRIVER_CACHE_LIGHTGUN;
+ if (gameinfo->usesMouse)
+ cache += DRIVER_CACHE_MOUSE;
+ if (gameinfo->hasRam)
+ cache += DRIVER_CACHE_RAM;
SetDriverCache(ndriver, cache);
}
@@ -364,14 +368,13 @@ static void SetDriversInfo(void)
static void InitDriversInfo(void)
{
- int ndriver;
int num_speakers;
int total = driver_list::total();
const game_driver *gamedrv = NULL;
struct DriversInfo *gameinfo = NULL;
const rom_entry *region, *rom;
- for (ndriver = 0; ndriver < total; ndriver++)
+ for (int ndriver = 0; ndriver < total; ndriver++)
{
gamedrv = &driver_list::driver(ndriver);
gameinfo = &drivers_info[ndriver];
@@ -389,15 +392,15 @@ static void InitDriversInfo(void)
for (device_t &device : device_iterator(config.root_device()))
for (region = rom_first_region(device); region; region = rom_next_region(region))
if (ROMREGION_ISDISKDATA(region))
- gameinfo->isHarddisk = TRUE;
+ gameinfo->isHarddisk = true;
- gameinfo->hasOptionalBIOS = FALSE;
+ gameinfo->hasOptionalBIOS = false;
if (gamedrv->rom)
{
auto rom_entries = rom_build_entries(gamedrv->rom);
for (rom = rom_entries.data(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISSYSTEM_BIOS(rom))
- gameinfo->hasOptionalBIOS = TRUE;
+ gameinfo->hasOptionalBIOS = true;
}
num_speakers = numberOfSpeakers(&config);
@@ -405,20 +408,20 @@ static void InitDriversInfo(void)
gameinfo->isStereo = (num_speakers > 1);
gameinfo->screenCount = numberOfScreens(&config);
gameinfo->isVector = isDriverVector(&config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0);
- gameinfo->usesRoms = FALSE;
+ gameinfo->usesRoms = false;
for (device_t &device : device_iterator(config.root_device()))
for (region = rom_first_region(device); region; region = rom_next_region(region))
for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
- gameinfo->usesRoms = TRUE;
+ gameinfo->usesRoms = true;
- gameinfo->usesSamples = FALSE;
+ gameinfo->usesSamples = false;
samples_device_iterator iter(config.root_device());
if (iter.first())
- gameinfo->usesSamples = TRUE;
+ gameinfo->usesSamples = true;
- gameinfo->usesTrackball = FALSE;
- gameinfo->usesLightGun = FALSE;
+ gameinfo->usesTrackball = false;
+ gameinfo->usesLightGun = false;
if (gamedrv->ipt)
{
ioport_list portlist;
@@ -435,14 +438,12 @@ static void InitDriversInfo(void)
type = field.type();
if (type == IPT_END)
break;
- if (type == IPT_DIAL || type == IPT_PADDLE ||
- type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y ||
- type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y)
- gameinfo->usesTrackball = TRUE;
+ if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y)
+ gameinfo->usesTrackball = true;
if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y)
- gameinfo->usesLightGun = TRUE;
+ gameinfo->usesLightGun = true;
if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y)
- gameinfo->usesMouse = TRUE;
+ gameinfo->usesMouse = true;
}
}
}
@@ -453,19 +454,18 @@ static void InitDriversInfo(void)
static int InitDriversCache(void)
{
- int cache = -1;
- int total = driver_list::total();
- const game_driver *gamedrv = NULL;
- struct DriversInfo *gameinfo = NULL;
- int ndriver;
-
if (RequiredDriverCache())
{
InitDriversInfo();
return 0;
}
- for (ndriver = 0; ndriver < total; ndriver++)
+ int cache = -1;
+ int total = driver_list::total();
+ const game_driver *gamedrv = NULL;
+ struct DriversInfo *gameinfo = NULL;
+
+ for (int ndriver = 0; ndriver < total; ndriver++)
{
gamedrv = &driver_list::driver(ndriver);
gameinfo = &drivers_info[ndriver];
@@ -620,11 +620,10 @@ BOOL StringIsSuffixedBy(const char *s, const char *suffix)
BOOL SafeIsAppThemed(void)
{
- BOOL bResult = FALSE;
- HMODULE hThemes;
+ BOOL bResult = false;
BOOL (WINAPI *pfnIsAppThemed)(void);
- hThemes = LoadLibrary(TEXT("uxtheme.dll"));
+ HMODULE hThemes = LoadLibrary(TEXT("uxtheme.dll"));
if (hThemes)
{
pfnIsAppThemed = (BOOL (WINAPI *)(void)) GetProcAddress(hThemes, "IsAppThemed");
@@ -687,9 +686,8 @@ TCHAR* win_tstring_strdup(LPCTSTR str)
// win_create_file_utf8
//============================================================
-HANDLE win_create_file_utf8(const char* filename, DWORD desiredmode, DWORD sharemode,
- LPSECURITY_ATTRIBUTES securityattributes, DWORD creationdisposition,
- DWORD flagsandattributes, HANDLE templatehandle)
+HANDLE win_create_file_utf8(const char* filename, DWORD desiredmode, DWORD sharemode, LPSECURITY_ATTRIBUTES securityattributes,
+ DWORD creationdisposition, DWORD flagsandattributes, HANDLE templatehandle)
{
HANDLE result = 0;
TCHAR* t_filename = ui_wstring_from_utf8(filename);
@@ -711,7 +709,6 @@ DWORD win_get_current_directory_utf8(DWORD bufferlength, char* buffer)
{
DWORD result = 0;
TCHAR* t_buffer = NULL;
- char* utf8_buffer = NULL;
if( bufferlength > 0 ) {
t_buffer = (TCHAR*)malloc((bufferlength * sizeof(TCHAR)) + 1);
@@ -721,6 +718,7 @@ DWORD win_get_current_directory_utf8(DWORD bufferlength, char* buffer)
result = GetCurrentDirectory(bufferlength, t_buffer);
+ char* utf8_buffer = NULL;
if( bufferlength > 0 ) {
utf8_buffer = ui_utf8_from_wstring(t_buffer);
if( !utf8_buffer ) {
diff --git a/src/osd/winui/newui.cpp b/src/osd/winui/newui.cpp
deleted file mode 100644
index 5ee6d76e5dd..00000000000
--- a/src/osd/winui/newui.cpp
+++ /dev/null
@@ -1,3364 +0,0 @@
-// For licensing and usage information, read docs/winui_license.txt
-//************************************************************************************************
-// MASTER
-//
-// newui.c - This is the NEWUI Windows dropdown menu system
-//
-// known bugs:
-// - Unable to modify keyboard or joystick. Last known to be working in 0.158 .
-// Need to use the default UI.
-//
-//
-//************************************************************************************************
-
-// Set minimum windows version to XP
-#ifdef _WIN32_WINNT
-#undef _WIN32_WINNT
-#endif
-#define _WIN32_WINNT 0x501
-
-
-// standard windows headers
-#include "newui.h"
-
-#include <shellapi.h>
-
-
-enum _win_file_dialog_type
-{
- WIN_FILE_DIALOG_OPEN = 1,
- WIN_FILE_DIALOG_SAVE
-};
-typedef enum _win_file_dialog_type win_file_dialog_type;
-
-typedef struct _win_open_file_name win_open_file_name;
-struct _win_open_file_name
-{
- win_file_dialog_type type; // type of file dialog
- HWND owner; // owner of the dialog
- HINSTANCE instance; // instance
- const char * filter; // pipe char ("|") delimited strings
- DWORD filter_index; // index into filter
- char filename[MAX_PATH]; // filename buffer
- const char * initial_directory; // initial directory for dialog
- DWORD flags; // standard flags
- LPARAM custom_data; // custom data for dialog hook
- LPOFNHOOKPROC hook; // custom dialog hook
- LPCTSTR template_name; // custom dialog template
-};
-
-
-typedef struct _dialog_box dialog_box;
-
-struct dialog_layout
-{
- short label_width;
- short combo_width;
-};
-
-typedef void (*dialog_itemstoreval)(void *param, int val);
-typedef void (*dialog_itemchangedproc)(dialog_box *dialog, HWND dlgitem, void *changed_param);
-typedef void (*dialog_notification)(dialog_box *dialog, HWND dlgwnd, NMHDR *notification, void *param);
-
-#ifdef UNICODE
-#define win_dialog_tcsdup win_dialog_wcsdup
-#else
-#define win_dialog_tcsdup win_dialog_strdup
-#endif
-
-#define SEQWM_SETFOCUS (WM_APP + 0)
-#define SEQWM_KILLFOCUS (WM_APP + 1)
-
-enum
-{
- TRIGGER_INITDIALOG = 1,
- TRIGGER_APPLY = 2,
- TRIGGER_CHANGED = 4
-};
-
-typedef LRESULT (*trigger_function)(dialog_box *dialog, HWND dlgwnd, UINT message, WPARAM wparam, LPARAM lparam);
-
-struct dialog_info_trigger
-{
- struct dialog_info_trigger *next;
- WORD dialog_item;
- WORD trigger_flags;
- UINT message;
- WPARAM wparam;
- LPARAM lparam;
- void (*storeval)(void *param, int val);
- void *storeval_param;
- trigger_function trigger_proc;
-};
-
-struct dialog_object_pool
-{
- HGDIOBJ objects[16];
-};
-
-struct _dialog_box
-{
- HGLOBAL handle;
- size_t handle_size;
- struct dialog_info_trigger *trigger_first;
- struct dialog_info_trigger *trigger_last;
- WORD item_count;
- WORD size_x, size_y;
- WORD pos_x, pos_y;
- WORD cursize_x, cursize_y;
- WORD home_y;
- DWORD style;
- int combo_string_count;
- int combo_default_value;
- //object_pool *mempool;
- struct dialog_object_pool *objpool;
- const struct dialog_layout *layout;
-
- // singular notification callback; hack
- UINT notify_code;
- dialog_notification notify_callback;
- void *notify_param;
-};
-
-enum _seqselect_state
-{
- SEQSELECT_STATE_NOT_POLLING,
- SEQSELECT_STATE_POLLING,
- SEQSELECT_STATE_POLLING_COMPLETE
-};
-typedef enum _seqselect_state seqselect_state;
-
-// this is the structure that gets associated with each input_seq edit box
-typedef struct _seqselect_info seqselect_info;
-struct _seqselect_info
-{
- WNDPROC oldwndproc;
- ioport_field *field; // pointer to the field
- ioport_field::user_settings settings; // the new settings
- input_seq *code; // the input_seq within settings
- WORD pos;
- BOOL is_analog;
- seqselect_state poll_state;
-};
-
-
-
-//============================================================
-// PARAMETERS
-//============================================================
-
-#define DIM_VERTICAL_SPACING 3
-#define DIM_HORIZONTAL_SPACING 5
-#define DIM_NORMAL_ROW_HEIGHT 10
-#define DIM_COMBO_ROW_HEIGHT 12
-#define DIM_SLIDER_ROW_HEIGHT 18
-#define DIM_BUTTON_ROW_HEIGHT 12
-#define DIM_EDIT_WIDTH 120
-#define DIM_BUTTON_WIDTH 50
-#define DIM_ADJUSTER_SCR_WIDTH 12
-#define DIM_ADJUSTER_HEIGHT 12
-#define DIM_SCROLLBAR_WIDTH 10
-#define DIM_BOX_VERTSKEW -3
-
-#define DLGITEM_BUTTON ((const WCHAR *) dlgitem_button)
-#define DLGITEM_EDIT ((const WCHAR *) dlgitem_edit)
-#define DLGITEM_STATIC ((const WCHAR *) dlgitem_static)
-#define DLGITEM_LISTBOX ((const WCHAR *) dlgitem_listbox)
-#define DLGITEM_SCROLLBAR ((const WCHAR *) dlgitem_scrollbar)
-#define DLGITEM_COMBOBOX ((const WCHAR *) dlgitem_combobox)
-
-#define DLGTEXT_OK "OK"
-#define DLGTEXT_APPLY "Apply"
-#define DLGTEXT_CANCEL "Cancel"
-
-#define FONT_SIZE 8
-#define FONT_FACE L"Arial"
-
-#define SCROLL_DELTA_LINE 10
-#define SCROLL_DELTA_PAGE 100
-
-#define LOG_WINMSGS 0
-#define DIALOG_STYLE WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | DS_SETFONT
-#define MAX_DIALOG_HEIGHT 200
-
-
-
-//============================================================
-// LOCAL VARIABLES
-//============================================================
-
-static running_machine *Machine; // HACK - please fix
-
-static double pixels_to_xdlgunits;
-static double pixels_to_ydlgunits;
-
-static const struct dialog_layout default_layout = { 80, 140 };
-static const WORD dlgitem_button[] = { 0xFFFF, 0x0080 };
-static const WORD dlgitem_edit[] = { 0xFFFF, 0x0081 };
-static const WORD dlgitem_static[] = { 0xFFFF, 0x0082 };
-static const WORD dlgitem_listbox[] = { 0xFFFF, 0x0083 };
-static const WORD dlgitem_scrollbar[] = { 0xFFFF, 0x0084 };
-static const WORD dlgitem_combobox[] = { 0xFFFF, 0x0085 };
-static int joystick_menu_setup = 0;
-static char state_filename[MAX_PATH];
-static void add_filter_entry(std::string &dest, const char *description, const char *extensions);
-static const char* software_dir;
-
-
-//============================================================
-// PROTOTYPES
-//============================================================
-
-static void dialog_prime(dialog_box *di);
-static int dialog_write_item(dialog_box *di, DWORD style, short x, short y, short width, short height, const char *str, const WCHAR *class_name, WORD *id);
-
-
-
-//============================================================
-// PARAMETERS
-//============================================================
-
-#define ID_FRAMESKIP_0 10000
-#define ID_DEVICE_0 11000
-#define ID_JOYSTICK_0 12000
-#define ID_VIDEO_VIEW_0 14000
-#define MAX_JOYSTICKS (8)
-
-enum
-{
- DEVOPTION_OPEN,
- DEVOPTION_CREATE,
- DEVOPTION_CLOSE,
- DEVOPTION_CASSETTE_PLAYRECORD,
- DEVOPTION_CASSETTE_STOPPAUSE,
- DEVOPTION_CASSETTE_PLAY,
- DEVOPTION_CASSETTE_RECORD,
- DEVOPTION_CASSETTE_REWIND,
- DEVOPTION_CASSETTE_FASTFORWARD,
- DEVOPTION_MAX
-};
-
-
-//========================================================================
-// LOCAL STRING FUNCTIONS (these require free after being called)
-//========================================================================
-
-static WCHAR *ui_wstring_from_utf8(const char *utf8string)
-{
- int char_count;
- WCHAR *result;
-
- // convert MAME string (UTF-8) to UTF-16
- char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, nullptr, 0);
- result = (WCHAR *)malloc(char_count * sizeof(*result));
- if (result != nullptr)
- MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
-
- return result;
-}
-
-static char *ui_utf8_from_wstring(const WCHAR *wstring)
-{
- int char_count;
- char *result;
-
- // convert UTF-16 to MAME string (UTF-8)
- char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, nullptr, 0, nullptr, nullptr);
- result = (char *)malloc(char_count * sizeof(*result));
- if (result != nullptr)
- WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, nullptr, nullptr);
- return result;
-}
-
-
-
-//============================================================
-// win_get_file_name_dialog - sanitize all of the ugliness
-// in invoking GetOpenFileName() and GetSaveFileName()
-// called from win_file_dialog, state_dialog
-//============================================================
-
-static BOOL win_get_file_name_dialog(win_open_file_name *ofn)
-{
- BOOL result = FALSE;
- BOOL dialog_result;
- OPENFILENAME os_ofn;
- LPTSTR t_filter = NULL;
- LPTSTR t_file = NULL;
- DWORD t_file_size = 0;
- LPTSTR t_initial_directory = NULL;
- LPTSTR buffer;
- char *utf8_file;
- int i;
-
- // do we have to translate the filter?
- if (ofn->filter)
- {
- buffer = ui_wstring_from_utf8(ofn->filter);
- if (!buffer)
- goto done;
-
- // convert a pipe-char delimited string into a NUL delimited string
- t_filter = (LPTSTR) alloca((_tcslen(buffer) + 2) * sizeof(*t_filter));
- for (i = 0; buffer[i] != '\0'; i++)
- t_filter[i] = (buffer[i] != '|') ? buffer[i] : '\0';
- t_filter[i++] = '\0';
- t_filter[i++] = '\0';
- free(buffer);
- }
-
- // do we need to translate the file parameter?
- if (ofn->filename)
- {
- buffer = ui_wstring_from_utf8(ofn->filename);
- if (!buffer)
- goto done;
-
- t_file_size = ((_tcslen(buffer) + 1) > MAX_PATH) ? (_tcslen(buffer) + 1) : MAX_PATH;
- t_file = (LPTSTR) alloca(t_file_size * sizeof(*t_file));
- _tcscpy(t_file, buffer);
- free(buffer);
- }
-
- // do we need to translate the initial directory?
- if (ofn->initial_directory)
- {
- t_initial_directory = ui_wstring_from_utf8(ofn->initial_directory);
- if (t_initial_directory == NULL)
- goto done;
- }
-
- // translate our custom structure to a native Win32 structure
- memset(&os_ofn, 0, sizeof(os_ofn));
- os_ofn.lStructSize = sizeof(OPENFILENAME);
- os_ofn.hwndOwner = ofn->owner;
- os_ofn.hInstance = ofn->instance;
- os_ofn.lpstrFilter = t_filter;
- os_ofn.nFilterIndex = ofn->filter_index;
- os_ofn.lpstrFile = t_file;
- os_ofn.nMaxFile = t_file_size;
- os_ofn.lpstrInitialDir = t_initial_directory;
- os_ofn.Flags = ofn->flags;
- os_ofn.lCustData = ofn->custom_data;
- os_ofn.lpfnHook = ofn->hook;
- os_ofn.lpTemplateName = ofn->template_name;
-
- // invoke the correct Win32 call
- switch(ofn->type)
- {
- case WIN_FILE_DIALOG_OPEN:
- dialog_result = GetOpenFileName(&os_ofn);
- break;
-
- case WIN_FILE_DIALOG_SAVE:
- dialog_result = GetSaveFileName(&os_ofn);
- break;
-
- default:
- // should not reach here
- dialog_result = FALSE;
- break;
- }
-
- // copy data out
- ofn->filter_index = os_ofn.nFilterIndex;
- ofn->flags = os_ofn.Flags;
-
- // copy file back out into passed structure
- if (t_file)
- {
- utf8_file = ui_utf8_from_wstring(t_file);
- if (!utf8_file)
- goto done;
-
- snprintf(ofn->filename, ARRAY_LENGTH(ofn->filename), "%s", utf8_file);
- free(utf8_file);
- }
-
- // we've completed the process
- result = dialog_result;
-
-done:
- if (t_initial_directory)
- free(t_initial_directory);
- return result;
-}
-
-
-
-//============================================================
-// win_scroll_window
-// called from dialog_proc
-//============================================================
-
-static void win_scroll_window(HWND window, WPARAM wparam, int scroll_bar, int scroll_delta_line)
-{
- SCROLLINFO si;
- int scroll_pos;
-
- // retrieve vital info about the scroll bar
- memset(&si, 0, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
- GetScrollInfo(window, scroll_bar, &si);
-
- scroll_pos = si.nPos;
-
- // change scroll_pos in accordance with this message
- switch(LOWORD(wparam))
- {
- case SB_BOTTOM:
- scroll_pos = si.nMax;
- break;
- case SB_LINEDOWN:
- scroll_pos += scroll_delta_line;
- break;
- case SB_LINEUP:
- scroll_pos -= scroll_delta_line;
- break;
- case SB_PAGEDOWN:
- scroll_pos += scroll_delta_line;
- break;
- case SB_PAGEUP:
- scroll_pos -= scroll_delta_line;
- break;
- case SB_THUMBPOSITION:
- case SB_THUMBTRACK:
- scroll_pos = HIWORD(wparam);
- break;
- case SB_TOP:
- scroll_pos = si.nMin;
- break;
- }
-
- // max out the scroll bar value
- if (scroll_pos < si.nMin)
- scroll_pos = si.nMin;
- else if (scroll_pos > (si.nMax - si.nPage))
- scroll_pos = (si.nMax - si.nPage);
-
- // if the value changed, set the scroll position
- if (scroll_pos != si.nPos)
- {
- SetScrollPos(window, scroll_bar, scroll_pos, TRUE);
- ScrollWindowEx(window, 0, si.nPos - scroll_pos, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE);
- }
-}
-
-
-
-//============================================================
-// win_append_menu_utf8
-// create a menu item
-//============================================================
-
-static BOOL win_append_menu_utf8(HMENU menu, UINT flags, UINT_PTR id, const char *item)
-{
- BOOL result;
- const TCHAR *t_item = (const TCHAR*)item;
- TCHAR *t_str = NULL;
-
- // only convert string when it's not a bitmap
- if (!(flags & MF_BITMAP) && item)
- {
- t_str = ui_wstring_from_utf8(item);
- t_item = t_str;
- }
-
- result = AppendMenu(menu, flags, id, t_item);
-
- if (t_str)
- free(t_str);
-
- return result;
-}
-
-
-
-//============================================================
-// call_windowproc
-// called from adjuster_sb_wndproc, seqselect_wndproc
-//============================================================
-
-static LRESULT call_windowproc(WNDPROC wndproc, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
-{
- LRESULT rc;
- if (IsWindowUnicode(hwnd))
- rc = CallWindowProcW(wndproc, hwnd, msg, wparam, lparam);
- else
- rc = CallWindowProcA(wndproc, hwnd, msg, wparam, lparam);
- return rc;
-}
-
-
-
-//==========================================================================
-// dialog_write
-// called from dialog_write_string, win_dialog_init, dialog_write_item
-//==========================================================================
-
-static int dialog_write(struct _dialog_box *di, const void *ptr, size_t sz, int align)
-{
- HGLOBAL newhandle;
- size_t base;
- UINT8 *mem;
- UINT8 *mem2;
-
- if (!di->handle)
- {
- newhandle = GlobalAlloc(GMEM_ZEROINIT, sz);
- base = 0;
- }
- else
- {
- base = di->handle_size;
- base += align - 1;
- base -= base % align;
- newhandle = GlobalReAlloc(di->handle, base + sz, GMEM_ZEROINIT);
- if (!newhandle)
- {
- newhandle = GlobalAlloc(GMEM_ZEROINIT, base + sz);
- if (newhandle)
- {
- mem = (UINT8*)GlobalLock(di->handle);
- mem2 = (UINT8*)GlobalLock(newhandle);
- memcpy(mem2, mem, base);
- GlobalUnlock(di->handle);
- GlobalUnlock(newhandle);
- GlobalFree(di->handle);
- }
- }
- }
- if (!newhandle)
- return 1;
-
- mem = (UINT8*)GlobalLock(newhandle);
- memcpy(mem + base, ptr, sz);
- GlobalUnlock(newhandle);
- di->handle = newhandle;
- di->handle_size = base + sz;
- return 0;
-}
-
-
-
-//============================================================
-// dialog_write_string
-// called from win_dialog_init, dialog_write_item
-//============================================================
-
-static int dialog_write_string(dialog_box *di, const WCHAR *str)
-{
- if (!str)
- str = L"";
- return dialog_write(di, str, (wcslen(str) + 1) * sizeof(WCHAR), 2);
-}
-
-
-
-
-//============================================================
-// win_dialog_exit
-// called from win_dialog_init, calc_dlgunits_multiple, change_device, and all customise_input functions
-//============================================================
-
-static void win_dialog_exit(dialog_box *dialog)
-{
- int i;
- struct dialog_object_pool *objpool;
-
- if (!dialog)
- printf("No dialog passed to win_dialog_exit\n");
- assert(dialog);
-
- objpool = dialog->objpool;
- if (objpool)
- {
- for (i = 0; i < ARRAY_LENGTH(objpool->objects); i++)
- DeleteObject(objpool->objects[i]);
- }
-
- if (dialog->handle)
- GlobalFree(dialog->handle);
-
- free(dialog);
-}
-
-
-
-//===========================================================================
-// win_dialog_init
-// called from calc_dlgunits_multiple, and all customise_input functions
-//===========================================================================
-
-dialog_box *win_dialog_init(const char *title, const struct dialog_layout *layout)
-{
- struct _dialog_box *di;
- DLGTEMPLATE dlg_template;
- WORD w[2];
- WCHAR *w_title;
- int rc;
-
- // use default layout if not specified
- if (!layout)
- layout = &default_layout;
-
- // create the dialog structure
- di = (_dialog_box *)malloc(sizeof(struct _dialog_box));
- if (!di)
- goto error;
- memset(di, 0, sizeof(*di));
-
- di->layout = layout;
-
- memset(&dlg_template, 0, sizeof(dlg_template));
- dlg_template.style = di->style = DIALOG_STYLE;
- dlg_template.x = 10;
- dlg_template.y = 10;
- if (dialog_write(di, &dlg_template, sizeof(dlg_template), 4))
- goto error;
-
- w[0] = 0;
- w[1] = 0;
- if (dialog_write(di, w, sizeof(w), 2))
- goto error;
-
- w_title = ui_wstring_from_utf8(title);
- rc = dialog_write_string(di, w_title);
- free(w_title);
- if (rc)
- goto error;
-
- // set the font, if necessary
- if (di->style & DS_SETFONT)
- {
- w[0] = FONT_SIZE;
- if (dialog_write(di, w, sizeof(w[0]), 2))
- goto error;
- if (dialog_write_string(di, FONT_FACE))
- goto error;
- }
-
- return di;
-
-error:
- if (di)
- win_dialog_exit(di);
- return NULL;
-}
-
-
-//============================================================
-// compute_dlgunits_multiple
-// called from dialog_scrollbar_init
-//============================================================
-
-static void calc_dlgunits_multiple(void)
-{
- dialog_box *dialog = NULL;
- short offset_x = 2048;
- short offset_y = 2048;
- const char *wnd_title = "Foo";
- WORD id;
- HWND dlg_window = NULL;
- HWND child_window;
- RECT r;
-
- if ((pixels_to_xdlgunits == 0) || (pixels_to_ydlgunits == 0))
- {
- // create a bogus dialog
- dialog = win_dialog_init(NULL, NULL);
- if (!dialog)
- goto done;
-
- if (dialog_write_item(dialog, WS_CHILD | WS_VISIBLE | SS_LEFT, 0, 0, offset_x, offset_y, wnd_title, DLGITEM_STATIC, &id))
- goto done;
-
- dialog_prime(dialog);
- dlg_window = CreateDialogIndirectParam(NULL, (const DLGTEMPLATE*)dialog->handle, NULL, NULL, 0);
- child_window = GetDlgItem(dlg_window, id);
-
- GetWindowRect(child_window, &r);
- pixels_to_xdlgunits = (double)(r.right - r.left) / offset_x;
- pixels_to_ydlgunits = (double)(r.bottom - r.top) / offset_y;
-
-done:
- if (dialog)
- win_dialog_exit(dialog);
- if (dlg_window)
- DestroyWindow(dlg_window);
- }
-}
-
-
-
-//============================================================
-// dialog_trigger
-// called from dialog_proc, file_dialog_hook
-//============================================================
-
-static void dialog_trigger(HWND dlgwnd, WORD trigger_flags)
-{
- LRESULT result;
- HWND dialog_item;
- struct _dialog_box *di;
- struct dialog_info_trigger *trigger;
- LONG_PTR l;
-
- l = GetWindowLongPtr(dlgwnd, GWLP_USERDATA);
- di = (struct _dialog_box *) l;
- if (!di)
- printf("Unexpected result of di in dialog_trigger\n");
- assert(di);
- for (trigger = di->trigger_first; trigger; trigger = trigger->next)
- {
- if (trigger->trigger_flags & trigger_flags)
- {
- if (trigger->dialog_item)
- dialog_item = GetDlgItem(dlgwnd, trigger->dialog_item);
- else
- dialog_item = dlgwnd;
- if (!dialog_item)
- printf("Unexpected result of dialog_item in dialog_trigger\n");
- assert(dialog_item);
- result = 0;
-
- if (trigger->message)
- result = SendMessage(dialog_item, trigger->message, trigger->wparam, trigger->lparam);
- if (trigger->trigger_proc)
- result = trigger->trigger_proc(di, dialog_item, trigger->message, trigger->wparam, trigger->lparam);
-
- if (trigger->storeval)
- trigger->storeval(trigger->storeval_param, result);
- }
- }
-}
-
-//============================================================
-// dialog_proc
-// called from win_dialog_runmodal
-//============================================================
-
-static INT_PTR CALLBACK dialog_proc(HWND dlgwnd, UINT msg, WPARAM wparam, LPARAM lparam)
-{
- INT_PTR handled = TRUE;
- std::string buf;
- WORD command;
-
- switch(msg)
- {
- case WM_INITDIALOG:
- SetWindowLongPtr(dlgwnd, GWLP_USERDATA, (LONG_PTR) lparam);
- dialog_trigger(dlgwnd, TRIGGER_INITDIALOG);
- break;
-
- case WM_COMMAND:
- command = LOWORD(wparam);
-
- buf = win_get_window_text_utf8((HWND) lparam);
- if (!strcmp(buf.c_str(), DLGTEXT_OK))
- command = IDOK;
- else if (!strcmp(buf.c_str(), DLGTEXT_CANCEL))
- command = IDCANCEL;
- else
- command = 0;
-
- switch(command)
- {
- case IDOK:
- dialog_trigger(dlgwnd, TRIGGER_APPLY);
- // fall through
-
- case IDCANCEL:
- EndDialog(dlgwnd, 0);
- break;
-
- default:
- handled = FALSE;
- break;
- }
- break;
-
- case WM_SYSCOMMAND:
- if (wparam == SC_CLOSE)
- EndDialog(dlgwnd, 0);
- else
- handled = FALSE;
-
- break;
-
- case WM_VSCROLL:
- if (lparam)
- // this scroll message came from an actual scroll bar window;
- // pass it on
- SendMessage((HWND) lparam, msg, wparam, lparam);
- else
- // scroll the dialog
- win_scroll_window(dlgwnd, wparam, SB_VERT, SCROLL_DELTA_LINE);
-
- break;
-
- default:
- handled = FALSE;
- break;
- }
- return handled;
-}
-
-
-
-//=========================================================================================================================================================================================
-// dialog_write_item
-// called from calc_dlgunits_multiple, win_dialog_add_active_combobox, win_dialog_add_adjuster, dialog_add_single_seqselect, win_dialog_add_portselect, win_dialog_add_standard_buttons
-//=========================================================================================================================================================================================
-
-static int dialog_write_item(dialog_box *di, DWORD style, short x, short y, short width, short height, const char *str, const WCHAR *class_name, WORD *id)
-{
- DLGITEMTEMPLATE item_template;
- UINT class_name_length;
- WORD w;
- WCHAR *w_str;
- int rc;
-
- memset(&item_template, 0, sizeof(item_template));
- item_template.style = style;
- item_template.x = x;
- item_template.y = y;
- item_template.cx = width;
- item_template.cy = height;
- item_template.id = di->item_count + 1;
-
- if (dialog_write(di, &item_template, sizeof(item_template), 4))
- return 1;
-
- if (*class_name == 0xffff)
- class_name_length = 4;
- else
- class_name_length = (wcslen(class_name) + 1) * sizeof(WCHAR);
- if (dialog_write(di, class_name, class_name_length, 2))
- return 1;
-
- w_str = str ? ui_wstring_from_utf8(str) : NULL;
- rc = dialog_write_string(di, w_str);
- if (w_str)
- free(w_str);
- if (rc)
- return 1;
-
- w = 0;
- if (dialog_write(di, &w, sizeof(w), 2))
- return 1;
-
- di->item_count++;
-
- if (id)
- *id = di->item_count;
- return 0;
-}
-
-
-
-//==========================================================================================================================================================
-// dialog_add_trigger
-// called from dialog_add_scrollbar, win_dialog_add_active_combobox, win_dialog_add_combobox_item, win_dialog_add_adjuster, dialog_add_single_seqselect
-//==========================================================================================================================================================
-
-static int dialog_add_trigger(struct _dialog_box *di, WORD dialog_item, WORD trigger_flags, UINT message, trigger_function trigger_proc,
- WPARAM wparam, LPARAM lparam, void (*storeval)(void *param, int val), void *storeval_param)
-{
- if (!di)
- printf("Unexpected result of di in dialog_add_trigger\n");
- assert(di);
- if (!trigger_flags)
- printf("Unexpected result of trigger_flags in dialog_add_trigger\n");
- assert(trigger_flags);
-
- dialog_info_trigger *trigger = new(dialog_info_trigger);
-
- trigger->next = NULL;
- trigger->trigger_flags = trigger_flags;
- trigger->dialog_item = dialog_item;
- trigger->message = message;
- trigger->trigger_proc = trigger_proc;
- trigger->wparam = wparam;
- trigger->lparam = lparam;
- trigger->storeval = storeval;
- trigger->storeval_param = storeval_param;
-
- if (di->trigger_last)
- di->trigger_last->next = trigger;
- else
- di->trigger_first = trigger;
- di->trigger_last = trigger;
- return 0;
-}
-
-
-
-//============================================================
-// dialog_scrollbar_init
-// called from dialog_add_scrollbar
-//============================================================
-
-static LRESULT dialog_scrollbar_init(dialog_box *dialog, HWND dlgwnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- SCROLLINFO si;
-
- calc_dlgunits_multiple();
-
- memset(&si, 0, sizeof(si));
- si.cbSize = sizeof(si);
- si.nMin = pixels_to_ydlgunits * 0;
- si.nMax = pixels_to_ydlgunits * dialog->size_y;
- si.nPage = pixels_to_ydlgunits * MAX_DIALOG_HEIGHT;
- si.fMask = SIF_PAGE | SIF_RANGE;
-
- SetScrollInfo(dlgwnd, SB_VERT, &si, TRUE);
- return 0;
-}
-
-
-
-//============================================================
-// dialog_add_scrollbar
-// called from dialog_prime
-//============================================================
-
-static int dialog_add_scrollbar(dialog_box *dialog)
-{
- if (dialog_add_trigger(dialog, 0, TRIGGER_INITDIALOG, 0, dialog_scrollbar_init, 0, 0, NULL, NULL))
- return 1;
-
- dialog->style |= WS_VSCROLL;
- return 0;
-}
-
-
-
-//==============================================================================
-// dialog_prime
-// called from calc_dlgunits_multiple, win_dialog_runmodal, win_file_dialog
-//==============================================================================
-
-static void dialog_prime(dialog_box *di)
-{
- DLGTEMPLATE *dlg_template;
-
- if (di->size_y > MAX_DIALOG_HEIGHT)
- {
- di->size_x += DIM_SCROLLBAR_WIDTH;
- dialog_add_scrollbar(di);
- }
-
- dlg_template = (DLGTEMPLATE *) GlobalLock(di->handle);
- dlg_template->cdit = di->item_count;
- dlg_template->cx = di->size_x;
- dlg_template->cy = (di->size_y > MAX_DIALOG_HEIGHT) ? MAX_DIALOG_HEIGHT : di->size_y;
- dlg_template->style = di->style;
- GlobalUnlock(di->handle);
-}
-
-
-
-//============================================================
-// dialog_get_combo_value
-// called from win_dialog_add_active_combobox
-//============================================================
-
-static LRESULT dialog_get_combo_value(dialog_box *dialog, HWND dialog_item, UINT message, WPARAM wparam, LPARAM lparam)
-{
- int idx;
- idx = SendMessage(dialog_item, CB_GETCURSEL, 0, 0);
- if (idx == CB_ERR)
- return 0;
- return SendMessage(dialog_item, CB_GETITEMDATA, idx, 0);
-}
-
-
-
-//============================================================
-// dialog_get_adjuster_value
-// called from win_dialog_add_adjuster
-//============================================================
-
-static LRESULT dialog_get_adjuster_value(dialog_box *dialog, HWND dialog_item, UINT message, WPARAM wparam, LPARAM lparam)
-{
- TCHAR buf[32];
- GetWindowText(dialog_item, buf, ARRAY_LENGTH(buf));
- return _ttoi(buf);
-}
-
-
-
-//====================================================================================================
-// dialog_new_control
-// called from win_dialog_add_active_combobox, win_dialog_add_adjuster, win_dialog_add_portselect
-//====================================================================================================
-
-static void dialog_new_control(struct _dialog_box *di, short *x, short *y)
-{
- *x = di->pos_x + DIM_HORIZONTAL_SPACING;
- *y = di->pos_y + DIM_VERTICAL_SPACING;
-}
-
-
-
-//====================================================================================================
-// dialog_finish_control
-// called from win_dialog_add_active_combobox, win_dialog_add_adjuster, win_dialog_add_portselect
-//====================================================================================================
-
-static void dialog_finish_control(struct _dialog_box *di, short x, short y)
-{
- di->pos_y = y;
-
- // update dialog size
- if (x > di->size_x)
- di->size_x = x;
- if (y > di->size_y)
- di->size_y = y;
- if (x > di->cursize_x)
- di->cursize_x = x;
- if (y > di->cursize_y)
- di->cursize_y = y;
-}
-
-
-
-//============================================================
-// dialog_combo_changed
-// called from win_dialog_add_active_combobox
-//============================================================
-
-static LRESULT dialog_combo_changed(dialog_box *dialog, HWND dlgitem, UINT message, WPARAM wparam, LPARAM lparam)
-{
- dialog_itemchangedproc changed = (dialog_itemchangedproc) wparam;
- changed(dialog, dlgitem, (void *) lparam);
- return 0;
-}
-
-
-
-//============================================================
-// win_dialog_wcsdup
-// called from win_dialog_add_adjuster (via define)
-//============================================================
-
-static WCHAR *win_dialog_wcsdup(dialog_box *dialog, const WCHAR *s)
-{
- WCHAR *result = global_alloc_array(WCHAR, wcslen(s) + 1);
- if (result)
- wcscpy(result, s);
- return result;
-}
-
-
-
-//============================================================
-// win_dialog_add_active_combobox
-// called from win_dialog_add_combobox
-//============================================================
-
-static int win_dialog_add_active_combobox(dialog_box *dialog, const char *item_label, int default_value,
- dialog_itemstoreval storeval, void *storeval_param, dialog_itemchangedproc changed, void *changed_param)
-{
- int rc = 1;
- short x;
- short y;
-
- dialog_new_control(dialog, &x, &y);
-
- if (dialog_write_item(dialog, WS_CHILD | WS_VISIBLE | SS_LEFT,
- x, y, dialog->layout->label_width, DIM_COMBO_ROW_HEIGHT, item_label, DLGITEM_STATIC, NULL))
- goto done;
-
- y += DIM_BOX_VERTSKEW;
-
- x += dialog->layout->label_width + DIM_HORIZONTAL_SPACING;
- if (dialog_write_item(dialog, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST,
- x, y, dialog->layout->combo_width, DIM_COMBO_ROW_HEIGHT * 8, NULL, DLGITEM_COMBOBOX, NULL))
- goto done;
- dialog->combo_string_count = 0;
- dialog->combo_default_value = default_value;
-
- // add the trigger invoked when the apply button is pressed
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_APPLY, 0, dialog_get_combo_value, 0, 0, storeval, storeval_param))
- goto done;
-
- // if appropriate, add the optional changed trigger
- if (changed)
- {
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_INITDIALOG | TRIGGER_CHANGED, 0, dialog_combo_changed, (WPARAM) changed, (LPARAM) changed_param, NULL, NULL))
- goto done;
- }
-
- x += dialog->layout->combo_width + DIM_HORIZONTAL_SPACING;
- y += DIM_COMBO_ROW_HEIGHT + DIM_VERTICAL_SPACING * 2;
-
- dialog_finish_control(dialog, x, y);
- rc = 0;
-
-done:
- return rc;
-}
-
-
-
-//============================================================
-// win_dialog_add_combobox
-// called from customise_switches, customise_analogcontrols
-//============================================================
-
-static int win_dialog_add_combobox(dialog_box *dialog, const char *item_label, int default_value, void (*storeval)(void *param, int val), void *storeval_param)
-{
- return win_dialog_add_active_combobox(dialog, item_label, default_value, storeval, storeval_param, NULL, NULL);
-}
-
-
-
-//============================================================
-// win_dialog_add_combobox_item
-// called from customise_switches, customise_analogcontrols
-//============================================================
-
-static int win_dialog_add_combobox_item(dialog_box *dialog, const char *item_label, int item_data)
-{
- // create our own copy of the string
- size_t newsize = strlen(item_label) + 1;
- wchar_t * t_item_label = new wchar_t[newsize];
- //size_t convertedChars = 0;
- //mbstowcs_s(&convertedChars, t_item_label, newsize, item_label, _TRUNCATE);
- mbstowcs(t_item_label, item_label, newsize);
-
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_INITDIALOG, CB_ADDSTRING, NULL, 0, (LPARAM) t_item_label, NULL, NULL))
- return 1;
- dialog->combo_string_count++;
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_INITDIALOG, CB_SETITEMDATA, NULL, dialog->combo_string_count-1, (LPARAM) item_data, NULL, NULL))
- return 1;
- if (item_data == dialog->combo_default_value)
- {
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_INITDIALOG, CB_SETCURSEL, NULL, dialog->combo_string_count-1, 0, NULL, NULL))
- return 1;
- }
- return 0;
-}
-
-
-
-//============================================================
-// adjuster_sb_wndproc
-// called from adjuster_sb_setup
-//============================================================
-
-struct adjuster_sb_stuff
-{
- WNDPROC oldwndproc;
- int min_value;
- int max_value;
-};
-
-static INT_PTR CALLBACK adjuster_sb_wndproc(HWND sbwnd, UINT msg, WPARAM wparam, LPARAM lparam)
-{
- INT_PTR result;
- struct adjuster_sb_stuff *stuff;
- std::string buf;
- CHAR BUF[64];
- HWND dlgwnd, editwnd;
- int value, id;
- LONG_PTR l;
-
- l = GetWindowLongPtr(sbwnd, GWLP_USERDATA);
- stuff = (struct adjuster_sb_stuff *) l;
-
- if (msg == WM_VSCROLL)
- {
- id = GetWindowLong(sbwnd, GWL_ID);
- dlgwnd = GetParent(sbwnd);
- editwnd = GetDlgItem(dlgwnd, id - 1);
- buf = win_get_window_text_utf8(editwnd);
- value = atoi(buf.c_str());
-
- switch(wparam)
- {
- case SB_LINEDOWN:
- case SB_PAGEDOWN:
- value--;
- break;
-
- case SB_LINEUP:
- case SB_PAGEUP:
- value++;
- break;
- }
-
- if (value < stuff->min_value)
- value = stuff->min_value;
- else if (value > stuff->max_value)
- value = stuff->max_value;
- _snprintf(BUF, 64, "%d", value);
- win_set_window_text_utf8(editwnd, BUF);
- result = 0;
- }
- else
- result = call_windowproc(stuff->oldwndproc, sbwnd, msg, wparam, lparam);
-
- return result;
-}
-
-
-
-//============================================================
-// adjuster_sb_setup
-// called from win_dialog_add_adjuster
-//============================================================
-
-static LRESULT adjuster_sb_setup(dialog_box *dialog, HWND sbwnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- struct adjuster_sb_stuff *stuff;
- LONG_PTR l;
-
- stuff = global_alloc(adjuster_sb_stuff);
- if (!stuff)
- return 1;
- stuff->min_value = (WORD) (lparam >> 0);
- stuff->max_value = (WORD) (lparam >> 16);
-
- l = (LONG_PTR) stuff;
- SetWindowLongPtr(sbwnd, GWLP_USERDATA, l);
- l = (LONG_PTR) adjuster_sb_wndproc;
- l = SetWindowLongPtr(sbwnd, GWLP_WNDPROC, l);
- stuff->oldwndproc = (WNDPROC) l;
- return 0;
-}
-
-
-
-//============================================================
-// win_dialog_add_adjuster
-// called from customise_analogcontrols
-//============================================================
-
-static int win_dialog_add_adjuster(dialog_box *dialog, const char *item_label, int default_value,
- int min_value, int max_value, BOOL is_percentage, dialog_itemstoreval storeval, void *storeval_param)
-{
- short x;
- short y;
- TCHAR buf[32];
- TCHAR *s;
-
- dialog_new_control(dialog, &x, &y);
-
- if (dialog_write_item(dialog, WS_CHILD | WS_VISIBLE | SS_LEFT, x, y, dialog->layout->label_width, DIM_ADJUSTER_HEIGHT, item_label, DLGITEM_STATIC, NULL))
- goto error;
- x += dialog->layout->label_width + DIM_HORIZONTAL_SPACING;
-
- y += DIM_BOX_VERTSKEW;
-
- if (dialog_write_item(dialog, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER,
- x, y, dialog->layout->combo_width - DIM_ADJUSTER_SCR_WIDTH, DIM_ADJUSTER_HEIGHT, NULL, DLGITEM_EDIT, NULL))
- goto error;
- x += dialog->layout->combo_width - DIM_ADJUSTER_SCR_WIDTH;
-
- _sntprintf(buf, ARRAY_LENGTH(buf), is_percentage ? TEXT("%d%%") : TEXT("%d"), default_value);
- s = win_dialog_tcsdup(dialog, buf);
-
- if (!s)
- return 1;
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_INITDIALOG, WM_SETTEXT, NULL, 0, (LPARAM) s, NULL, NULL))
- goto error;
-
- // add the trigger invoked when the apply button is pressed
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_APPLY, 0, dialog_get_adjuster_value, 0, 0, storeval, storeval_param))
- goto error;
-
- if (dialog_write_item(dialog, WS_CHILD | WS_VISIBLE | WS_TABSTOP | SBS_VERT, x, y, DIM_ADJUSTER_SCR_WIDTH, DIM_ADJUSTER_HEIGHT, NULL, DLGITEM_SCROLLBAR, NULL))
- goto error;
- x += DIM_ADJUSTER_SCR_WIDTH + DIM_HORIZONTAL_SPACING;
-
- if (dialog_add_trigger(dialog, dialog->item_count, TRIGGER_INITDIALOG, 0, adjuster_sb_setup, 0, MAKELONG(min_value, max_value), NULL, NULL))
- return 1;
-
- y += DIM_COMBO_ROW_HEIGHT + DIM_VERTICAL_SPACING * 2;
-
- dialog_finish_control(dialog, x, y);
- return 0;
-
-error:
- return 1;
-}
-
-
-
-
-//============================================================
-// get_seqselect_info
-//============================================================
-
-static seqselect_info *get_seqselect_info(HWND editwnd)
-{
- LONG_PTR lp;
- lp = GetWindowLongPtr(editwnd, GWLP_USERDATA);
- return (seqselect_info *) lp;
-}
-
-
-
-//=============================================================================
-// seqselect_settext
-// called from seqselect_start_read_from_main_thread, seqselect_setup
-//=============================================================================
-//#pragma GCC diagnostic push
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-value"
-#endif
-
-static void seqselect_settext(HWND editwnd)
-{
- seqselect_info *stuff;
- std::string seqstring, buf;
-
- // the basics
- stuff = get_seqselect_info(editwnd);
- if (stuff == NULL)
- return; // this should not happen - need to fix this
-
- // retrieve the seq name
- seqstring = Machine->input().seq_name(*stuff->code);
-
- // change the text - avoid calls to SetWindowText() if we can
- buf = win_get_window_text_utf8(editwnd);
- if (buf != seqstring)
- win_set_window_text_utf8(editwnd, seqstring.c_str());
-
- // reset the selection
- if (GetFocus() == editwnd)
- {
- DWORD start = 0, end = 0;
- SendMessage(editwnd, EM_GETSEL, (WPARAM) (LPDWORD) &start, (LPARAM) (LPDWORD) &end);
- if ((start != 0) || (end != buf.size()))
- SendMessage(editwnd, EM_SETSEL, 0, -1);
- }
-}
-
-#ifdef __GNUC__
-#pragma GCC diagnostic error "-Wunused-value"
-#endif
-
-
-//============================================================
-// seqselect_start_read_from_main_thread
-// called from seqselect_wndproc
-//============================================================
-
-static void seqselect_start_read_from_main_thread(void *param)
-{
- seqselect_info *stuff;
-
- // get the basics
- HWND editwnd = (HWND) param;
- stuff = get_seqselect_info(editwnd);
-
- // are we currently polling? if so bail out
- if (stuff->poll_state != SEQSELECT_STATE_NOT_POLLING)
- return;
-
- // change the state
- stuff->poll_state = SEQSELECT_STATE_POLLING;
-
- // the Win32 OSD code thinks that we are paused, we need to temporarily
- // unpause ourselves or else we will block
- int pause_count = 0;
- while(Machine->paused() && !winwindow_ui_is_paused(*Machine))
- {
- winwindow_ui_pause(*Machine, FALSE);
- pause_count++;
- }
-
- // start the polling
- (*Machine).input().seq_poll_start(stuff->is_analog ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, NULL);
-
- while(stuff->poll_state == SEQSELECT_STATE_POLLING)
- {
- // poll
- if (Machine->input().seq_poll())
- {
- *stuff->code = Machine->input().seq_poll_final();
- seqselect_settext(editwnd);
- }
- }
-
- // we are no longer polling
- stuff->poll_state = SEQSELECT_STATE_NOT_POLLING;
-
- // repause the OSD code
- while(pause_count--)
- winwindow_ui_pause(*Machine, TRUE);
-}
-
-
-
-//============================================================
-// seqselect_stop_read_from_main_thread
-// called from seqselect_wndproc
-//============================================================
-
-static void seqselect_stop_read_from_main_thread(void *param)
-{
- HWND editwnd;
- seqselect_info *stuff;
-
- // get the basics
- editwnd = (HWND) param;
- stuff = get_seqselect_info(editwnd);
-
- // stop the read
- if (stuff->poll_state == SEQSELECT_STATE_POLLING)
- stuff->poll_state = SEQSELECT_STATE_POLLING_COMPLETE;
-}
-
-
-
-//============================================================
-// seqselect_wndproc
-// called from seqselect_setup
-//============================================================
-
-static INT_PTR CALLBACK seqselect_wndproc(HWND editwnd, UINT msg, WPARAM wparam, LPARAM lparam)
-{
- seqselect_info *stuff;
- INT_PTR result = 0;
- BOOL call_baseclass = TRUE;
-
- stuff = get_seqselect_info(editwnd);
-
- switch(msg)
- {
- case WM_KEYDOWN:
- case WM_SYSKEYDOWN:
- case WM_CHAR:
- case WM_KEYUP:
- case WM_SYSKEYUP:
- result = 1;
- call_baseclass = FALSE;
- break;
-
- case WM_SETFOCUS:
- PostMessage(editwnd, SEQWM_SETFOCUS, 0, 0);
- break;
-
- case WM_KILLFOCUS:
- PostMessage(editwnd, SEQWM_KILLFOCUS, 0, 0);
- break;
-
- case SEQWM_SETFOCUS:
- // if we receive the focus, we should start a polling loop
- seqselect_start_read_from_main_thread( (void *) editwnd);
- break;
-
- case SEQWM_KILLFOCUS:
- // when we abort the focus, end any current polling loop
- seqselect_stop_read_from_main_thread( (void *) editwnd);
- break;
-
- case WM_LBUTTONDOWN:
- case WM_RBUTTONDOWN:
- SetFocus(editwnd);
- SendMessage(editwnd, EM_SETSEL, 0, -1);
- call_baseclass = FALSE;
- result = 0;
- break;
- }
-
- if (call_baseclass)
- result = call_windowproc(stuff->oldwndproc, editwnd, msg, wparam, lparam);
- return result;
-}
-
-
-
-//============================================================
-// seqselect_setup
-// called from dialog_add_single_seqselect
-//============================================================
-
-static LRESULT seqselect_setup(dialog_box *dialog, HWND editwnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- seqselect_info *stuff = (seqselect_info *) lparam;
- LONG_PTR lp;
-
- lp = SetWindowLongPtr(editwnd, GWLP_WNDPROC, (LONG_PTR) seqselect_wndproc);
- stuff->oldwndproc = (WNDPROC) lp;
- SetWindowLongPtr(editwnd, GWLP_USERDATA, lparam);
- seqselect_settext(editwnd);
- return 0;
-}
-
-
-
-//============================================================
-// seqselect_apply
-// called from dialog_add_single_seqselect
-//============================================================
-
-static LRESULT seqselect_apply(dialog_box *dialog, HWND editwnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- seqselect_info *stuff;
- stuff = get_seqselect_info(editwnd);
-
- // store the settings
- stuff->field->set_user_settings(stuff->settings);
-
- return 0;
-}
-
-//============================================================
-// dialog_add_single_seqselect
-// called from win_dialog_add_portselect
-//============================================================
-
-static int dialog_add_single_seqselect(struct _dialog_box *di, short x, short y, short cx, short cy, ioport_field *field, int is_analog, int seqtype)
-{
- // write the dialog item
- if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | ES_CENTER | SS_SUNKEN, x, y, cx, cy, NULL, DLGITEM_EDIT, NULL))
- return 1;
-
- // allocate a seqselect_info
- seqselect_info *stuff = new(seqselect_info);
- //seqselect_info *stuff;
- //stuff = global_alloc(seqselect_info);
- if (!stuff)
- return 1;
-
- // initialize the structure
- memset(stuff, 0, sizeof(*stuff));
- field->get_user_settings(stuff->settings);
- stuff->field = field;
- stuff->pos = di->item_count;
- stuff->is_analog = is_analog;
-
- // This next line is completely unsafe, but I do not know what to use *****************
- stuff->code = const_cast <input_seq*> (&field->seq( (input_seq_type) seqtype) );
-
- if (dialog_add_trigger(di, di->item_count, TRIGGER_INITDIALOG, 0, seqselect_setup, di->item_count, (LPARAM) stuff, NULL, NULL))
- return 1;
- if (dialog_add_trigger(di, di->item_count, TRIGGER_APPLY, 0, seqselect_apply, 0, 0, NULL, NULL))
- return 1;
- return 0;
-}
-
-
-
-//============================================================
-// win_dialog_add_seqselect
-// called from customise_input, customise_miscinput
-//============================================================
-
-static int win_dialog_add_portselect(dialog_box *dialog, ioport_field *field)
-{
- dialog_box *di = dialog;
- short x;
- short y;
- const char *port_name;
- const char *this_port_name;
- char *s;
- int seq;
- int seq_count = 0;
- const char *port_suffix[3];
- int seq_types[3];
- int is_analog[3];
- int len;
-
- port_name = field->name();
- if (!port_name)
- printf("Blank port_name encountered in win_dialog_add_portselect\n");
- assert(port_name);
-
- if (field->type() > IPT_ANALOG_FIRST && field->type() < IPT_ANALOG_LAST)
- {
- seq_types[seq_count] = SEQ_TYPE_STANDARD;
- port_suffix[seq_count] = " Analog";
- is_analog[seq_count] = TRUE;
- seq_count++;
-
- seq_types[seq_count] = SEQ_TYPE_DECREMENT;
- port_suffix[seq_count] = " Dec";
- is_analog[seq_count] = FALSE;
- seq_count++;
-
- seq_types[seq_count] = SEQ_TYPE_INCREMENT;
- port_suffix[seq_count] = " Inc";
- is_analog[seq_count] = FALSE;
- seq_count++;
- }
- else
- {
- seq_types[seq_count] = SEQ_TYPE_STANDARD;
- port_suffix[seq_count] = NULL;
- is_analog[seq_count] = FALSE;
- seq_count++;
- }
-
- for (seq = 0; seq < seq_count; seq++)
- {
- // create our local name for this entry; also convert from
- // MAME strings to wide strings
- len = strlen(port_name);
- s = (char *) alloca((len + (port_suffix[seq] ? strlen(port_suffix[seq]) : 0) + 1) * sizeof(*s));
- strcpy(s, port_name);
-
- if (port_suffix[seq])
- strcpy(s + len, port_suffix[seq]);
- this_port_name = s;
-
- // no positions specified
- dialog_new_control(di, &x, &y);
-
- if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX, x, y,
- dialog->layout->label_width, DIM_NORMAL_ROW_HEIGHT, this_port_name, DLGITEM_STATIC, NULL))
- return 1;
- x += dialog->layout->label_width + DIM_HORIZONTAL_SPACING;
-
- if (dialog_add_single_seqselect(di, x, y, DIM_EDIT_WIDTH, DIM_NORMAL_ROW_HEIGHT, field, is_analog[seq], seq_types[seq]))
- return 1;
- y += DIM_VERTICAL_SPACING + DIM_NORMAL_ROW_HEIGHT;
- x += DIM_EDIT_WIDTH + DIM_HORIZONTAL_SPACING;
-
- dialog_finish_control(di, x, y);
- }
- return 0;
-}
-
-
-
-//============================================================
-// win_dialog_add_standard_buttons
-//============================================================
-
-static int win_dialog_add_standard_buttons(dialog_box *dialog)
-{
- dialog_box *di = dialog;
- short x;
- short y;
-
- // Handle the case of an empty dialog box (size_x & size_y will be 0)
- if (!di->size_x)
- di->size_x = 3 * DIM_HORIZONTAL_SPACING + 2 * DIM_BUTTON_WIDTH;
- if (!di->size_y)
- di->size_y = DIM_VERTICAL_SPACING;
-
- // work out where cancel button goes
- x = di->size_x - DIM_HORIZONTAL_SPACING - DIM_BUTTON_WIDTH;
- y = di->size_y + DIM_VERTICAL_SPACING;
-
- // display cancel button
- if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_LEFT, x, y, DIM_BUTTON_WIDTH, DIM_BUTTON_ROW_HEIGHT, DLGTEXT_CANCEL, DLGITEM_BUTTON, NULL))
- return 1;
-
- // work out where OK button goes
- x -= DIM_HORIZONTAL_SPACING + DIM_BUTTON_WIDTH;
-
- // display OK button
- if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_LEFT, x, y, DIM_BUTTON_WIDTH, DIM_BUTTON_ROW_HEIGHT, DLGTEXT_OK, DLGITEM_BUTTON, NULL))
- return 1;
-
- di->size_y += DIM_BUTTON_ROW_HEIGHT + DIM_VERTICAL_SPACING * 2;
-
- return 0;
-}
-
-
-
-//============================================================
-// before_display_dialog
-//============================================================
-
-static void before_display_dialog(running_machine &machine)
-{
- Machine = &machine;
- winwindow_ui_pause(machine, TRUE);
-}
-
-
-
-//============================================================
-// after_display_dialog
-//============================================================
-
-static void after_display_dialog(running_machine &machine)
-{
- winwindow_ui_pause(machine, FALSE);
-}
-
-
-
-//============================================================
-// win_dialog_runmodal
-// called from the various customise_inputs functions
-//============================================================
-
-static void win_dialog_runmodal(running_machine &machine, HWND wnd, dialog_box *dialog)
-{
- if (!dialog)
- printf("Unexpected result in win_dialog_runmodal\n");
- assert(dialog);
-
- // finishing touches on the dialog
- dialog_prime(dialog);
-
- // show the dialog
- before_display_dialog(machine);
- DialogBoxIndirectParamW(NULL, (const DLGTEMPLATE*)dialog->handle, wnd, (DLGPROC) dialog_proc, (LPARAM) dialog);
- after_display_dialog(machine);
-}
-
-
-
-//============================================================
-// win_file_dialog
-// called from change_device
-//============================================================
-
-static BOOL win_file_dialog(running_machine &machine, HWND parent, win_file_dialog_type dlgtype, const char *filter,
- const char *initial_dir, char *filename, size_t filename_len)
-{
- win_open_file_name ofn;
- BOOL result = FALSE;
-
- // set up the OPENFILENAME data structure
- memset(&ofn, 0, sizeof(ofn));
- ofn.type = dlgtype;
- ofn.owner = parent;
- ofn.flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
- ofn.filter = filter;
- ofn.initial_directory = initial_dir;
-
- if (dlgtype == WIN_FILE_DIALOG_OPEN)
- ofn.flags |= OFN_FILEMUSTEXIST;
-
- snprintf(ofn.filename, ARRAY_LENGTH(ofn.filename), "%s", filename);
-
- before_display_dialog(machine);
- result = win_get_file_name_dialog(&ofn);
- after_display_dialog(machine);
-
- snprintf(filename, filename_len, "%s", ofn.filename);
- return result;
-}
-
-
-
-//============================================================
-// customise_input
-//============================================================
-
-static void customise_input(running_machine &machine, HWND wnd, const char *title, int player, int inputclass)
-{
- dialog_box *dlg;
- int this_inputclass, this_player;
-
- /* create the dialog */
- dlg = win_dialog_init(title, NULL);
- if (!dlg)
- return;
-
- for (auto &port : machine.ioport().ports())
- {
- for (ioport_field &field : port.second->fields())
- {
- /* add if we match the group and we have a valid name */
- const char *name = field.name();
- this_inputclass = field.type_class();
- this_player = field.player();
-
- if ((name)
- && (field.enabled())
-//check me && ((field->type() == IPT_OTHER && field->name()) || (machine.ioport().type_group(field->type(), field->player()) != IPG_INVALID))
- && (this_player == player)
- && (this_inputclass == inputclass))
- {
- if (win_dialog_add_portselect(dlg, &field))
- goto done;
- }
- }
- }
-
- /* ...and now add OK/Cancel */
- if (win_dialog_add_standard_buttons(dlg))
- goto done;
-
- /* ...and finally display the dialog */
- win_dialog_runmodal(machine, wnd, dlg);
-
-done:
- if (dlg)
- win_dialog_exit(dlg);
-}
-
-
-
-//============================================================
-// customise_joystick
-//============================================================
-
-static void customise_joystick(running_machine &machine, HWND wnd, int joystick_num)
-{
- customise_input(machine, wnd, "Joysticks/Controllers", joystick_num, INPUT_CLASS_CONTROLLER);
-}
-
-
-
-//============================================================
-// customise_keyboard
-//============================================================
-
-static void customise_keyboard(running_machine &machine, HWND wnd)
-{
- customise_input(machine, wnd, "Emulated Keyboard", 0, INPUT_CLASS_KEYBOARD);
-}
-
-
-
-//===============================================================================================
-// check_for_miscinput
-// (to decide if "Miscellaneous Inputs" menu item should show or not).
-// We do this here because the core check has been broken for years (always returns false).
-//===============================================================================================
-
-static bool check_for_miscinput(running_machine &machine)
-{
- int this_inputclass = 0;
-
- for (auto &port : machine.ioport().ports())
- {
- for (ioport_field &field : port.second->fields())
- {
- const char *name = field.name();
- this_inputclass = field.type_class();
-
- /* add if we match the group and we have a valid name */
- if ((name)
- && (field.enabled())
- && ((field.type() == IPT_OTHER && field.name()) || (machine.ioport().type_group(field.type(), field.player()) != IPG_INVALID))
- && (this_inputclass != INPUT_CLASS_CONTROLLER)
- && (this_inputclass != INPUT_CLASS_KEYBOARD))
- {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-
-
-//============================================================
-// customise_miscinput
-//============================================================
-
-static void customise_miscinput(running_machine &machine, HWND wnd)
-{
- dialog_box *dlg;
- int this_inputclass;
- const char *title = "Miscellaneous Inputs";
-
- /* create the dialog */
- dlg = win_dialog_init(title, NULL);
- if (!dlg)
- return;
-
- for (auto &port : machine.ioport().ports())
- {
- for (ioport_field &field : port.second->fields())
- {
- const char *name = field.name();
- this_inputclass = field.type_class();
-
- /* add if we match the group and we have a valid name */
- if ((name)
- && (field.enabled())
- && ((field.type() == IPT_OTHER && field.name()) || (machine.ioport().type_group(field.type(), field.player()) != IPG_INVALID))
- && (this_inputclass != INPUT_CLASS_CONTROLLER)
- && (this_inputclass != INPUT_CLASS_KEYBOARD))
- {
- if (win_dialog_add_portselect(dlg, &field))
- goto done;
- }
- }
- }
-
- /* ...and now add OK/Cancel */
- if (win_dialog_add_standard_buttons(dlg))
- goto done;
-
- /* ...and finally display the dialog */
- win_dialog_runmodal(machine, wnd, dlg);
-
-done:
- if (dlg)
- win_dialog_exit(dlg);
-}
-
-
-
-//============================================================
-// storeval_inputport
-// called from customise_switches
-//============================================================
-
-static void storeval_inputport(void *param, int val)
-{
- ioport_field *field = (ioport_field *) param;
- ioport_field::user_settings settings;
-
- field->get_user_settings(settings);
- settings.value = (ioport_value) val;
- field->set_user_settings(settings);
-}
-
-
-
-//============================================================
-// customise_switches
-//============================================================
-
-static void customise_switches(running_machine &machine, HWND wnd, const char* title_string, UINT32 ipt_name)
-{
- dialog_box *dlg;
- ioport_field *afield;
- ioport_setting *setting;
- const char *switch_name = NULL;
- ioport_field::user_settings settings;
-
- UINT32 type = 0;
-
- dlg = win_dialog_init(title_string, NULL);
- if (!dlg)
- return;
-
- for (auto &port : machine.ioport().ports())
- {
- for (ioport_field &field : port.second->fields())
- {
- type = field.type();
-
- if (type == ipt_name)
- {
- switch_name = field.name();
-
- field.get_user_settings(settings);
- afield = &field;
- if (win_dialog_add_combobox(dlg, switch_name, settings.value, storeval_inputport, (void *) afield))
- goto done;
-
- for (setting = field.settings().first(); setting; setting = setting->next())
- {
- if (win_dialog_add_combobox_item(dlg, setting->name(), setting->value()))
- goto done;
- }
- }
- }
- }
-
- if (win_dialog_add_standard_buttons(dlg))
- goto done;
-
- win_dialog_runmodal(machine, wnd, dlg);
-
-done:
- if (dlg)
- win_dialog_exit(dlg);
-}
-
-
-
-//============================================================
-// customise_dipswitches
-//============================================================
-
-static void customise_dipswitches(running_machine &machine, HWND wnd)
-{
- customise_switches(machine, wnd, "Dip Switches", IPT_DIPSWITCH);
-}
-
-
-
-//============================================================
-// customise_configuration
-//============================================================
-
-static void customise_configuration(running_machine &machine, HWND wnd)
-{
- customise_switches(machine, wnd, "Driver Configuration", IPT_CONFIG);
-}
-
-
-
-//============================================================
-// customise_analogcontrols
-//============================================================
-
-enum
-{
- ANALOG_ITEM_KEYSPEED,
- ANALOG_ITEM_CENTERSPEED,
- ANALOG_ITEM_REVERSE,
- ANALOG_ITEM_SENSITIVITY
-};
-
-
-
-static void store_analogitem(void *param, int val, int selected_item)
-{
- ioport_field *field = (ioport_field *) param;
- ioport_field::user_settings settings;
-
- field->get_user_settings(settings);
-
- switch(selected_item)
- {
- case ANALOG_ITEM_KEYSPEED:
- settings.delta = val;
- break;
- case ANALOG_ITEM_CENTERSPEED:
- settings.centerdelta = val;
- break;
- case ANALOG_ITEM_REVERSE:
- settings.reverse = val;
- break;
- case ANALOG_ITEM_SENSITIVITY:
- settings.sensitivity = val;
- break;
- }
- field->set_user_settings(settings);
-}
-
-
-
-static void store_delta(void *param, int val)
-{
- store_analogitem(param, val, ANALOG_ITEM_KEYSPEED);
-}
-
-
-
-static void store_centerdelta(void *param, int val)
-{
- store_analogitem(param, val, ANALOG_ITEM_CENTERSPEED);
-}
-
-
-
-static void store_reverse(void *param, int val)
-{
- store_analogitem(param, val, ANALOG_ITEM_REVERSE);
-}
-
-
-
-static void store_sensitivity(void *param, int val)
-{
- store_analogitem(param, val, ANALOG_ITEM_SENSITIVITY);
-}
-
-
-
-static int port_type_is_analog(int type)
-{
- return (type > IPT_ANALOG_FIRST && type < IPT_ANALOG_LAST);
-}
-
-
-
-static void customise_analogcontrols(running_machine &machine, HWND wnd)
-{
- dialog_box *dlg;
- ioport_field::user_settings settings;
- ioport_field *afield;
- const char *name;
- char buf[255];
- static const struct dialog_layout layout = { 120, 52 };
-
- dlg = win_dialog_init("Analog Controls", &layout);
- if (!dlg)
- return;
-
- for (auto &port : machine.ioport().ports())
- {
- for (ioport_field &field : port.second->fields())
- {
- if (port_type_is_analog(field.type()))
- {
- field.get_user_settings(settings);
- name = field.name();
- afield = &field;
-
- _snprintf(buf, ARRAY_LENGTH(buf), "%s %s", name, "Digital Speed");
- if (win_dialog_add_adjuster(dlg, buf, settings.delta, 1, 255, FALSE, store_delta, (void *) afield))
- goto done;
-
- _snprintf(buf, ARRAY_LENGTH(buf), "%s %s", name, "Autocenter Speed");
- if (win_dialog_add_adjuster(dlg, buf, settings.centerdelta, 0, 255, FALSE, store_centerdelta, (void *) afield))
- goto done;
-
- _snprintf(buf, ARRAY_LENGTH(buf), "%s %s", name, "Reverse");
- if (win_dialog_add_combobox(dlg, buf, settings.reverse ? 1 : 0, store_reverse, (void *) afield))
- goto done;
- if (win_dialog_add_combobox_item(dlg, "Off", 0))
- goto done;
- if (win_dialog_add_combobox_item(dlg, "On", 1))
- goto done;
-
- _snprintf(buf, ARRAY_LENGTH(buf), "%s %s", name, "Sensitivity");
- if (win_dialog_add_adjuster(dlg, buf, settings.sensitivity, 1, 255, TRUE, store_sensitivity, (void *) afield))
- goto done;
- }
- }
- }
-
- if (win_dialog_add_standard_buttons(dlg))
- goto done;
-
- win_dialog_runmodal(machine, wnd, dlg);
-
-done:
- if (dlg)
- win_dialog_exit(dlg);
-}
-
-
-//============================================================
-// win_dirname
-// called from state_dialog
-//============================================================
-
-static char *win_dirname(const char *filename)
-{
- char *dirname;
- char *c;
-
- // NULL begets NULL
- if (!filename)
- return NULL;
-
- // allocate space for it
- dirname = (char*)malloc(strlen(filename) + 1);
- if (!dirname)
- return NULL;
-
- // copy in the name
- strcpy(dirname, filename);
-
- // search backward for a slash or a colon
- for (c = dirname + strlen(dirname) - 1; c >= dirname; c--)
- if (*c == '\\' || *c == '/' || *c == ':')
- {
- // found it: NULL terminate and return
- *(c + 1) = 0;
- return dirname;
- }
-
- // otherwise, return an empty string
- dirname[0] = 0;
- return dirname;
-}
-
-
-//============================================================
-// state_dialog
-// called when loading or saving a state
-//============================================================
-
-static void state_dialog(HWND wnd, win_file_dialog_type dlgtype, DWORD fileproc_flags, bool is_load, running_machine &machine)
-{
- win_open_file_name ofn;
- char *dir = NULL;
- int result = 0;
-
- if (state_filename[0])
- dir = win_dirname(state_filename);
-
- memset(&ofn, 0, sizeof(ofn));
- ofn.type = dlgtype;
- ofn.owner = wnd;
- ofn.flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | fileproc_flags;
- ofn.filter = "State Files (*.sta)|*.sta|All Files (*.*)|*.*";
- ofn.initial_directory = dir;
-
- if (!core_filename_ends_with(ofn.filename, "sta"))
- snprintf(ofn.filename, ARRAY_LENGTH(ofn.filename), "%s.sta", state_filename);
- else
- snprintf(ofn.filename, ARRAY_LENGTH(ofn.filename), "%s", state_filename);
-
- result = win_get_file_name_dialog(&ofn);
-
- if (result)
- {
- // the core doesn't add the extension if it's an absolute path
- if (osd_is_absolute_path(ofn.filename) && !core_filename_ends_with(ofn.filename, "sta"))
- snprintf(state_filename, ARRAY_LENGTH(state_filename), "%s.sta", ofn.filename);
- else
- snprintf(state_filename, ARRAY_LENGTH(state_filename), "%s", ofn.filename);
-
- if (is_load)
- machine.schedule_load(state_filename);
- else
- machine.schedule_save(state_filename);
- }
-
- if (dir)
- free(dir);
-}
-
-
-
-static void state_load(HWND wnd, running_machine &machine)
-{
- state_dialog(wnd, WIN_FILE_DIALOG_OPEN, OFN_FILEMUSTEXIST, TRUE, machine);
-}
-
-static void state_save_as(HWND wnd, running_machine &machine)
-{
- state_dialog(wnd, WIN_FILE_DIALOG_SAVE, OFN_OVERWRITEPROMPT, FALSE, machine);
-}
-
-static void state_save(running_machine &machine)
-{
- machine.schedule_save(state_filename);
-}
-
-
-
-//============================================================
-// copy_extension_list
-//============================================================
-
-static void copy_extension_list(std::string &dest, const char *extensions)
-{
- // our extension lists are comma delimited; Win32 expects to see lists
- // delimited by semicolons
- char const *s = extensions;
- while (*s)
- {
- // append a semicolon if not at the beginning
- if (s != extensions)
- dest.push_back(';');
-
- // append ".*"
- dest.append("*.");
-
- // append the file extension
- while (*s && (*s != ','))
- dest.push_back(*s++);
-
- // if we found a comma, advance
- while(*s == ',')
- s++;
- }
-}
-
-
-
-//============================================================
-// add_filter_entry
-//============================================================
-
-static void add_filter_entry(std::string &dest, const char *description, const char *extensions)
-{
- // add the description
- dest.append(description);
- dest.append(" (");
-
- // add the extensions to the description
- copy_extension_list(dest, extensions);
-
- // add the trailing rparen and '|' character
- dest.append(")|");
-
- // now add the extension list itself
- copy_extension_list(dest, extensions);
-
- // append a '|'
- dest.append("|");
-}
-
-
-
-//============================================================
-// build_generic_filter
-//============================================================
-
-static void build_generic_filter(device_image_interface *img, bool is_save, std::string &filter)
-{
- std::string file_extension = img->file_extensions();
-
- if (!is_save)
- file_extension.append(",zip,7z");
-
- add_filter_entry(filter, "Common image types", file_extension.c_str());
-
- filter.append("All files (*.*)|*.*|");
-
- if (!is_save)
- filter.append("Compressed Images (*.zip;*.7z)|*.zip;*.7z|");
-}
-
-
-
-//============================================================
-// change_device
-// open a dialog box to open or create a software file
-//============================================================
-
-static void change_device(HWND wnd, device_image_interface *image, bool is_save)
-{
- std::string filter;
- char filename[MAX_PATH];
- const char *initial_dir;
- BOOL result = 0;
- int create_format = 0;
- util::option_resolution *create_args = NULL;
-
- // get the file
- if (image->exists())
- {
- const char *imgname;
- imgname = image->basename();
- snprintf(filename, ARRAY_LENGTH(filename), "%s", imgname);
- }
- else
- filename[0] = '\0';
-
- // get the working directory, but if it is ".", then use the one specified in swpath
- char *working = 0;
- std::string dst;
- osd_get_full_path(dst,"."); // turn local directory into full path
- initial_dir = image->working_directory().c_str(); // get working directory from diimage.cpp
- // if . use swpath
- if (strcmp(dst.c_str(), initial_dir) == 0) // same?
- initial_dir = software_dir;
-
- // remove any trailing backslash
- working = core_strdup(initial_dir);
- int temp = strlen(working) - 1;
- if (temp > 2)
- if (working[temp] == '\\')
- {
- working[temp] = '\0';
- initial_dir = working;
- }
-
-// NOTE: the working directory can come from the .cfg file. If it's wrong delete the cfg.
-//printf("%s = %s = %s = %s\n",dst,working,initial_dir,software_dir);
-
- // build a normal filter
- build_generic_filter(image, is_save, filter);
-
- // display the dialog
- result = win_file_dialog(image->device().machine(), wnd, is_save ? WIN_FILE_DIALOG_SAVE : WIN_FILE_DIALOG_OPEN, filter.c_str(), initial_dir, filename, ARRAY_LENGTH(filename));
- if (result)
- {
- // mount the image
- if (is_save)
- (image_error_t)image->create(filename, image->device_get_indexed_creatable_format(create_format), create_args);
- else
- (image_error_t)image->load( filename);
-
- // no need to check the returnvalue and show a messagebox anymore.
- // a UI message will now be generated by the image code
- }
-}
-
-
-
-//============================================================
-// pause
-//============================================================
-
-static void pause(running_machine &machine)
-{
- if (!winwindow_ui_is_paused(machine))
- machine.pause();
- else
- machine.resume();
-}
-
-
-
-//============================================================
-// get_menu_item_string
-//============================================================
-
-static BOOL get_menu_item_string(HMENU menu, UINT item, BOOL by_position, HMENU *sub_menu, LPTSTR buffer, size_t buffer_len)
-{
- MENUITEMINFO mii;
-
- // clear out results
- memset(buffer, '\0', sizeof(*buffer) * buffer_len);
- if (sub_menu)
- *sub_menu = NULL;
-
- // prepare MENUITEMINFO structure
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_TYPE | (sub_menu ? MIIM_SUBMENU : 0);
- mii.dwTypeData = buffer;
- mii.cch = buffer_len;
-
- // call GetMenuItemInfo()
- if (!GetMenuItemInfo(menu, item, by_position, &mii))
- return FALSE;
-
- // return results
- if (sub_menu)
- *sub_menu = mii.hSubMenu;
- if (mii.fType == MFT_SEPARATOR)
- _sntprintf(buffer, buffer_len, TEXT("-"));
- return TRUE;
-}
-
-
-
-//============================================================
-// find_sub_menu
-//============================================================
-
-static HMENU find_sub_menu(HMENU menu, const char *menutext, bool create_sub_menu)
-{
- TCHAR buf[128];
- HMENU sub_menu;
-
- while(*menutext)
- {
- TCHAR *t_menutext = ui_wstring_from_utf8(menutext);
-
- int i = -1;
- do
- {
- if (!get_menu_item_string(menu, ++i, TRUE, &sub_menu, buf, ARRAY_LENGTH(buf)))
- {
- free(t_menutext);
- return NULL;
- }
- }
- while(_tcscmp(t_menutext, buf));
-
- free(t_menutext);
-
- if (!sub_menu && create_sub_menu)
- {
- MENUITEMINFO mii;
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_SUBMENU;
- mii.hSubMenu = CreateMenu();
- if (!SetMenuItemInfo(menu, i, TRUE, &mii))
- {
- i = GetLastError();
- return NULL;
- }
- sub_menu = mii.hSubMenu;
- }
- menu = sub_menu;
- if (!menu)
- return NULL;
- menutext += strlen(menutext) + 1;
- }
- return menu;
-}
-
-
-
-//============================================================
-// set_command_state
-//============================================================
-
-static void set_command_state(HMENU menu_bar, UINT command, UINT state)
-{
- BOOL result = 0;
-
- MENUITEMINFO mii;
-
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STATE;
- mii.fState = state;
- result = SetMenuItemInfo(menu_bar, command, FALSE, &mii);
- result++;
-}
-
-
-
-
-//============================================================
-// remove_menu_items
-//============================================================
-
-static void remove_menu_items(HMENU menu)
-{
- while(RemoveMenu(menu, 0, MF_BYPOSITION))
- ;
-}
-
-
-
-//============================================================
-// setup_joystick_menu
-//============================================================
-
-static void setup_joystick_menu(running_machine &machine, HMENU menu_bar)
-{
- int joystick_count = 0;
- HMENU joystick_menu;
- int i = 0;
- char buf[256];
- int child_count = 0;
-
- joystick_menu = find_sub_menu(menu_bar, "&Options\0&Joysticks\0", TRUE);
- if (!joystick_menu)
- return;
-
- // set up joystick menu
- joystick_count = machine.ioport().count_players();
- if (joystick_count > 0)
- {
- for (i = 0; i < joystick_count; i++)
- {
- snprintf(buf, ARRAY_LENGTH(buf), "Joystick %i", i + 1);
- win_append_menu_utf8(joystick_menu, MF_STRING, ID_JOYSTICK_0 + i, buf);
- child_count++;
- }
- }
-
- // last but not least, enable the joystick menu (or not)
- set_command_state(menu_bar, ID_OPTIONS_JOYSTICKS, child_count ? MFS_ENABLED : MFS_GRAYED);
-}
-
-
-
-//============================================================
-// is_windowed
-//============================================================
-
-static int is_windowed(void)
-{
- return video_config.windowed;
-}
-
-
-
-//============================================================
-// frameskip_level_count
-//============================================================
-
-static int frameskip_level_count(running_machine &machine)
-{
- static int count = -1;
-
- if (count < 0)
- {
- int frameskip_max = 10;
- count = frameskip_max + 1;
- }
- return count;
-}
-
-
-
-//============================================================
-// prepare_menus
-//============================================================
-
-static void prepare_menus(HWND wnd)
-{
- int i = 0;
- char buf[MAX_PATH];
- TCHAR t_buf[MAX_PATH];
- const char *s;
- HMENU menu_bar;
- HMENU video_menu;
- HMENU device_menu;
- HMENU sub_menu;
- UINT_PTR new_item;
- UINT flags_for_exists = 0;
- UINT flags_for_writing = 0;
- bool has_config = 0, has_dipswitch = 0, has_keyboard = 0, has_misc = 0, has_analog = 0;
- int frameskip = 0;
- int orientation = 0;
- int speed = 0;
- LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA);
- win_window_info *window = (win_window_info *)ptr;
- const char *view_name;
- int view_index = 0;
- ioport_field::user_settings settings;
-
- menu_bar = GetMenu(wnd);
- if (!menu_bar)
- return;
-
- if (!joystick_menu_setup)
- {
- setup_joystick_menu(window->machine(), menu_bar);
- joystick_menu_setup = 1;
- }
-
- frameskip = window->machine().video().frameskip();
-
- orientation = window->m_target->orientation();
-
- speed = window->machine().video().throttled() ? window->machine().video().speed_factor() : 0;
-
- has_config = window->machine().ioport().type_class_present(INPUT_CLASS_CONFIG);
- has_dipswitch = window->machine().ioport().type_class_present(INPUT_CLASS_DIPSWITCH);
- has_keyboard = window->machine().ioport().type_class_present(INPUT_CLASS_KEYBOARD);
- has_misc = check_for_miscinput(window->machine());
-
- has_analog = 0;
- for (auto &port : window->machine().ioport().ports())
- {
- for (ioport_field &field : port.second->fields())
- {
- if (port_type_is_analog(field.type()))
- {
- has_analog = 1;
- break;
- }
- }
- }
-
- if (window->machine().system().flags & MACHINE_SUPPORTS_SAVE)
- {
- set_command_state(menu_bar, ID_FILE_LOADSTATE_NEWUI, MFS_ENABLED);
- set_command_state(menu_bar, ID_FILE_SAVESTATE_AS, MFS_ENABLED);
- set_command_state(menu_bar, ID_FILE_SAVESTATE, state_filename[0] != '\0' ? MFS_ENABLED : MFS_GRAYED);
- }
- else
- {
- set_command_state(menu_bar, ID_FILE_LOADSTATE_NEWUI, MFS_GRAYED);
- set_command_state(menu_bar, ID_FILE_SAVESTATE_AS, MFS_GRAYED);
- set_command_state(menu_bar, ID_FILE_SAVESTATE, MFS_GRAYED);
- }
-
- set_command_state(menu_bar, ID_EDIT_PASTE, window->machine().ioport().natkeyboard().can_post() ? MFS_ENABLED : MFS_GRAYED);
-
- set_command_state(menu_bar, ID_OPTIONS_PAUSE, winwindow_ui_is_paused(window->machine()) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_OPTIONS_CONFIGURATION, has_config ? MFS_ENABLED : MFS_GRAYED);
- set_command_state(menu_bar, ID_OPTIONS_DIPSWITCHES, has_dipswitch ? MFS_ENABLED : MFS_GRAYED);
- set_command_state(menu_bar, ID_OPTIONS_MISCINPUT, has_misc ? MFS_ENABLED : MFS_GRAYED);
- set_command_state(menu_bar, ID_OPTIONS_ANALOGCONTROLS, has_analog ? MFS_ENABLED : MFS_GRAYED);
- set_command_state(menu_bar, ID_FILE_FULLSCREEN, !is_windowed() ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_OPTIONS_TOGGLEFPS, mame_machine_manager::instance()->ui().show_fps() ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_FILE_UIACTIVE, has_keyboard ? (window->machine().ui_active() ? MFS_CHECKED : MFS_ENABLED): MFS_CHECKED | MFS_GRAYED);
-
- set_command_state(menu_bar, ID_KEYBOARD_EMULATED, has_keyboard ? (!window->machine().ioport().natkeyboard().in_use() ? MFS_CHECKED : MFS_ENABLED): MFS_GRAYED);
- set_command_state(menu_bar, ID_KEYBOARD_NATURAL, (has_keyboard && window->machine().ioport().natkeyboard().can_post()) ? (window->machine().ioport().natkeyboard().in_use() ? MFS_CHECKED : MFS_ENABLED): MFS_GRAYED);
- set_command_state(menu_bar, ID_KEYBOARD_CUSTOMIZE, has_keyboard ? MFS_ENABLED : MFS_GRAYED);
-
- set_command_state(menu_bar, ID_VIDEO_ROTATE_0, (orientation == ROT0) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_VIDEO_ROTATE_90, (orientation == ROT90) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_VIDEO_ROTATE_180, (orientation == ROT180) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_VIDEO_ROTATE_270, (orientation == ROT270) ? MFS_CHECKED : MFS_ENABLED);
-
- set_command_state(menu_bar, ID_THROTTLE_50, (speed == 500) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_THROTTLE_100, (speed == 1000) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_THROTTLE_200, (speed == 2000) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_THROTTLE_500, (speed == 5000) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_THROTTLE_1000, (speed == 10000) ? MFS_CHECKED : MFS_ENABLED);
- set_command_state(menu_bar, ID_THROTTLE_UNTHROTTLED, (speed == 0) ? MFS_CHECKED : MFS_ENABLED);
-
- set_command_state(menu_bar, ID_FRAMESKIP_AUTO, (frameskip < 0) ? MFS_CHECKED : MFS_ENABLED);
- for (i = 0; i < frameskip_level_count(window->machine()); i++)
- set_command_state(menu_bar, ID_FRAMESKIP_0 + i, (frameskip == i) ? MFS_CHECKED : MFS_ENABLED);
-
- // set up screens in video menu
- video_menu = find_sub_menu(menu_bar, "&Options\0&Video\0", FALSE);
- do
- {
- get_menu_item_string(video_menu, 0, TRUE, NULL, t_buf, ARRAY_LENGTH(t_buf));
- if (_tcscmp(t_buf, TEXT("-")))
- RemoveMenu(video_menu, 0, MF_BYPOSITION);
- }
- while(_tcscmp(t_buf, TEXT("-")));
- i = 0;
- view_index = window->m_target->view();
- while((view_name = window->m_target->view_name(i)))
- {
- TCHAR *t_view_name = ui_wstring_from_utf8(view_name);
- InsertMenu(video_menu, i, MF_BYPOSITION | (i == view_index ? MF_CHECKED : 0), ID_VIDEO_VIEW_0 + i, t_view_name);
- free(t_view_name);
- i++;
- }
-
- // set up device menu; first remove all existing menu items
- device_menu = find_sub_menu(menu_bar, "&Media\0", FALSE);
- remove_menu_items(device_menu);
-
- int cnt = 0;
- // then set up the actual devices
- for (device_image_interface &img : image_interface_iterator(window->machine().root_device()))
- {
- new_item = ID_DEVICE_0 + (cnt * DEVOPTION_MAX);
- flags_for_exists = MF_STRING;
-
- if (!img.exists())
- flags_for_exists |= MF_GRAYED;
-
- flags_for_writing = flags_for_exists;
- if (img.is_readonly())
- flags_for_writing |= MF_GRAYED;
-
- sub_menu = CreateMenu();
- win_append_menu_utf8(sub_menu, MF_STRING, new_item + DEVOPTION_OPEN, "Mount File...");
-
- if (img.is_creatable())
- win_append_menu_utf8(sub_menu, MF_STRING, new_item + DEVOPTION_CREATE, "Create...");
-
- win_append_menu_utf8(sub_menu, flags_for_exists, new_item + DEVOPTION_CLOSE, "Unmount");
-
- if (img.device().type() == CASSETTE)
- {
- cassette_state state;
- state = (cassette_state)(img.exists() ? (dynamic_cast<cassette_image_device*>(&img.device())->get_state() & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED);
- win_append_menu_utf8(sub_menu, MF_SEPARATOR, 0, NULL);
- win_append_menu_utf8(sub_menu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, "Pause/Stop");
- win_append_menu_utf8(sub_menu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, "Play");
- win_append_menu_utf8(sub_menu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, "Record");
- win_append_menu_utf8(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_REWIND, "Rewind");
- win_append_menu_utf8(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, "Fast Forward");
- }
- s = img.exists() ? img.filename() : "[empty slot]";
-
- snprintf(buf, ARRAY_LENGTH(buf), "%s: %s", img.device().name(), s);
- win_append_menu_utf8(device_menu, MF_POPUP, (UINT_PTR)sub_menu, buf);
-
- cnt++;
- }
-}
-
-
-
-//============================================================
-// set_speed
-//============================================================
-
-static void set_speed(running_machine &machine, int speed)
-{
- std::string error_string;
- if (speed != 0)
- {
- machine.video().set_speed_factor(speed);
- machine.options().emu_options::set_value(OPTION_SPEED, speed / 1000, OPTION_PRIORITY_CMDLINE, error_string);
- }
-
- machine.video().set_throttled(speed != 0);
- machine.options().emu_options::set_value(OPTION_THROTTLE, (speed != 0), OPTION_PRIORITY_CMDLINE, error_string);
-}
-
-
-
-//============================================================
-// win_toggle_menubar
-//============================================================
-
-static void win_toggle_menubar(void)
-{
- LONG width_diff = 0;
- LONG height_diff = 0;
- DWORD style = 0, exstyle = 0;
- HWND hwnd = 0;
- HMENU menu = 0;
-
- for (auto window : osd_common_t::s_window_list)
- {
- RECT before_rect = { 100, 100, 200, 200 };
- RECT after_rect = { 100, 100, 200, 200 };
-
- hwnd = std::static_pointer_cast<win_window_info>(window)->platform_window();
-
- // get current menu
- menu = GetMenu(hwnd);
-
- // get before rect
- style = GetWindowLong(hwnd, GWL_STYLE);
- exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
- AdjustWindowRectEx(&before_rect, style, menu ? TRUE : FALSE, exstyle);
-
- // toggle the menu
- if (menu)
- {
- SetProp(hwnd, TEXT("menu"), (HANDLE) menu);
- menu = NULL;
- }
- else
- menu = (HMENU) GetProp(hwnd, TEXT("menu"));
-
- SetMenu(hwnd, menu);
-
- // get after rect, and width/height diff
- AdjustWindowRectEx(&after_rect, style, menu ? TRUE : FALSE, exstyle);
- width_diff = (after_rect.right - after_rect.left) - (before_rect.right - before_rect.left);
- height_diff = (after_rect.bottom - after_rect.top) - (before_rect.bottom - before_rect.top);
-
- if (is_windowed())
- {
- RECT window_rect;
- GetWindowRect(hwnd, &window_rect);
- SetWindowPos(hwnd, HWND_TOP, 0, 0, window_rect.right - window_rect.left + width_diff, window_rect.bottom - window_rect.top + height_diff, SWP_NOMOVE | SWP_NOZORDER);
- }
-
- RedrawWindow(hwnd, NULL, NULL, 0);
- }
-}
-
-
-
-//============================================================
-// device_command
-// This handles all options under the "Media" dropdown
-//============================================================
-
-static void device_command(HWND wnd, device_image_interface *img, int devoption)
-{
- switch(devoption)
- {
- case DEVOPTION_OPEN:
- change_device(wnd, img, FALSE);
- break;
-
- case DEVOPTION_CREATE:
- change_device(wnd, img, TRUE);
- break;
-
- case DEVOPTION_CLOSE:
- img->unload();
- break;
-
- default:
- if (img->device().type() == CASSETTE)
- {
- cassette_image_device* cassette = dynamic_cast<cassette_image_device*>(&img->device());
-
- switch(devoption)
- {
- case DEVOPTION_CASSETTE_STOPPAUSE:
- cassette->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
- break;
-
- case DEVOPTION_CASSETTE_PLAY:
- cassette->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
- break;
-
- case DEVOPTION_CASSETTE_RECORD:
- cassette->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
- break;
-
- case DEVOPTION_CASSETTE_REWIND:
- cassette->seek(-60.0, SEEK_CUR);
- break;
-
- case DEVOPTION_CASSETTE_FASTFORWARD:
- cassette->seek(+60.0, SEEK_CUR);
- break;
- }
- }
- break;
- }
-}
-
-
-
-//============================================================
-// help_display
-//============================================================
-
-static void help_display(HWND wnd, const char *chapter)
-{
- typedef HWND (WINAPI *htmlhelpproc)(HWND hwndCaller, LPCTSTR pszFile, UINT uCommand, DWORD_PTR dwData);
- static htmlhelpproc htmlhelp;
- static DWORD htmlhelp_cookie;
- LPCSTR htmlhelp_funcname;
-
- if (htmlhelp == NULL)
- {
-#ifdef UNICODE
- htmlhelp_funcname = "HtmlHelpW";
-#else
- htmlhelp_funcname = "HtmlHelpA";
-#endif
- htmlhelp = (htmlhelpproc) GetProcAddress(LoadLibrary(TEXT("hhctrl.ocx")), htmlhelp_funcname);
- if (!htmlhelp)
- return;
- htmlhelp(NULL, NULL, 28 /*HH_INITIALIZE*/, (DWORD_PTR) &htmlhelp_cookie);
- }
-
- // if full screen, turn it off
- if (!is_windowed())
- winwindow_toggle_full_screen();
-
- TCHAR *t_chapter = ui_wstring_from_utf8(chapter);
-// htmlhelp(wnd, t_chapter, 0 /*HH_DISPLAY_TOPIC*/, 0);
-// TCHAR *szSite = new TCHAR[100];
-// _tcscpy(szSite, TEXT("http://messui.the-chronicles.org/onlinehelp/"));
-// _tcscat(szSite, t_chapter);
-// _tcscat(szSite, TEXT(".html"));
-// ShellExecute(wnd, TEXT("open"), TEXT("http://www.microsoft.com/directx"), TEXT(""), NULL, SW_SHOWNORMAL);
- ShellExecute(wnd, TEXT("open"), t_chapter, TEXT(""), NULL, SW_SHOWNORMAL);
- free(t_chapter);
-// free(szSite);
-}
-
-
-
-//============================================================
-// help_about_mess
-//============================================================
-
-static void help_about_mess(HWND wnd)
-{
- //help_display(wnd, "mess.chm::/windows/main.htm"); //doesnt do anything
- //help_display(wnd, "mess.chm");
- help_display(wnd, "http://mamedev.org/");
-}
-
-
-
-//============================================================
-// help_about_thissystem
-//============================================================
-
-static void help_about_thissystem(running_machine &machine, HWND wnd)
-{
- char buf[100];
-// snprintf(buf, ARRAY_LENGTH(buf), "mess.chm::/sysinfo/%s.htm", machine.system().name);
-// snprintf(buf, ARRAY_LENGTH(buf), "http://messui.the-chronicles.org/onlinehelp/%s.html", machine.system().name);
- snprintf(buf, ARRAY_LENGTH(buf), "http://www.progettoemma.net/mess/system.php?machine=%s", machine.system().name);
- help_display(wnd, buf);
-}
-
-
-
-//============================================================
-// decode_deviceoption
-//============================================================
-
-static device_image_interface *decode_deviceoption(running_machine &machine, int command, int *devoption)
-{
- command -= ID_DEVICE_0;
- int absolute_index = command / DEVOPTION_MAX;
-
- if (devoption)
- *devoption = command % DEVOPTION_MAX;
-
- image_interface_iterator iter(machine.root_device());
- return iter.byindex(absolute_index);
-}
-
-
-
-//============================================================
-// set_window_orientation
-//============================================================
-
-static void set_window_orientation(win_window_info *window, int orientation)
-{
- window->m_target->set_orientation(orientation);
- if (window->m_target->is_ui_target())
- {
- render_container::user_settings settings;
- window->machine().render().ui_container().get_user_settings(settings);
- settings.m_orientation = orientation;
- window->machine().render().ui_container().set_user_settings(settings);
- }
- window->update();
-}
-
-
-
-//============================================================
-// pause_for_command
-//============================================================
-
-static int pause_for_command(UINT command)
-{
- // we really should be more conservative and only pause for commands
- // that do dialog stuff
- return (command != ID_OPTIONS_PAUSE);
-}
-
-
-
-//============================================================
-// invoke_command
-//============================================================
-
-static bool invoke_command(HWND wnd, UINT command)
-{
- std::string error_string;
- bool handled = TRUE;
- int dev_command = 0;
- device_image_interface *img;
- LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA);
- win_window_info *window = (win_window_info *)ptr;
- ioport_field::user_settings settings;
-
- // pause while invoking certain commands
- if (pause_for_command(command))
- winwindow_ui_pause(window->machine(), TRUE);
-
- switch(command)
- {
- case ID_FILE_LOADSTATE_NEWUI:
- state_load(wnd, window->machine());
- break;
-
- case ID_FILE_SAVESTATE:
- state_save(window->machine());
- break;
-
- case ID_FILE_SAVESTATE_AS:
- state_save_as(wnd, window->machine());
- break;
-
- case ID_FILE_SAVESCREENSHOT:
- window->machine().video().save_active_screen_snapshots();
- break;
-
- case ID_FILE_UIACTIVE:
- window->machine().set_ui_active(!window->machine().ui_active());
- break;
-
- case ID_FILE_EXIT_NEWUI:
- window->machine().schedule_exit();
- break;
-
- case ID_EDIT_PASTE:
- PostMessage(wnd, WM_PASTE, 0, 0);
- break;
-
- case ID_KEYBOARD_NATURAL:
- window->machine().ioport().natkeyboard().set_in_use(TRUE);
- break;
-
- case ID_KEYBOARD_EMULATED:
- window->machine().ioport().natkeyboard().set_in_use(FALSE);
- break;
-
- case ID_KEYBOARD_CUSTOMIZE:
- customise_keyboard(window->machine(), wnd);
- break;
-
- case ID_VIDEO_ROTATE_0:
- set_window_orientation(window, ROT0);
- break;
-
- case ID_VIDEO_ROTATE_90:
- set_window_orientation(window, ROT90);
- break;
-
- case ID_VIDEO_ROTATE_180:
- set_window_orientation(window, ROT180);
- break;
-
- case ID_VIDEO_ROTATE_270:
- set_window_orientation(window, ROT270);
- break;
-
- case ID_OPTIONS_PAUSE:
- pause(window->machine());
- break;
-
- case ID_OPTIONS_HARDRESET:
- window->machine().schedule_hard_reset();
- break;
-
- case ID_OPTIONS_SOFTRESET:
- window->machine().schedule_soft_reset();
- break;
-
- case ID_OPTIONS_CONFIGURATION:
- customise_configuration(window->machine(), wnd);
- break;
-
- case ID_OPTIONS_DIPSWITCHES:
- customise_dipswitches(window->machine(), wnd);
- break;
-
- case ID_OPTIONS_MISCINPUT:
- customise_miscinput(window->machine(), wnd);
- break;
-
- case ID_OPTIONS_ANALOGCONTROLS:
- customise_analogcontrols(window->machine(), wnd);
- break;
-
- case ID_FILE_OLDUI:
- mame_machine_manager::instance()->ui().show_menu();
- break;
-
- case ID_FILE_FULLSCREEN:
- winwindow_toggle_full_screen();
- break;
-
- case ID_OPTIONS_TOGGLEFPS:
- mame_machine_manager::instance()->ui().set_show_fps(!mame_machine_manager::instance()->ui().show_fps());
- break;
-
- case ID_OPTIONS_USEMOUSE:
- {
- // FIXME
-// extern int win_use_mouse;
-// win_use_mouse = !win_use_mouse;
- }
- break;
-
- case ID_FILE_TOGGLEMENUBAR:
- win_toggle_menubar();
- break;
-
- case ID_FRAMESKIP_AUTO:
- window->machine().video().set_frameskip(-1);
- window->machine().options().emu_options::set_value(OPTION_AUTOFRAMESKIP, 1, OPTION_PRIORITY_CMDLINE, error_string);
- break;
-
- case ID_HELP_ABOUT_NEWUI:
- help_about_mess(wnd);
- break;
-
- case ID_HELP_ABOUTSYSTEM:
- help_about_thissystem(window->machine(), wnd);
- break;
-
- case ID_THROTTLE_50:
- set_speed(window->machine(), 500);
- break;
-
- case ID_THROTTLE_100:
- set_speed(window->machine(), 1000);
- break;
-
- case ID_THROTTLE_200:
- set_speed(window->machine(), 2000);
- break;
-
- case ID_THROTTLE_500:
- set_speed(window->machine(), 5000);
- break;
-
- case ID_THROTTLE_1000:
- set_speed(window->machine(), 10000);
- break;
-
- case ID_THROTTLE_UNTHROTTLED:
- set_speed(window->machine(), 0);
- break;
-
- default:
- if ((command >= ID_FRAMESKIP_0) && (command < ID_FRAMESKIP_0 + frameskip_level_count(window->machine())))
- {
- // change frameskip
- window->machine().video().set_frameskip(command - ID_FRAMESKIP_0);
- window->machine().options().emu_options::set_value(OPTION_AUTOFRAMESKIP, 0, OPTION_PRIORITY_CMDLINE, error_string);
- window->machine().options().emu_options::set_value(OPTION_FRAMESKIP, (int)command - ID_FRAMESKIP_0, OPTION_PRIORITY_CMDLINE, error_string);
- }
- else
- if ((command >= ID_DEVICE_0) && (command < ID_DEVICE_0 + (IO_COUNT*DEVOPTION_MAX)))
- {
- // change device
- img = decode_deviceoption(window->machine(), command, &dev_command);
- device_command(wnd, img, dev_command);
- }
- else
- if ((command >= ID_JOYSTICK_0) && (command < ID_JOYSTICK_0 + MAX_JOYSTICKS))
- // customise joystick
- customise_joystick(window->machine(), wnd, command - ID_JOYSTICK_0);
- else
- if ((command >= ID_VIDEO_VIEW_0) && (command < ID_VIDEO_VIEW_0 + 1000))
- {
- // render views
- window->m_target->set_view(command - ID_VIDEO_VIEW_0);
- window->update(); // actually change window size
- }
- else
- // bogus command
- handled = FALSE;
-
- break;
- }
-
- // resume emulation
- if (pause_for_command(command))
- winwindow_ui_pause(window->machine(), FALSE);
-
- return handled;
-}
-
-
-
-//============================================================
-// set_menu_text
-//============================================================
-
-static void set_menu_text(HMENU menu_bar, int command, const char *text)
-{
- TCHAR *t_text;
- MENUITEMINFO mii;
-
- // convert to TCHAR
- t_text = ui_wstring_from_utf8(text);
-
- // invoke SetMenuItemInfo()
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_TYPE;
- mii.dwTypeData = t_text;
- SetMenuItemInfo(menu_bar, command, FALSE, &mii);
-
- // cleanup
- free(t_text);
-}
-
-
-
-//============================================================
-// win_setup_menus
-//============================================================
-
-static int win_setup_menus(running_machine &machine, HMODULE module, HMENU menu_bar)
-{
- HMENU frameskip_menu;
- char buf[256];
- int i = 0;
-
- // verify that our magic numbers work
- assert((ID_DEVICE_0 + IO_COUNT * DEVOPTION_MAX) < ID_JOYSTICK_0);
-
- // initialize critical values
- joystick_menu_setup = 0;
-
- // set up frameskip menu
- frameskip_menu = find_sub_menu(menu_bar, "&Options\0&Frameskip\0", FALSE);
-
- if (!frameskip_menu)
- return 1;
-
- for(i = 0; i < frameskip_level_count(machine); i++)
- {
- snprintf(buf, ARRAY_LENGTH(buf), "%i", i);
- win_append_menu_utf8(frameskip_menu, MF_STRING, ID_FRAMESKIP_0 + i, buf);
- }
-
- // set the help menu to refer to this machine
- snprintf(buf, ARRAY_LENGTH(buf), "About %s (%s)...", machine.system().description, machine.system().name);
- set_menu_text(menu_bar, ID_HELP_ABOUTSYSTEM, buf);
-
- // initialize state_filename for each driver, so we don't carry names in-between them
- {
- char *src;
- char *dst;
-
- snprintf(state_filename, ARRAY_LENGTH(state_filename), "%s State", machine.system().description);
-
- src = state_filename;
- dst = state_filename;
- do
- {
- if ((*src == '\0') || isalnum(*src) || isspace(*src) || strchr("(),.", *src))
- *(dst++) = *src;
- }
- while(*(src++));
- }
-
- return 0;
-}
-
-
-
-//============================================================
-// win_resource_module
-//============================================================
-
-static HMODULE win_resource_module(void)
-{
- static HMODULE module;
- if (module == NULL)
- {
- MEMORY_BASIC_INFORMATION info;
- if ((VirtualQuery((const void*)win_resource_module, &info, sizeof(info))) == sizeof(info))
- module = (HMODULE)info.AllocationBase;
- }
- return module;
-}
-
-///// Interface to the core /////
-
-//============================================================
-// win_create_menu
-//============================================================
-
-int win_create_menu(running_machine &machine, HMENU *menus)
-{
- // Get the path for loose software from <gamename>.ini
- // if this is invalid, then windows chooses whatever directory it used last.
- const char* t = machine.options().emu_options::sw_path();
- // This pulls out the first path from a multipath field
- const char* t1 = strtok((char*)t, ";");
- if (t1)
- software_dir = t1; // the first path of many
- else
- software_dir = t; // the only path
-
- // do not show in the mewui ui.
- if (strcmp(machine.system().name, "___empty") == 0)
- return 0;
-
- HMODULE module = win_resource_module();
- HMENU menu_bar = LoadMenu(module, MAKEINTRESOURCE(IDR_RUNTIME_MENU));
-
- if (!menu_bar)
- {
- printf("No memory for the menu, running without it.\n");
- return 0;
- }
-
- if (win_setup_menus(machine, module, menu_bar))
- {
- printf("Unable to setup the menu, running without it.\n");
- if (menu_bar)
- DestroyMenu(menu_bar);
- return 0; // return 1 causes a crash
- }
-
- *menus = menu_bar;
- return 0;
-}
-
-
-
-//============================================================
-// winwindow_video_window_proc_ui
-//============================================================
-
-LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
-{
- switch(message)
- {
- case WM_INITMENU:
- prepare_menus(wnd);
- break;
-
- case WM_PASTE:
- {
- mame_machine_manager::instance()->ui().paste();
- }
- break;
-
- case WM_COMMAND:
- if (invoke_command(wnd, wparam))
- break;
- /* fall through */
-
- default:
- return win_window_info::video_window_proc(wnd, message, wparam, lparam);
- }
- return 0;
-}
-
diff --git a/src/osd/winui/picker.cpp b/src/osd/winui/picker.cpp
index 894687b9a2f..5dfa9a24cf8 100644
--- a/src/osd/winui/picker.cpp
+++ b/src/osd/winui/picker.cpp
@@ -1,36 +1,23 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
// standard windows headers
#define _WIN32_IE 0x0501
#include <windows.h>
#include <windowsx.h>
-#include <shellapi.h>
#include <commctrl.h>
-#include <commdlg.h>
-#include <wingdi.h>
// standard C headers
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <time.h>
#include <tchar.h>
// MAME/MAMEUI headers
#include "picker.h"
#include "winui.h"
-#include "mui_util.h" // For dprintf
#include "mui_opts.h"
-#include "bitmask.h"
-#include "treeview.h" // For GetParentFound()
+#include "treeview.h"
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#endif
-
// fix warning: cast does not match function type
#if defined(__GNUC__) && defined(ListView_GetHeader)
#undef ListView_GetHeader
@@ -87,15 +74,13 @@ struct PickerInfo
static struct PickerInfo *GetPickerInfo(HWND hWnd)
{
- LONG_PTR l;
- l = GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ LONG_PTR l = GetWindowLongPtr(hWnd, GWLP_USERDATA);
return (struct PickerInfo *) l;
}
-static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc,
- HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT rc;
@@ -111,40 +96,34 @@ static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc,
static BOOL ListViewOnErase(HWND hWnd, HDC hDC)
{
- RECT rcClient;
- HRGN rgnBitmap;
- HPALETTE hPAL;
-
- int i, j;
- HDC htempDC;
- POINT ptOrigin;
- POINT pt = {0,0};
- HBITMAP hOldBitmap;
MYBITMAPINFO *pbmDesc = GetBackgroundInfo();
- HBITMAP hBackground = GetBackgroundBitmap();
- HPALETTE hPALbg = GetBackgroundPalette();
+ HBITMAP hBackground = GetBackgroundBitmap();
+ HPALETTE hPALbg = GetBackgroundPalette();
// this does not draw the background properly in report view
+ RECT rcClient;
GetClientRect(hWnd, &rcClient);
- htempDC = CreateCompatibleDC(hDC);
- hOldBitmap = (HBITMAP)SelectObject(htempDC, hBackground);
+ HDC htempDC = CreateCompatibleDC(hDC);
+ HBITMAP hOldBitmap = (HBITMAP)SelectObject(htempDC, hBackground);
- rgnBitmap = CreateRectRgnIndirect(&rcClient);
+ HRGN rgnBitmap = CreateRectRgnIndirect(&rcClient);
SelectClipRgn(hDC, rgnBitmap);
DeleteBitmap(rgnBitmap);
- hPAL = (!hPALbg) ? CreateHalftonePalette(hDC) : hPALbg;
+ HPALETTE hPAL = (!hPALbg) ? CreateHalftonePalette(hDC) : hPALbg;
if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL)
{
- SelectPalette(htempDC, hPAL, FALSE);
+ SelectPalette(htempDC, hPAL, false);
RealizePalette(htempDC);
}
// Get x and y offset
+ POINT pt = {0,0};
MapWindowPoints(hWnd, GetTreeView(), &pt, 1);
+ POINT ptOrigin;
GetDCOrgEx(hDC, &ptOrigin);
ptOrigin.x -= pt.x;
ptOrigin.y -= pt.y;
@@ -152,11 +131,9 @@ static BOOL ListViewOnErase(HWND hWnd, HDC hDC)
ptOrigin.y = -GetScrollPos(hWnd, SB_VERT);
if (pbmDesc->bmWidth && pbmDesc->bmHeight)
- {
- for (i = ptOrigin.x; i < rcClient.right; i += pbmDesc->bmWidth)
- for (j = ptOrigin.y; j < rcClient.bottom; j += pbmDesc->bmHeight)
+ for (int i = ptOrigin.x; i < rcClient.right; i += pbmDesc->bmWidth)
+ for (int j = ptOrigin.y; j < rcClient.bottom; j += pbmDesc->bmHeight)
BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY);
- }
SelectObject(htempDC, hOldBitmap);
DeleteDC(htempDC);
@@ -167,31 +144,29 @@ static BOOL ListViewOnErase(HWND hWnd, HDC hDC)
hPAL = 0;
}
- return TRUE;
+ return true;
}
static BOOL ListViewNotify(HWND hWnd, LPNMHDR lpNmHdr)
{
- RECT rcClient;
- DWORD dwPos;
- POINT pt;
-
// This code is for using bitmap in the background
// Invalidate the right side of the control when a column is resized
if (lpNmHdr->code == HDN_ITEMCHANGINGA || lpNmHdr->code == HDN_ITEMCHANGINGW)
{
- dwPos = GetMessagePos();
+ DWORD dwPos = GetMessagePos();
+ POINT pt;
pt.x = LOWORD(dwPos);
pt.y = HIWORD(dwPos);
+ RECT rcClient;
GetClientRect(hWnd, &rcClient);
ScreenToClient(hWnd, &pt);
rcClient.left = pt.x;
- InvalidateRect(hWnd, &rcClient, FALSE);
+ InvalidateRect(hWnd, &rcClient, false);
}
- return FALSE;
+ return false;
}
@@ -199,28 +174,27 @@ static BOOL ListViewNotify(HWND hWnd, LPNMHDR lpNmHdr)
static BOOL ListViewContextMenu(HWND hwndPicker, LPARAM lParam)
{
struct PickerInfo *pPickerInfo;
- POINT pt, headerPt;
- int i, nViewID, nColumn = -1;
- HWND hwndHeader;
- RECT rcCol;
-
pPickerInfo = GetPickerInfo(hwndPicker);
// Extract the point out of the lparam
+ POINT pt;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (pt.x < 0 && pt.y < 0)
GetCursorPos(&pt);
// Figure out which header column was clicked, if at all
- nViewID = Picker_GetViewID(hwndPicker);
+ int nViewID = Picker_GetViewID(hwndPicker);
+ int nColumn = -1;
+
if ((nViewID == VIEW_REPORT) || (nViewID == VIEW_GROUPED))
{
- hwndHeader = ListView_GetHeader(hwndPicker);
- headerPt = pt;
+ HWND hwndHeader = ListView_GetHeader(hwndPicker);
+ POINT headerPt = pt;
ScreenToClient(hwndHeader, &headerPt);
- for (i = 0; Header_GetItemRect(hwndHeader, i, &rcCol); i++)
+ RECT rcCol;
+ for (int i = 0; Header_GetItemRect(hwndHeader, i, &rcCol); i++)
{
if (PtInRect(&rcCol, headerPt))
{
@@ -242,7 +216,7 @@ static BOOL ListViewContextMenu(HWND hwndPicker, LPARAM lParam)
if (pPickerInfo->pCallbacks->pfnOnBodyContextMenu)
pPickerInfo->pCallbacks->pfnOnBodyContextMenu(pt);
}
- return TRUE;
+ return true;
}
@@ -263,7 +237,7 @@ static LRESULT CALLBACK ListViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
{
struct PickerInfo *pPickerInfo;
LRESULT rc = 0;
- BOOL bHandled = FALSE;
+ BOOL bHandled = false;
WNDPROC pfnParentWndProc;
HWND hwndHeaderCtrl = NULL;
HFONT hHeaderCtrlFont = NULL;
@@ -273,16 +247,16 @@ static LRESULT CALLBACK ListViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
switch(message)
{
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE:
if (MouseHasBeenMoved())
- ShowCursor(TRUE);
+ ShowCursor(true);
break;
case WM_ERASEBKGND:
if (GetBackgroundBitmap())
{
rc = ListViewOnErase(hWnd, (HDC) wParam);
- bHandled = TRUE;
+ bHandled = true;
}
break;
@@ -315,7 +289,7 @@ static LRESULT CALLBACK ListViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
// If we received WM_SETFONT, reset header ctrl font back to original font
if (hwndHeaderCtrl)
- SetWindowFont(hwndHeaderCtrl, hHeaderCtrlFont, TRUE);
+ SetWindowFont(hwndHeaderCtrl, hHeaderCtrlFont, true);
return rc;
}
@@ -326,19 +300,17 @@ static LRESULT CALLBACK ListViewWndProc(HWND hWnd, UINT message, WPARAM wParam,
static void Picker_InternalResetColumnDisplay(HWND hWnd, BOOL bFirstTime)
{
LV_COLUMN lvc;
- int i;
- int nColumn;
- int *widths;
- int *order;
- int *shown;
+ int i = 0;
+ int nColumn = 0;
//int shown_columns;
LVCOLUMN col;
struct PickerInfo *pPickerInfo;
- HRESULT res;
- BOOL b_res;
+ HRESULT res = 0;
+ BOOL b_res = 0;
pPickerInfo = GetPickerInfo(hWnd);
+ int *widths, *order, *shown;
widths = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*widths));
order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order));
shown = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*shown));
@@ -357,8 +329,7 @@ static void Picker_InternalResetColumnDisplay(HWND hWnd, BOOL bFirstTime)
DWORD style = GetWindowLong(hWnd, GWL_STYLE);
// switch the list view to LVS_REPORT style so column widths reported correctly
- SetWindowLong(hWnd, GWL_STYLE,
- (GetWindowLong(hWnd, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT);
+ SetWindowLong(hWnd, GWL_STYLE, (GetWindowLong(hWnd, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT);
// Retrieve each of the column widths
i = 0;
@@ -387,12 +358,13 @@ static void Picker_InternalResetColumnDisplay(HWND hWnd, BOOL bFirstTime)
lvc.iSubItem = nColumn;
lvc.cx = widths[order[i]];
lvc.fmt = LVCFMT_LEFT;
- res = ListView_InsertColumn(hWnd, nColumn, &lvc);
- pPickerInfo->pnColumnsOrder[nColumn] = order[i];
-
- dprintf("Visible column %d: Logical column %d; Width=%d\n", nColumn, order[i], widths[order[i]]);
-
- nColumn++;
+ if (lvc.pszText[0] > 0) // column name cannot be blank
+ {
+ res = ListView_InsertColumn(hWnd, nColumn, &lvc);
+ pPickerInfo->pnColumnsOrder[nColumn] = order[i];
+ //dprintf("Visible column %d: Logical column %d; Width=%d\n", nColumn, order[i], widths[order[i]]);
+ nColumn++;
+ }
}
}
@@ -420,13 +392,15 @@ done:
free(order);
if (shown)
free(shown);
+ res++;
+ b_res++;
}
void Picker_ResetColumnDisplay(HWND hWnd)
{
- Picker_InternalResetColumnDisplay(hWnd, FALSE);
+ Picker_InternalResetColumnDisplay(hWnd, false);
}
@@ -445,17 +419,15 @@ void Picker_ClearIdle(HWND hwndPicker)
-static void CALLBACK Picker_TimerProc(HWND hwndPicker, UINT uMsg,
- UINT_PTR idEvent, DWORD dwTime)
+static void CALLBACK Picker_TimerProc(HWND hwndPicker, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
struct PickerInfo *pPickerInfo;
- BOOL bContinueIdle;
- DWORD nTickCount, nBaseTickCount;
+ DWORD nTickCount = 0;
DWORD nMaxIdleTicks = 50;
pPickerInfo = GetPickerInfo(hwndPicker);
- bContinueIdle = FALSE;
- nBaseTickCount = GetTickCount();
+ BOOL bContinueIdle = false;
+ DWORD nBaseTickCount = GetTickCount();
// This idle procedure will loop until either idling is over, or until
// a specified amount of time elapses (in this case, 50ms). This frees
@@ -476,7 +448,7 @@ static void CALLBACK Picker_TimerProc(HWND hwndPicker, UINT uMsg,
// Instructs this picker to reset idling; idling will continue until the
-// idle function returns FALSE
+// idle function returns false
void Picker_ResetIdle(HWND hwndPicker)
{
struct PickerInfo *pPickerInfo;
@@ -502,16 +474,16 @@ BOOL Picker_IsIdling(HWND hwndPicker)
BOOL SetupPicker(HWND hwndPicker, const struct PickerOptions *pOptions)
{
struct PickerInfo *pPickerInfo;
- int i;
- LONG_PTR l;
- HRESULT res;
+ int i = 0;
+ LONG_PTR l = 0;
+ HRESULT res = 0;
- assert(hwndPicker);
+ //assert(hwndPicker);
// Allocate the list view struct
pPickerInfo = (struct PickerInfo *) malloc(sizeof(struct PickerInfo));
if (!pPickerInfo)
- return FALSE;
+ return false;
// And fill it out
memset(pPickerInfo, 0, sizeof(*pPickerInfo));
@@ -534,7 +506,7 @@ BOOL SetupPicker(HWND hwndPicker, const struct PickerOptions *pOptions)
for (i = 0; i < pPickerInfo->nColumnCount; i++)
{
pPickerInfo->pnColumnsOrder[i] = i;
- pPickerInfo->pnColumnsShown[i] = TRUE;
+ pPickerInfo->pnColumnsShown[i] = true;
}
if (GetUseOldControl())
@@ -562,14 +534,15 @@ BOOL SetupPicker(HWND hwndPicker, const struct PickerOptions *pOptions)
res = ListView_SetExtendedListViewStyle(hwndPicker, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP |
LVS_EX_UNDERLINEHOT | LVS_EX_UNDERLINECOLD | LVS_EX_LABELTIP);
- Picker_InternalResetColumnDisplay(hwndPicker, TRUE);
+ Picker_InternalResetColumnDisplay(hwndPicker, true);
Picker_ResetIdle(hwndPicker);
- return TRUE;
+ res++;
+ return true;
error:
if (pPickerInfo)
Picker_Free(pPickerInfo);
- return FALSE;
+ return false;
}
@@ -586,9 +559,6 @@ int Picker_GetViewID(HWND hwndPicker)
void Picker_SetViewID(HWND hwndPicker, int nViewID)
{
struct PickerInfo *pPickerInfo;
- LONG_PTR nListViewStyle;
- DWORD dwStyle;
-
pPickerInfo = GetPickerInfo(hwndPicker);
// Change the nCurrentViewID member
@@ -597,6 +567,7 @@ void Picker_SetViewID(HWND hwndPicker, int nViewID)
pPickerInfo->pCallbacks->pfnSetViewMode(pPickerInfo->nCurrentViewID);
// Change the ListView flags in accordance
+ LONG_PTR nListViewStyle;
switch(nViewID)
{
case VIEW_LARGE_ICONS:
@@ -615,7 +586,7 @@ void Picker_SetViewID(HWND hwndPicker, int nViewID)
break;
}
- dwStyle = GetWindowLong(hwndPicker, GWL_STYLE);
+ DWORD dwStyle = GetWindowLong(hwndPicker, GWL_STYLE);
if (GetUseXPControl())
{
// RS Microsoft must have changed something in the Ownerdraw handling with Version 6 of the Common Controls
@@ -629,8 +600,7 @@ void Picker_SetViewID(HWND hwndPicker, int nViewID)
// to properly get them to arrange, otherwise the entries might overlap
// we have to call SetWindowLong to get it into effect !!
// It's no use just setting the Style, as it's changed again further down...
- SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE)
- & ~LVS_TYPEMASK) | LVS_ICON);
+ SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_ICON);
}
}
else
@@ -647,71 +617,71 @@ void Picker_SetViewID(HWND hwndPicker, int nViewID)
}
-
static BOOL PickerHitTest(HWND hWnd)
{
- RECT rect;
- POINTS p;
- DWORD res = GetMessagePos();
- LVHITTESTINFO htInfo;
- HRESULT result;
-
- memset(&htInfo, 0, sizeof(htInfo));
- p = MAKEPOINTS(res);
+ LVHITTESTINFO htInfo;
+ memset(&htInfo, 0, sizeof(htInfo));
+ RECT rect;
GetWindowRect(hWnd, &rect);
+ DWORD res = GetMessagePos();
+ POINTS p = MAKEPOINTS(res);
htInfo.pt.x = p.x - rect.left;
htInfo.pt.y = p.y - rect.top;
- result = ListView_HitTest(hWnd, &htInfo);
-
+ HRESULT result = ListView_HitTest(hWnd, &htInfo);
+ result++;
return (! (htInfo.flags & LVHT_NOWHERE));
}
-
int Picker_GetSelectedItem(HWND hWnd)
{
- int nItem;
- LV_ITEM lvi;
- BOOL res;
-
- nItem = ListView_GetNextItem(hWnd, -1, LVIS_SELECTED | LVIS_FOCUSED);
+ int nItem = ListView_GetNextItem(hWnd, -1, LVIS_SELECTED | LVIS_FOCUSED);
if (nItem < 0)
return 0;
+ LV_ITEM lvi;
memset(&lvi, 0, sizeof(lvi));
lvi.iItem = nItem;
lvi.mask = LVIF_PARAM;
- res = ListView_GetItem(hWnd, &lvi);
+ BOOL res = ListView_GetItem(hWnd, &lvi);
+ res++;
return lvi.lParam;
}
-
+// This highlights a selected game, and scrolls it into view
void Picker_SetSelectedPick(HWND hWnd, int nIndex)
{
- BOOL res;
-
if (nIndex < 0)
nIndex = 0;
-
- ListView_SetItemState(hWnd, nIndex, LVIS_FOCUSED | LVIS_SELECTED,
- LVIS_FOCUSED | LVIS_SELECTED);
- res = ListView_EnsureVisible(hWnd, nIndex, FALSE);
+ // Protection against bad coding elsewhere
+ // nCount is one more than number of last game
+ int nCount = ListView_GetItemCount(hWnd);
+ // No games to show
+ if (nCount == 0)
+ return;
+ nCount--;
+ if (nCount < nIndex)
+ nIndex = nCount;
+ // Highlight a game
+ if (nIndex > -1)
+ ListView_SetItemState(hWnd, nIndex, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
+ // Bring the game into view
+ BOOL res = ListView_EnsureVisible(hWnd, nIndex, false);
+ res++;
}
void Picker_SetSelectedItem(HWND hWnd, int nItem)
{
- int i;
- LV_FINDINFO lvfi;
-
if (nItem < 0)
return;
+ LV_FINDINFO lvfi;
lvfi.flags = LVFI_PARAM;
lvfi.lParam = nItem;
- i = ListView_FindItem(hWnd, -1, &lvfi);
+ int i = ListView_FindItem(hWnd, -1, &lvfi);
if (i == -1)
{
POINT p = {0,0};
@@ -724,8 +694,7 @@ void Picker_SetSelectedItem(HWND hWnd, int nItem)
-static const TCHAR *Picker_CallGetItemString(HWND hwndPicker,
- int nItem, int nColumn, TCHAR *pszBuffer, UINT nBufferLength)
+static const TCHAR *Picker_CallGetItemString(HWND hwndPicker, int nItem, int nColumn, TCHAR *pszBuffer, UINT nBufferLength)
{
// this call wraps the pfnGetItemString callback to properly set up the
// buffers, and normalize the results
@@ -737,10 +706,8 @@ static const TCHAR *Picker_CallGetItemString(HWND hwndPicker,
s = NULL;
if (pPickerInfo->pCallbacks->pfnGetItemString)
- {
- s = pPickerInfo->pCallbacks->pfnGetItemString(hwndPicker,
- nItem, nColumn, pszBuffer, nBufferLength);
- }
+ s = pPickerInfo->pCallbacks->pfnGetItemString(hwndPicker, nItem, nColumn, pszBuffer, nBufferLength);
+
if (!s)
s = pszBuffer;
return s;
@@ -752,23 +719,17 @@ static const TCHAR *Picker_CallGetItemString(HWND hwndPicker,
static void Picker_ResetHeaderSortIcon(HWND hwndPicker)
{
struct PickerInfo *pPickerInfo;
- HWND hwndHeader;
- HD_ITEM hdi;
- int i, nViewColumn;
- BOOL res;
-
pPickerInfo = GetPickerInfo(hwndPicker);
-
- hwndHeader = ListView_GetHeader(hwndPicker);
+ HWND hwndHeader = ListView_GetHeader(hwndPicker);
+ BOOL res;
// take arrow off non-current columns
+ HD_ITEM hdi;
hdi.mask = HDI_FORMAT;
hdi.fmt = HDF_STRING;
- for (i = 0; i < pPickerInfo->nColumnCount; i++)
- {
+ for (int i = 0; i < pPickerInfo->nColumnCount; i++)
if (i != pPickerInfo->pCallbacks->pfnGetSortColumn())
res = Header_SetItem(hwndHeader, Picker_GetViewColumnFromRealColumn(hwndPicker, i), &hdi);
- }
if (GetUseXPControl())
{
@@ -784,8 +745,9 @@ static void Picker_ResetHeaderSortIcon(HWND hwndPicker)
hdi.iImage = pPickerInfo->pCallbacks->pfnGetSortReverse() ? 1 : 0;
}
- nViewColumn = Picker_GetViewColumnFromRealColumn(hwndPicker, pPickerInfo->pCallbacks->pfnGetSortColumn());
+ int nViewColumn = Picker_GetViewColumnFromRealColumn(hwndPicker, pPickerInfo->pCallbacks->pfnGetSortColumn());
res = Header_SetItem(hwndHeader, nViewColumn, &hdi);
+ res++;
}
@@ -801,8 +763,7 @@ struct CompareProcParams
-static void Picker_PopulateCompareProcParams(HWND hwndPicker,
- struct CompareProcParams *pParams)
+static void Picker_PopulateCompareProcParams(HWND hwndPicker, struct CompareProcParams *pParams)
{
struct PickerInfo *pPickerInfo;
@@ -825,8 +786,8 @@ static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nPar
{
struct CompareProcParams *pcpp = (struct CompareProcParams *) nParamSort;
struct PickerInfo *pPickerInfo = pcpp->pPickerInfo;
- BOOL bCallCompare = TRUE;
- int nResult = 0, nParent1, nParent2;
+ BOOL bCallCompare = true;
+ int nResult = 0, nParent1 = 0, nParent2 = 0;
TCHAR szBuffer1[256], szBuffer2[256];
const TCHAR *s1, *s2;
@@ -868,7 +829,7 @@ static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nPar
{
// if this is a child and its parent, put child after
nResult = 1;
- bCallCompare = FALSE;
+ bCallCompare = false;
}
else
{
@@ -883,7 +844,7 @@ static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nPar
{
// if this is a child and its parent, put child after
nResult = -1;
- bCallCompare = FALSE;
+ bCallCompare = false;
}
else
{
@@ -905,9 +866,9 @@ static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nPar
{
// no default sort proc, just get the string and compare them
s1 = Picker_CallGetItemString(pcpp->hwndPicker, index1, pcpp->nSortColumn,
- szBuffer1, ARRAY_LENGTH(szBuffer1));
+ szBuffer1, sizeof(szBuffer1) / sizeof(szBuffer1[0]));
s2 = Picker_CallGetItemString(pcpp->hwndPicker, index2, pcpp->nSortColumn,
- szBuffer2, ARRAY_LENGTH(szBuffer2));
+ szBuffer2, sizeof(szBuffer2) / sizeof(szBuffer2[0]));
nResult = _tcsicmp(s1, s2);
}
@@ -921,27 +882,26 @@ static int CALLBACK Picker_CompareProc(LPARAM index1, LPARAM index2, LPARAM nPar
void Picker_Sort(HWND hwndPicker)
{
- LV_FINDINFO lvfi;
//struct PickerInfo *pPickerInfo;
struct CompareProcParams params;
- int nItem;
- BOOL res;
//pPickerInfo = GetPickerInfo(hwndPicker);
// populate the CompareProcParams structure
Picker_PopulateCompareProcParams(hwndPicker, &params);
- res = ListView_SortItems(hwndPicker, Picker_CompareProc, (LPARAM) &params);
+ BOOL res = ListView_SortItems(hwndPicker, Picker_CompareProc, (LPARAM) &params);
Picker_ResetHeaderSortIcon(hwndPicker);
+ LV_FINDINFO lvfi;
memset(&lvfi, 0, sizeof(lvfi));
lvfi.flags = LVFI_PARAM;
lvfi.lParam = Picker_GetSelectedItem(hwndPicker);
- nItem = ListView_FindItem(hwndPicker, -1, &lvfi);
+ int nItem = ListView_FindItem(hwndPicker, -1, &lvfi);
- res = ListView_EnsureVisible(hwndPicker, nItem, FALSE);
+ res = ListView_EnsureVisible(hwndPicker, nItem, false);
+ res++;
}
@@ -949,16 +909,15 @@ void Picker_Sort(HWND hwndPicker)
int Picker_InsertItemSorted(HWND hwndPicker, int nParam)
{
//struct PickerInfo *pPickerInfo;
- int nHigh, nLow, nMid;
+ int nLow = 0, nMid = 0;
struct CompareProcParams params;
- int nCompareResult;
+ int nCompareResult = 0;
LVITEM lvi;
- BOOL res;
+ BOOL res = 0;
//pPickerInfo = GetPickerInfo(hwndPicker);
- nLow = 0;
- nHigh = ListView_GetItemCount(hwndPicker);
+ int nHigh = ListView_GetItemCount(hwndPicker);
// populate the CompareProcParams structure
Picker_PopulateCompareProcParams(hwndPicker, &params);
@@ -971,7 +930,6 @@ int Picker_InsertItemSorted(HWND hwndPicker, int nParam)
lvi.mask = LVIF_PARAM;
lvi.iItem = nMid;
res = ListView_GetItem(hwndPicker, &lvi);
-
nCompareResult = Picker_CompareProc(nParam, lvi.lParam, (LPARAM) &params);
if (nCompareResult > 0)
@@ -985,13 +943,14 @@ int Picker_InsertItemSorted(HWND hwndPicker, int nParam)
}
}
+ res++;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = nLow;
+ lvi.iItem = nLow;
lvi.iSubItem = 0;
- lvi.lParam = nParam;
+ lvi.lParam = nParam;
lvi.pszText = LPSTR_TEXTCALLBACK;
- lvi.iImage = I_IMAGECALLBACK;
+ lvi.iImage = I_IMAGECALLBACK;
return ListView_InsertItem(hwndPicker, &lvi);
}
@@ -1014,14 +973,11 @@ int Picker_GetRealColumnFromViewColumn(HWND hWnd, int nViewColumn)
int Picker_GetViewColumnFromRealColumn(HWND hWnd, int nRealColumn)
{
struct PickerInfo *pPickerInfo;
- int i;
pPickerInfo = GetPickerInfo(hWnd);
- for (i = 0; i < pPickerInfo->nColumnCount; i++)
- {
+ for (int i = 0; i < pPickerInfo->nColumnCount; i++)
if (pPickerInfo->pnColumnsOrder[i] == nRealColumn)
return i;
- }
// major error, shouldn't be possible, but no good way to warn
return 0;
@@ -1033,12 +989,12 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
{
struct PickerInfo *pPickerInfo;
HWND hWnd;
- BOOL bResult = FALSE;
+ BOOL bResult = false;
NM_LISTVIEW *pnmv;
LV_DISPINFO *pDispInfo;
- int nItem, nColumn;
+ int nItem = 0, nColumn = 0;
const TCHAR *s;
- BOOL bReverse;
+ BOOL bReverse = 0;
hWnd = lpNmHdr->hwndFrom;
pPickerInfo = GetPickerInfo(hWnd);
@@ -1057,13 +1013,13 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
{
Picker_SetSelectedItem(hWnd, pPickerInfo->nLastItem);
}
- bResult = TRUE;
+ bResult = true;
}
else if ((lpNmHdr->code == NM_DBLCLK) && (pPickerInfo->pCallbacks->pfnDoubleClick))
{
// double click!
pPickerInfo->pCallbacks->pfnDoubleClick();
- bResult = TRUE;
+ bResult = true;
}
break;
@@ -1078,13 +1034,13 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
pDispInfo->item.iImage = pPickerInfo->pCallbacks->pfnGetItemImage(hWnd, nItem);
else
pDispInfo->item.iImage = 0;
- bResult = TRUE;
+ bResult = true;
}
if (pDispInfo->item.mask & LVIF_STATE)
{
pDispInfo->item.state = 0;
- bResult = TRUE;
+ bResult = true;
}
if (pDispInfo->item.mask & LVIF_TEXT)
@@ -1096,7 +1052,7 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
pDispInfo->item.pszText, pDispInfo->item.cchTextMax);
pDispInfo->item.pszText = (TCHAR *) s;
- bResult = TRUE;
+ bResult = true;
}
break;
@@ -1115,7 +1071,7 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
if (pPickerInfo->pCallbacks->pfnEnteringItem)
pPickerInfo->pCallbacks->pfnEnteringItem(hWnd, pnmv->lParam);
}
- bResult = TRUE;
+ bResult = true;
break;
case LVN_COLUMNCLICK:
@@ -1123,11 +1079,11 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
if (pPickerInfo->pCallbacks->pfnGetSortColumn() == Picker_GetRealColumnFromViewColumn(hWnd, pnmv->iSubItem))
bReverse = !pPickerInfo->pCallbacks->pfnGetSortReverse();
else
- bReverse = FALSE;
+ bReverse = false;
pPickerInfo->pCallbacks->pfnSetSortReverse(bReverse);
pPickerInfo->pCallbacks->pfnSetSortColumn(Picker_GetRealColumnFromViewColumn(hWnd, pnmv->iSubItem));
Picker_Sort(hWnd);
- bResult = TRUE;
+ bResult = true;
break;
case LVN_BEGINDRAG:
@@ -1143,11 +1099,8 @@ BOOL Picker_HandleNotify(LPNMHDR lpNmHdr)
int Picker_GetNumColumns(HWND hWnd)
{
int nColumnCount = 0;
- int i;
- HWND hwndHeader;
int *shown;
struct PickerInfo *pPickerInfo;
-
pPickerInfo = GetPickerInfo(hWnd);
shown = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*shown));
@@ -1155,16 +1108,14 @@ int Picker_GetNumColumns(HWND hWnd)
return -1;
pPickerInfo->pCallbacks->pfnGetColumnShown(shown);
- hwndHeader = ListView_GetHeader(hWnd);
+ HWND hwndHeader = ListView_GetHeader(hWnd);
if (GetUseOldControl() || (nColumnCount = Header_GetItemCount(hwndHeader)) < 1)
{
nColumnCount = 0;
- for (i = 0; i < pPickerInfo->nColumnCount ; i++ )
- {
+ for (int i = 0; i < pPickerInfo->nColumnCount ; i++ )
if (shown[i])
nColumnCount++;
- }
}
free(shown);
@@ -1179,9 +1130,7 @@ static LPCTSTR MakeShortString(HDC hDC, LPCTSTR lpszLong, int nColumnLen, int nO
static const TCHAR szThreeDots[] = TEXT("...");
static TCHAR szShort[MAX_PATH];
int nStringLen = lstrlen(lpszLong);
- int nAddLen;
SIZE size;
- int i;
GetTextExtentPoint32(hDC, lpszLong, nStringLen, &size);
if (nStringLen == 0 || size.cx + nOffset <= nColumnLen)
@@ -1189,9 +1138,9 @@ static LPCTSTR MakeShortString(HDC hDC, LPCTSTR lpszLong, int nColumnLen, int nO
lstrcpy(szShort, lpszLong);
GetTextExtentPoint32(hDC, szThreeDots, ARRAY_LENGTH(szThreeDots), &size);
- nAddLen = size.cx;
+ int nAddLen = size.cx;
- for (i = nStringLen - 1; i > 0; i--)
+ for (int i = nStringLen - 1; i > 0; i--)
{
szShort[i] = 0;
GetTextExtentPoint32(hDC, szShort, i, &size);
@@ -1208,51 +1157,48 @@ static LPCTSTR MakeShortString(HDC hDC, LPCTSTR lpszLong, int nColumnLen, int nO
void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- struct PickerInfo *pPickerInfo;
- HDC hDC = lpDrawItemStruct->hDC;
- RECT rcItem = lpDrawItemStruct->rcItem;
- UINT uiFlags = ILD_TRANSPARENT;
- HIMAGELIST hImageList;
- int nItem = lpDrawItemStruct->itemID;
- COLORREF clrTextSave = 0;
- COLORREF clrBkSave = 0;
- COLORREF clrImage = GetSysColor(COLOR_WINDOW);
- static TCHAR szBuff[MAX_PATH];
- BOOL bFocus = (GetFocus() == hWnd);
- LPCTSTR pszText;
- UINT nStateImageMask;
- BOOL bSelected;
- LV_COLUMN lvc;
- LV_ITEM lvi;
- RECT rcAllLabels;
- RECT rcLabel;
- RECT rcIcon;
- int offset;
- SIZE size;
- int i, j;
- int nColumn;
- int nColumnMax = 0;
- int *order;
- BOOL bDrawAsChild;
- int indent_space;
- BOOL bColorChild = FALSE;
- BOOL bParentFound = FALSE;
- int nParent;
- HBITMAP hBackground = GetBackgroundBitmap();
- MYBITMAPINFO *pbmDesc = GetBackgroundInfo();
- BOOL res;
-
+ struct PickerInfo *pPickerInfo;
pPickerInfo = GetPickerInfo(hWnd);
-
+ int *order;
order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order));
if (!order)
return;
- nColumnMax = Picker_GetNumColumns(hWnd);
+
+ HDC hDC = lpDrawItemStruct->hDC;
+ RECT rcItem = lpDrawItemStruct->rcItem;
+ UINT uiFlags = ILD_TRANSPARENT;
+ HIMAGELIST hImageList;
+ int nItem = lpDrawItemStruct->itemID;
+ COLORREF clrTextSave = 0;
+ COLORREF clrBkSave = 0;
+ COLORREF clrImage = GetSysColor(COLOR_WINDOW);
+ static TCHAR szBuff[MAX_PATH];
+ BOOL bFocus = (GetFocus() == hWnd);
+ LPCTSTR pszText;
+ UINT nStateImageMask = 0;
+ BOOL bSelected = 0;
+ LV_COLUMN lvc;
+ LV_ITEM lvi;
+ RECT rcAllLabels;
+ RECT rcLabel;
+ RECT rcIcon;
+ int offset = 0;
+ SIZE size;
+ int i = 0, j = 0;
+ int nColumn = 0;
+ BOOL bDrawAsChild = 0;
+ int indent_space = 0;
+ BOOL bColorChild = false;
+ BOOL bParentFound = false;
+ int nParent = 0;
+ HBITMAP hBackground = GetBackgroundBitmap();
+ MYBITMAPINFO *pbmDesc = GetBackgroundInfo();
+ BOOL res = 0;
+
+ int nColumnMax = Picker_GetNumColumns(hWnd);
if (GetUseOldControl())
- {
pPickerInfo->pCallbacks->pfnGetColumnOrder(order);
- }
else
{
/* Get the Column Order and save it */
@@ -1278,16 +1224,15 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
GetTextExtentPoint32(hDC, TEXT(" "), 1, &size);
offset = size.cx;
- lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
- lvi.iItem = nItem;
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
+ lvi.iItem = nItem;
lvi.iSubItem = order[0];
- lvi.pszText = szBuff;
- lvi.cchTextMax = ARRAY_LENGTH(szBuff);
- lvi.stateMask = 0xFFFF; /* get all state flags */
+ lvi.pszText = szBuff;
+ lvi.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]);
+ lvi.stateMask = 0xFFFF; /* get all state flags */
res = ListView_GetItem(hWnd, &lvi);
- bSelected = ((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED)
- && ((bFocus) || (GetWindowLong(hWnd, GWL_STYLE) & LVS_SHOWSELALWAYS))));
+ bSelected = ((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED) && ((bFocus) || (GetWindowLong(hWnd, GWL_STYLE) & LVS_SHOWSELALWAYS))));
/* figure out if we indent and draw grayed */
if (pPickerInfo->pCallbacks->pfnFindItemParent)
@@ -1326,13 +1271,13 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
if (!bParentFound && bDrawAsChild)
{
/*Reset it, as no Parent is there*/
- bDrawAsChild = FALSE;
- bColorChild = TRUE;
+ bDrawAsChild = false;
+ bColorChild = true;
}
else
{
nParent = -1;
- bParentFound = FALSE;
+ bParentFound = false;
}
}
@@ -1341,19 +1286,17 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
rcAllLabels.left = rcLabel.left;
- if (hBackground != NULL)
+ if (hBackground)
{
- RECT rcClient;
- HRGN rgnBitmap;
- RECT rcTmpBmp = rcItem;
- RECT rcFirstItem;
- HPALETTE hPAL;
- HDC htempDC;
- HBITMAP oldBitmap;
+ RECT rcClient;
+ HRGN rgnBitmap;
+ RECT rcTmpBmp = rcItem;
+ RECT rcFirstItem;
+ HPALETTE hPAL;
- htempDC = CreateCompatibleDC(hDC);
+ HDC htempDC = CreateCompatibleDC(hDC);
- oldBitmap = (HBITMAP)SelectObject(htempDC, hBackground);
+ HBITMAP oldBitmap = (HBITMAP)SelectObject(htempDC, hBackground);
GetClientRect(hWnd, &rcClient);
rcTmpBmp.right = rcClient.right;
@@ -1372,7 +1315,7 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL)
{
- SelectPalette(htempDC, hPAL, FALSE);
+ SelectPalette(htempDC, hPAL, false);
RealizePalette(htempDC);
}
@@ -1416,14 +1359,14 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
if (bFocus)
{
clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
- clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
- hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
+ clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
+ hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
}
else
{
clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT));
- clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_BTNFACE));
- hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
+ clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_BTNFACE));
+ hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
}
hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
@@ -1435,9 +1378,7 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (hBackground == NULL)
{
- HBRUSH hBrush;
-
- hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
+ HBRUSH hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
FillRect(hDC, &rcAllLabels, hBrush);
DeleteBrush(hBrush);
}
@@ -1466,7 +1407,8 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
clrImage = GetSysColor(COLOR_WINDOW);
uiFlags |= ILD_BLEND50;
}
- else if (bSelected)
+ else
+ if (bSelected)
{
if (bFocus)
clrImage = GetSysColor(COLOR_HIGHLIGHT);
@@ -1497,10 +1439,7 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK;
if (rcIcon.left + 16 + indent_space < rcItem.right)
- {
- ImageList_DrawEx(hImageList, lvi.iImage, hDC, rcIcon.left, rcIcon.top, 16, 16,
- GetSysColor(COLOR_WINDOW), clrImage, uiFlags | nOvlImageMask);
- }
+ ImageList_DrawEx(hImageList, lvi.iImage, hDC, rcIcon.left, rcIcon.top, 16, 16, GetSysColor(COLOR_WINDOW), clrImage, uiFlags | nOvlImageMask);
}
res = ListView_GetItemRect_Modified(hWnd, nItem, &rcItem, LVIR_LABEL);
@@ -1511,25 +1450,24 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
rcLabel.left += offset + indent_space;
rcLabel.right -= offset;
- DrawText(hDC, pszText, -1, &rcLabel,
- DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
+ DrawText(hDC, pszText, -1, &rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
for (nColumn = 1; nColumn < nColumnMax; nColumn++)
{
- int nRetLen;
- UINT nJustify;
+ int nRetLen;
+ UINT nJustify;
LV_ITEM lvItem;
lvc.mask = LVCF_FMT | LVCF_WIDTH;
res = ListView_GetColumn(hWnd, order[nColumn], &lvc);
- lvItem.mask = LVIF_TEXT;
- lvItem.iItem = nItem;
+ lvItem.mask = LVIF_TEXT;
+ lvItem.iItem = nItem;
lvItem.iSubItem = order[nColumn];
- lvItem.pszText = szBuff;
- lvItem.cchTextMax = ARRAY_LENGTH(szBuff);
+ lvItem.pszText = szBuff;
+ lvItem.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]);
- if (ListView_GetItem(hWnd, &lvItem) == FALSE)
+ if (ListView_GetItem(hWnd, &lvItem) == false)
continue;
rcItem.left = rcItem.right;
@@ -1563,8 +1501,7 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
rcLabel = rcItem;
rcLabel.left += offset;
rcLabel.right -= offset;
- DrawText(hDC, pszText, -1, &rcLabel,
- nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
+ DrawText(hDC, pszText, -1, &rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
}
if (lvi.state & LVIS_FOCUSED && bFocus)
@@ -1573,6 +1510,7 @@ void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct)
SetTextColor(hDC, clrTextSave);
SetBkColor(hDC, clrBkSave);
free(order);
+ res++;
}
@@ -1617,16 +1555,14 @@ void Picker_SetHeaderImageList(HWND hwndPicker, HIMAGELIST hHeaderImages)
BOOL Picker_SaveColumnWidths(HWND hwndPicker)
{
struct PickerInfo *pPickerInfo;
- int *widths;
- int *order;
- int *tmpOrder;
- int nColumnMax, i;
- BOOL bSuccess = FALSE;
- BOOL res;
+ int nColumnMax = 0, i = 0;
+ BOOL bSuccess = false;
+ BOOL res = 0;
pPickerInfo = GetPickerInfo(hwndPicker);
/* allocate space for the column info */
+ int *widths, *order, *tmpOrder;
widths = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*widths));
order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order));
tmpOrder = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*tmpOrder));
@@ -1640,19 +1576,13 @@ BOOL Picker_SaveColumnWidths(HWND hwndPicker)
pPickerInfo->pCallbacks->pfnGetColumnOrder(order);
/* switch the list view to LVS_REPORT style so column widths reported correctly */
- SetWindowLong(hwndPicker, GWL_STYLE,
- (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT);
+ SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT);
nColumnMax = Picker_GetNumColumns(hwndPicker);
if (GetUseOldControl())
- {
for (i = 0; i < nColumnMax; i++)
- {
- widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] =
- ListView_GetColumnWidth(hwndPicker, i);
- }
- }
+ widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = ListView_GetColumnWidth(hwndPicker, i);
else
{
/* Get the Column Order and save it */
@@ -1660,15 +1590,14 @@ BOOL Picker_SaveColumnWidths(HWND hwndPicker)
for (i = 0; i < nColumnMax; i++)
{
- widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)]
- = ListView_GetColumnWidth(hwndPicker, i);
+ widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = ListView_GetColumnWidth(hwndPicker, i);
order[i] = Picker_GetRealColumnFromViewColumn(hwndPicker, tmpOrder[i]);
}
}
pPickerInfo->pCallbacks->pfnSetColumnWidths(widths);
pPickerInfo->pCallbacks->pfnSetColumnOrder(order);
- bSuccess = TRUE;
+ bSuccess = true;
done:
if (widths)
@@ -1677,5 +1606,6 @@ done:
free(order);
if (tmpOrder)
free(tmpOrder);
+ res++;
return bSuccess;
}
diff --git a/src/osd/winui/properties.cpp b/src/osd/winui/properties.cpp
index f00ceb9c9f9..d23c4deb76b 100644
--- a/src/osd/winui/properties.cpp
+++ b/src/osd/winui/properties.cpp
@@ -4,7 +4,7 @@
/***************************************************************************
- Properties.c
+ Properties.cpp
Properties Popup and Misc UI support routines.
@@ -123,7 +123,9 @@ b) Exit the dialog.
#endif
#include "newuires.h"
+#ifdef UI_DIRECTDRAW
#include "directdraw.h" /* has to be after samples.h */
+#endif
#include "properties.h"
#include "drivenum.h"
#include "machine/ram.h"
@@ -135,6 +137,9 @@ b) Exit the dialog.
#define PropSheet_GetTabControl(d) (HWND)(LRESULT)(int)SendMessage((d),PSM_GETTABCONTROL,0,0)
#endif /* defined(__GNUC__) */
+/* Enable this if MAME supports multiple versions of D3D */
+//#define D3DVERSION
+
/***************************************************************
* Imported function prototypes
***************************************************************/
@@ -154,7 +159,9 @@ static void InitializeSkippingUI(HWND hwnd);
static void InitializeRotateUI(HWND hwnd);
static void UpdateSelectScreenUI(HWND hwnd);
static void InitializeSelectScreenUI(HWND hwnd);
+#ifdef D3DVERSION
static void InitializeD3DVersionUI(HWND hwnd);
+#endif
static void InitializeVideoUI(HWND hwnd);
static void InitializeBIOSUI(HWND hwnd);
static void InitializeControllerMappingUI(HWND hwnd);
@@ -181,7 +188,7 @@ static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_
static BOOL DirListPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name);
static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name);
extern BOOL BrowseForDirectory(HWND hwnd, LPCTSTR pStartDir, TCHAR* pResult);
-//static BOOL g_bModifiedSoftwarePaths = FALSE;
+//static BOOL g_bModifiedSoftwarePaths = false;
#endif
/**************************************************************
@@ -201,8 +208,8 @@ static int g_nGame = 0;
static int g_nFolder = 0;
static int g_nFolderGame = 0;
static OPTIONS_TYPE g_nPropertyMode = OPTIONS_GAME;
-static BOOL g_bAutoAspect[MAX_SCREENS] = {FALSE, FALSE, FALSE, FALSE};
-static BOOL g_bAutoSnapSize = FALSE;
+static BOOL g_bAutoAspect[MAX_SCREENS] = {false, false, false, false};
+static BOOL g_bAutoSnapSize = false;
static HICON g_hIcon = NULL;
/* Property sheets */
@@ -234,7 +241,9 @@ static struct ComboBoxVideo
{
{ TEXT("Auto"), "auto" },
{ TEXT("GDI"), "gdi" },
-// { TEXT("DirectDraw"), "ddraw" }, // removed 20160217
+#ifdef UI_DIRECTDRAW
+ { TEXT("DirectDraw"), "ddraw" }, // removed 20160217
+#endif
{ TEXT("Direct3D"), "d3d" },
{ TEXT("BGFX"), "bgfx" },
{ TEXT("OpenGL"), "opengl" },
@@ -254,7 +263,7 @@ static struct ComboBoxSound
// { TEXT("XAudio2"), "xaudio2" }, // invalid option
};
#define NUMSOUND (sizeof(g_ComboBoxSound) / sizeof(g_ComboBoxSound[0]))
-
+#ifdef D3DVERSION
static struct ComboBoxD3DVersion
{
const TCHAR* m_pText;
@@ -267,7 +276,7 @@ static struct ComboBoxD3DVersion
#define NUMD3DVERSIONS (sizeof(g_ComboBoxD3DVersion) / sizeof(g_ComboBoxD3DVersion[0]))
#define WINOPTION_D3DVERSION "9"
-
+#endif
static struct ComboBoxSelectScreen
{
const TCHAR* m_pText;
@@ -443,7 +452,7 @@ void InitDefaultPropertyPage(HINSTANCE hInst, HWND hWnd)
ZeroMemory(&pshead, sizeof(pshead));
- pspage = CreatePropSheetPages(hInst, TRUE, -1, &pshead.nPages, FALSE);
+ pspage = CreatePropSheetPages(hInst, true, -1, &pshead.nPages, false);
if (!pspage)
return;
@@ -511,7 +520,7 @@ void InitPropertyPageToPage(HINSTANCE hInst, HWND hWnd, HICON hIcon, OPTIONS_TYP
// Evaluate if the current set uses the Default set
//g_bUseDefaults = (pCurrentOpts != pDefaultOpts);
- //g_bReset = FALSE;
+ //g_bReset = false;
BuildDataMap();
ZeroMemory(&pshead, sizeof(PROPSHEETHEADER));
@@ -522,11 +531,11 @@ void InitPropertyPageToPage(HINSTANCE hInst, HWND hWnd, HICON hIcon, OPTIONS_TYP
if( OPTIONS_GAME == opt_type )
{
InitGameAudit(game_num);
-// pspage = CreatePropSheetPages(hInst, FALSE, &driver_list::driver(game_num), &pshead.nPages, TRUE);
- pspage = CreatePropSheetPages(hInst, FALSE, game_num, &pshead.nPages, TRUE);
+// pspage = CreatePropSheetPages(hInst, false, &driver_list::driver(game_num), &pshead.nPages, true);
+ pspage = CreatePropSheetPages(hInst, false, game_num, &pshead.nPages, true);
}
else
- pspage = CreatePropSheetPages(hInst, FALSE, -1, &pshead.nPages, FALSE);
+ pspage = CreatePropSheetPages(hInst, false, -1, &pshead.nPages, false);
if (!pspage)
return;
@@ -589,19 +598,9 @@ static char *GameInfoCPU(UINT nIndex)
for (device_execute_interface &cpu : execute_interface_iterator(config.root_device()))
{
if (cpu.device().clock() >= 1000000)
- {
- sprintf(&buf[strlen(buf)], "%s %d.%06d MHz",
- cpu.device().name(),
- cpu.device().clock() / 1000000,
- cpu.device().clock() % 1000000);
- }
+ sprintf(&buf[strlen(buf)], "%s %d.%06d MHz", cpu.device().name(), cpu.device().clock() / 1000000, cpu.device().clock() % 1000000);
else
- {
- sprintf(&buf[strlen(buf)], "%s %d.%03d kHz",
- cpu.device().name(),
- cpu.device().clock() / 1000,
- cpu.device().clock() % 1000);
- }
+ sprintf(&buf[strlen(buf)], "%s %d.%03d kHz", cpu.device().name(), cpu.device().clock() / 1000, cpu.device().clock() % 1000);
strcat(buf, "\n");
}
@@ -632,17 +631,9 @@ static char *GameInfoSound(UINT nIndex)
if (clock)
{
if (clock >= 1000000)
- {
- sprintf(&buf[strlen(buf)]," %d.%06d MHz",
- clock / 1000000,
- clock % 1000000);
- }
+ sprintf(&buf[strlen(buf)]," %d.%06d MHz", clock / 1000000, clock % 1000000);
else
- {
- sprintf(&buf[strlen(buf)]," %d.%03d kHz",
- clock / 1000,
- clock % 1000);
- }
+ sprintf(&buf[strlen(buf)]," %d.%03d kHz", clock / 1000, clock % 1000);
}
strcat(buf,"\n");
@@ -702,7 +693,7 @@ const char *GameInfoStatus(int driver_index, BOOL bRomStatus)
memset(buffer,0,sizeof(char)*1024);
if ( bRomStatus )
{
- if (IsAuditResultKnown(audit_result) == FALSE)
+ if (IsAuditResultKnown(audit_result) == false)
strcpy(buffer, "Unknown");
else if (IsAuditResultYes(audit_result))
{
@@ -814,22 +805,17 @@ const char *GameInfoStatus(int driver_index, BOOL bRomStatus)
}
}
else
- {
// audit result is no
strcpy(buffer, "BIOS missing");
- }
}
else
{
//Just show the emulation flags
if (DriverIsBroken(driver_index))
- {
strcpy(buffer, "Not working");
- }
else
- {
strcpy(buffer, "Working");
- }
+
if (driver_list::driver(driver_index).flags & MACHINE_UNEMULATED_PROTECTION)
{
if (*buffer != '\0')
@@ -953,7 +939,7 @@ HWND hWnd;
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_TITLE), GameInfoTitle(g_nPropertyMode, g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_MANUFACTURED), GameInfoManufactured(g_nGame));
- win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_STATUS), GameInfoStatus(g_nGame, FALSE));
+ win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_STATUS), GameInfoStatus(g_nGame, false));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_CPU), GameInfoCPU(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SOUND), GameInfoSound(g_nGame));
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_PROP_SCREEN), GameInfoScreen(g_nGame));
@@ -974,12 +960,9 @@ HWND hWnd;
}
/* Handle all options property pages */
-// NOTE you cannot just say opts1=opts2, although in theory it should work, in practice opts1 becomes null.
INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- BOOL g_bUseDefaults = 0, g_bReset = 0;
- //d3d_version = pCurrentOpts.int_value(WINOPTION_D3DVERSION);
-
+ BOOL g_bUseDefaults = false, g_bReset = false;
switch (Msg)
{
@@ -991,7 +974,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
// Default button doesn't exist on Default settings
@@ -1008,7 +991,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
case WM_HSCROLL:
/* slider changed */
HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OptOnHScroll);
- EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), true);
// Enable Apply button
PropSheet_Changed(GetParent(hDlg), hDlg);
@@ -1017,7 +1000,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// redraw it, it might be a new color now
- InvalidateRect((HWND)lParam,NULL,TRUE);
+ InvalidateRect((HWND)lParam,NULL,true);
break;
@@ -1027,7 +1010,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
WORD wID = GET_WM_COMMAND_ID(wParam, lParam);
HWND hWndCtrl = GET_WM_COMMAND_HWND(wParam, lParam);
WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
- BOOL changed = FALSE;
+ BOOL changed = false;
int nCurSelection = 0;
TCHAR szClass[256];
@@ -1037,7 +1020,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
if (wNotifyCode == LBN_SELCHANGE)
{
RefreshSelectionChange(hDlg, hWndCtrl);
- changed = TRUE;
+ changed = true;
}
break;
@@ -1045,7 +1028,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
nCurSelection = Button_GetCheck( GetDlgItem(hDlg, IDC_ASPECT));
if( g_bAutoAspect[GetSelectedScreen(hDlg)] != nCurSelection )
{
- changed = TRUE;
+ changed = true;
g_bAutoAspect[GetSelectedScreen(hDlg)] = nCurSelection;
}
break;
@@ -1054,7 +1037,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
nCurSelection = Button_GetCheck( GetDlgItem(hDlg, IDC_SNAPSIZE));
if( g_bAutoSnapSize != nCurSelection )
{
- changed = TRUE;
+ changed = true;
g_bAutoSnapSize = nCurSelection;
}
break;
@@ -1093,7 +1076,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
// The original options become the current options.
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
// Turn off Apply
PropSheet_UnChanged(GetParent(hDlg), hDlg);
@@ -1111,7 +1094,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
// The original options become the current options.
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
// Enable/Disable the Reset to Defaults button
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
@@ -1137,7 +1120,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
//MSH 20070814 - Hate to do this, but its either this, or update each individual
// control on the SCREEN tab.
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
- changed = TRUE;
+ changed = true;
/* NOT USED *************
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SCREENSELECT);
datamap_populate_control(properties_datamap, hDlg, pCurrentOpts, IDC_SCREEN);
@@ -1150,13 +1133,14 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
strcmp(options_get_string(pCurrentOpts, "screen1"), options_get_string(pOrigOpts, "screen1")!=0) ||
strcmp(options_get_string(pCurrentOpts, "screen2"), options_get_string(pOrigOpts, "screen2")!=0) ||
strcmp(options_get_string(pCurrentOpts, "screen3"), options_get_string(pOrigOpts, "screen3")!=0))
- changed = TRUE;
+ changed = true;
************************************* */
}
break;
default:
#ifdef MESS
if (MessPropertiesCommand(hDlg, wNotifyCode, wID, &changed))
+ // To Do: add a hook to MessReadMountedSoftware(drvindex); so the software will update itself when the folder is configured
break;
#endif
@@ -1177,13 +1161,13 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
break;
}
- if (changed == TRUE)
+ if (changed == true)
{
// make sure everything's copied over, to determine what's changed
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// enable the apply button
PropSheet_Changed(GetParent(hDlg), hDlg);
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
@@ -1203,7 +1187,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
case PSN_SETACTIVE:
/* Initialize the controls. */
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
@@ -1216,7 +1200,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
//if (bClosing)
//{
//if (NULL == pCurrentOpts)
- //return TRUE;
+ //return true;
//}
// Read the datamap
@@ -1227,7 +1211,7 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
// Repopulate the controls? WTF? We just read them, they should be fine.
UpdateProperties(hDlg, properties_datamap, pCurrentOpts);
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
@@ -1239,29 +1223,29 @@ INT_PTR CALLBACK GameOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar
PropSheet_UnChanged(GetParent(hDlg), hDlg);
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
- return TRUE;
+ return true;
case PSN_KILLACTIVE:
/* Save Changes to the options here. */
UpdateOptions(hDlg, properties_datamap, pCurrentOpts);
// Determine button states.
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
ResetDataMap(hDlg);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
+ SetWindowLongPtr(hDlg, DWLP_MSGRESULT, false);
return 1;
case PSN_RESET:
// Reset to the original values. Disregard changes
//pCurrentOpts = pOrigOpts;
- g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts);
+ g_bUseDefaults = AreOptionsEqual(pCurrentOpts, pDefaultOpts) ? false : true;
g_bReset = AreOptionsEqual(pCurrentOpts, pOrigOpts) ? false : true;
EnableWindow(GetDlgItem(hDlg, IDC_USE_DEFAULT), g_bUseDefaults);
EnableWindow(GetDlgItem(hDlg, IDC_PROP_RESET), g_bReset);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
+ SetWindowLongPtr(hDlg, DWLP_MSGRESULT, false);
break;
case PSN_HELP:
@@ -1383,7 +1367,6 @@ static void UpdateProperties(HWND hDlg, datamap *map, windows_options &opts)
/* Populate controls that are not handled in the DataMap */
static void OptionsToProp(HWND hWnd, windows_options& o)
{
- HWND hCtrl;
HWND hCtrl2;
TCHAR buf[100];
int n = 0;
@@ -1399,7 +1382,7 @@ static void OptionsToProp(HWND hWnd, windows_options& o)
/* Setup Select screen*/
UpdateSelectScreenUI(hWnd );
- hCtrl = GetDlgItem(hWnd, IDC_ASPECT);
+ HWND hCtrl = GetDlgItem(hWnd, IDC_ASPECT);
if (hCtrl)
{
Button_SetCheck(hCtrl, g_bAutoAspect[GetSelectedScreen(hWnd)] ) ;
@@ -1438,13 +1421,13 @@ static void OptionsToProp(HWND hWnd, windows_options& o)
snprintf(aspect_option, ARRAY_LENGTH(aspect_option), "aspect%d", GetSelectedScreen(hWnd));
if( strcmp(o.value(aspect_option), "auto") == 0)
{
- Button_SetCheck(hCtrl, TRUE);
- g_bAutoAspect[GetSelectedScreen(hWnd)] = TRUE;
+ Button_SetCheck(hCtrl, true);
+ g_bAutoAspect[GetSelectedScreen(hWnd)] = true;
}
else
{
- Button_SetCheck(hCtrl, FALSE);
- g_bAutoAspect[GetSelectedScreen(hWnd)] = FALSE;
+ Button_SetCheck(hCtrl, false);
+ g_bAutoAspect[GetSelectedScreen(hWnd)] = false;
}
}
@@ -1493,13 +1476,13 @@ static void OptionsToProp(HWND hWnd, windows_options& o)
{
if( strcmp(o.value(OPTION_SNAPSIZE), "auto") == 0)
{
- Button_SetCheck(hCtrl, TRUE);
- g_bAutoSnapSize = TRUE;
+ Button_SetCheck(hCtrl, true);
+ g_bAutoSnapSize = true;
}
else
{
- Button_SetCheck(hCtrl, FALSE);
- g_bAutoSnapSize = FALSE;
+ Button_SetCheck(hCtrl, false);
+ g_bAutoSnapSize = false;
}
}
/* snapshot size */
@@ -1536,17 +1519,19 @@ static void OptionsToProp(HWND hWnd, windows_options& o)
/* Adjust controls - tune them to the currently selected game */
static void SetPropEnabledControls(HWND hWnd)
{
- //HWND hCtrl;
- bool useart = TRUE;
- BOOL joystick_attached = FALSE;
- bool in_window = FALSE;
+ bool useart = true;
+ BOOL joystick_attached = false;
+ bool in_window = false;
int nIndex = g_nGame;
// auto is a reserved word
bool autov = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "auto")==0);
bool d3d = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "d3d")==0) | autov;
- bool ddraw = 0;//(core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "ddraw")==0) | autov;
- //bool gdi = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "gdi")==0) | autov;
+#ifdef UI_DIRECTDRAW
+ bool ddraw = (core_stricmp(pCurrentOpts.value(OSDOPTION_VIDEO), "ddraw")==0) | autov;
+#else
+ bool ddraw = false;
+#endif
in_window = pCurrentOpts.bool_value(OSDOPTION_WINDOW);
Button_SetCheck(GetDlgItem(hWnd, IDC_ASPECT), g_bAutoAspect[GetSelectedScreen(hWnd)] );
@@ -1556,9 +1541,13 @@ static void SetPropEnabledControls(HWND hWnd)
EnableWindow(GetDlgItem(hWnd, IDC_PRESCALE), d3d|ddraw);
EnableWindow(GetDlgItem(hWnd, IDC_PRESCALEDISP), d3d|ddraw);
EnableWindow(GetDlgItem(hWnd, IDC_PRESCALETEXT), d3d|ddraw);
+#ifdef UI_DIRECTDRAW
EnableWindow(GetDlgItem(hWnd, IDC_HWSTRETCH), ddraw && DirectDraw_HasHWStretch());
- EnableWindow(GetDlgItem(hWnd, IDC_SWITCHRES), TRUE);
- EnableWindow(GetDlgItem(hWnd, IDC_SYNCREFRESH), TRUE);
+#else
+ EnableWindow(GetDlgItem(hWnd, IDC_HWSTRETCH), false);
+#endif
+ EnableWindow(GetDlgItem(hWnd, IDC_SWITCHRES), true);
+ EnableWindow(GetDlgItem(hWnd, IDC_SYNCREFRESH), true);
EnableWindow(GetDlgItem(hWnd, IDC_REFRESH), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_REFRESHTEXT), !in_window);
EnableWindow(GetDlgItem(hWnd, IDC_FSGAMMA), !in_window);
@@ -1580,11 +1569,12 @@ static void SetPropEnabledControls(HWND hWnd)
EnableWindow(GetDlgItem(hWnd, IDC_SNAPSIZEWIDTH), !g_bAutoSnapSize);
EnableWindow(GetDlgItem(hWnd, IDC_SNAPSIZEX), !g_bAutoSnapSize);
- EnableWindow(GetDlgItem(hWnd,IDC_D3D_FILTER),d3d);
- EnableWindow(GetDlgItem(hWnd,IDC_D3D_VERSION),(NUMD3DVERSIONS>1) & d3d);
+ EnableWindow(GetDlgItem(hWnd, IDC_D3D_FILTER),d3d);
+#ifdef D3DVERSION
+ EnableWindow(GetDlgItem(hWnd, IDC_D3D_VERSION),(NUMD3DVERSIONS>1) & d3d);
+#endif
//Switchres and D3D or ddraw enable the per screen parameters
-
EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENS), ddraw | d3d);
EnableWindow(GetDlgItem(hWnd, IDC_NUMSCREENSDISP), ddraw | d3d);
EnableWindow(GetDlgItem(hWnd, IDC_SCREENSELECT), ddraw | d3d);
@@ -1610,9 +1600,9 @@ static void SetPropEnabledControls(HWND hWnd)
EnableWindow(GetDlgItem(hWnd, IDC_JSAT), joystick_attached);
/* Trackball / Mouse options */
if (nIndex <= -1 || DriverUsesTrackball(nIndex) || DriverUsesLightGun(nIndex))
- Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),TRUE);
+ Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),true);
else
- Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),FALSE);
+ Button_Enable(GetDlgItem(hWnd,IDC_USE_MOUSE),false);
if (!in_window && (nIndex <= -1 || DriverUsesLightGun(nIndex)))
{
@@ -1635,16 +1625,16 @@ static void SetPropEnabledControls(HWND hWnd)
{
BOOL use_lightgun;
//XP and above...
- Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),FALSE);
+ Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),false);
use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_USE_MOUSE));
- Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),FALSE);
+ Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),false);
Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun);
}
else
{
BOOL use_lightgun;
// Older than XP
- Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),TRUE);
+ Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),true);
use_lightgun = Button_GetCheck(GetDlgItem(hWnd,IDC_LIGHTGUN));
Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),use_lightgun);
Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),use_lightgun);
@@ -1652,9 +1642,9 @@ static void SetPropEnabledControls(HWND hWnd)
}
else
{
- Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),FALSE);
- Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),FALSE);
- Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),FALSE);
+ Button_Enable(GetDlgItem(hWnd,IDC_LIGHTGUN),false);
+ Button_Enable(GetDlgItem(hWnd,IDC_DUAL_LIGHTGUN),false);
+ Button_Enable(GetDlgItem(hWnd,IDC_RELOAD),false);
}
@@ -1671,14 +1661,14 @@ static void SetPropEnabledControls(HWND hWnd)
SetSamplesEnabled(hWnd, nIndex, sound);
if (Button_GetCheck(GetDlgItem(hWnd, IDC_AUTOFRAMESKIP)))
- EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), FALSE);
+ EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), false);
else
EnableWindow(GetDlgItem(hWnd, IDC_FRAMESKIP), 1);
if (nIndex <= -1 || DriverHasOptionalBIOS(nIndex))
- EnableWindow(GetDlgItem(hWnd,IDC_BIOS),TRUE);
+ EnableWindow(GetDlgItem(hWnd,IDC_BIOS),true);
else
- EnableWindow(GetDlgItem(hWnd,IDC_BIOS),FALSE);
+ EnableWindow(GetDlgItem(hWnd,IDC_BIOS),false);
}
@@ -1703,7 +1693,7 @@ static BOOL RotateReadControl(datamap *map, HWND dialog, HWND control, windows_o
else if (opts->bool_value(OPTION_AUTOROL))
original_selection = 5;
- // Any work to do? If so, make the changes and return TRUE.
+ // Any work to do? If so, make the changes and return true.
if (selected_index != original_selection)
{
// Set the options based on the new selection.
@@ -1712,11 +1702,11 @@ static BOOL RotateReadControl(datamap *map, HWND dialog, HWND control, windows_o
opts->set_value(OPTION_ROTATE, selected_index != 3, OPTION_PRIORITY_CMDLINE);
opts->set_value(OPTION_AUTOROR, selected_index == 4, OPTION_PRIORITY_CMDLINE);
opts->set_value(OPTION_AUTOROL, selected_index == 5, OPTION_PRIORITY_CMDLINE);
- return TRUE;
+ return true;
}
// No changes
- return FALSE;
+ return false;
}
@@ -1737,7 +1727,7 @@ static BOOL RotatePopulateControl(datamap *map, HWND dialog, HWND control, windo
res = ComboBox_SetCurSel(control, selected_index);
res++;
- return FALSE;
+ return false;
}
@@ -1745,19 +1735,14 @@ static BOOL RotatePopulateControl(datamap *map, HWND dialog, HWND control, windo
static BOOL ScreenReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
char screen_option_name[32];
- TCHAR *screen_option_value;
- int selected_screen;
- int screen_option_index;
- char *op_val;
-
- selected_screen = GetSelectedScreen(dialog);
- screen_option_index = ComboBox_GetCurSel(control);
- screen_option_value = (TCHAR*) ComboBox_GetItemData(control, screen_option_index);
+ int selected_screen = GetSelectedScreen(dialog);
+ int screen_option_index = ComboBox_GetCurSel(control);
+ TCHAR *screen_option_value = (TCHAR*) ComboBox_GetItemData(control, screen_option_index);
snprintf(screen_option_name, ARRAY_LENGTH(screen_option_name), "screen%d", selected_screen);
- op_val = ui_utf8_from_wstring(screen_option_value);
+ char *op_val = ui_utf8_from_wstring(screen_option_value);
opts->set_value(screen_option_name, op_val, OPTION_PRIORITY_CMDLINE);
free(op_val);
- return FALSE;
+ return false;
}
@@ -1792,7 +1777,7 @@ static BOOL ScreenPopulateControl(datamap *map, HWND dialog, HWND control, windo
snprintf(screen_option, ARRAY_LENGTH(screen_option), "screen%d", GetSelectedScreen(dialog));
t_option = ui_wstring_from_utf8(opts->value(screen_option));
if( !t_option )
- return FALSE;
+ return false;
if (_tcscmp(t_option, dd.DeviceName) == 0)
nSelection = i+1;
free(t_option);
@@ -1800,7 +1785,7 @@ static BOOL ScreenPopulateControl(datamap *map, HWND dialog, HWND control, windo
}
res = ComboBox_SetCurSel(control, nSelection);
res++;
- return FALSE;
+ return false;
}
@@ -1812,17 +1797,15 @@ static void ViewSetOptionName(datamap *map, HWND dialog, HWND control, char *buf
static BOOL ViewPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
- int res, i;
int selected_index = 0;
char view_option[32];
- const char *view;
// determine the view option value
snprintf(view_option, ARRAY_LENGTH(view_option), "view%d", GetSelectedScreen(dialog));
- view = opts->value(view_option);
+ const char *view = opts->value(view_option);
- res = ComboBox_ResetContent(control);
- for (i = 0; i < NUMVIEW; i++)
+ int res = ComboBox_ResetContent(control);
+ for (int i = 0; i < NUMVIEW; i++)
{
res = ComboBox_InsertString(control, i, g_ComboBoxView[i].m_pText);
res = ComboBox_SetItemData(control, i, g_ComboBoxView[i].m_pData);
@@ -1832,20 +1815,18 @@ static BOOL ViewPopulateControl(datamap *map, HWND dialog, HWND control, windows
}
res = ComboBox_SetCurSel(control, selected_index);
res++;
- return FALSE;
+ return false;
}
static BOOL SnapViewPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
- int res, i;
int selected_index = 0;
- const char *snapview;
// determine the snapview option value
- snapview = opts->value(OPTION_SNAPVIEW);
+ const char *snapview = opts->value(OPTION_SNAPVIEW);
- res = ComboBox_ResetContent(control);
- for (i = 0; i < NUMSNAPVIEW; i++)
+ int res = ComboBox_ResetContent(control);
+ for (int i = 0; i < NUMSNAPVIEW; i++)
{
res = ComboBox_InsertString(control, i, g_ComboBoxSnapView[i].m_pText);
res = ComboBox_SetItemData(control, i, g_ComboBoxSnapView[i].m_pData);
@@ -1855,70 +1836,60 @@ static BOOL SnapViewPopulateControl(datamap *map, HWND dialog, HWND control, win
}
res = ComboBox_SetCurSel(control, selected_index);
res++;
- return FALSE;
+ return false;
}
static BOOL DefaultInputReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
- TCHAR *input_option_value;
- int input_option_index;
- char *op_val = NULL;
-
- input_option_index = ComboBox_GetCurSel(control);
- input_option_value = (TCHAR*) ComboBox_GetItemData(control, input_option_index);
- op_val = ui_utf8_from_wstring(input_option_value);
+ int input_option_index = ComboBox_GetCurSel(control);
+ TCHAR *input_option_value = (TCHAR*) ComboBox_GetItemData(control, input_option_index);
+ char *op_val = ui_utf8_from_wstring(input_option_value);
opts->set_value(OPTION_CTRLR, input_option_index ? op_val : "", OPTION_PRIORITY_CMDLINE);
free(op_val);
- return FALSE;
+ return false;
}
static BOOL DefaultInputPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
- WIN32_FIND_DATA FindFileData;
- HANDLE hFind;
- TCHAR *ext;
TCHAR root[256];
TCHAR path[256];
int selected = 0;
- int res, index = 0;
+ int index = 0;
LPCTSTR t_ctrlr_option = 0;
LPTSTR t_buf = 0;
- const char *ctrlr_option;
- TCHAR* t_ctrldir;
// determine the ctrlr option
- ctrlr_option = opts->value(OPTION_CTRLR);
+ const char *ctrlr_option = opts->value(OPTION_CTRLR);
if( ctrlr_option )
{
t_buf = ui_wstring_from_utf8(ctrlr_option);
if( !t_buf )
- return FALSE;
+ return false;
t_ctrlr_option = t_buf;
}
else
- {
t_ctrlr_option = TEXT("");
- }
// reset the controllers dropdown
- res = ComboBox_ResetContent(control);
+ int res = ComboBox_ResetContent(control);
res = ComboBox_InsertString(control, index, TEXT("Default"));
res = ComboBox_SetItemData(control, index, "");
index++;
- t_ctrldir = ui_wstring_from_utf8(GetCtrlrDir());
+ TCHAR *t_ctrldir = ui_wstring_from_utf8(GetCtrlrDir());
if( !t_ctrldir )
{
if( t_buf )
free(t_buf);
- return FALSE;
+ return false;
}
_stprintf (path, TEXT("%s\\*.*"), t_ctrldir);
free(t_ctrldir);
- hFind = FindFirstFile(path, &FindFileData);
+ WIN32_FIND_DATA FindFileData;
+ HANDLE hFind = FindFirstFile(path, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
{
@@ -1928,7 +1899,7 @@ static BOOL DefaultInputPopulateControl(datamap *map, HWND dialog, HWND control,
_tcscpy (root,FindFileData.cFileName);
// find the extension
- ext = _tcsrchr (root,'.');
+ TCHAR *ext = _tcsrchr (root,'.');
if (ext)
{
// check if it's a cfg file
@@ -1959,7 +1930,7 @@ static BOOL DefaultInputPopulateControl(datamap *map, HWND dialog, HWND control,
free(t_buf);
res++;
- return FALSE;
+ return false;
}
@@ -1974,27 +1945,26 @@ static BOOL ResolutionReadControl(datamap *map, HWND dialog, HWND control, windo
{
HWND refresh_control = GetDlgItem(dialog, IDC_REFRESH);
HWND sizes_control = GetDlgItem(dialog, IDC_SIZES);
- int res = 0, refresh_index = 0, refresh_value = 0, width = 0, height = 0;
+ int res = 0, width = 0, height = 0;
char option_value[256];
- TCHAR buffer[256];
if (refresh_control && sizes_control)
{
+ TCHAR buffer[256];
res = ComboBox_GetText(sizes_control, buffer, ARRAY_LENGTH(buffer) - 1);
if (_stscanf(buffer, TEXT("%d x %d"), &width, &height) == 2)
{
- refresh_index = ComboBox_GetCurSel(refresh_control);
- refresh_value = ComboBox_GetItemData(refresh_control, refresh_index);
+ int refresh_index = ComboBox_GetCurSel(refresh_control);
+ int refresh_value = ComboBox_GetItemData(refresh_control, refresh_index);
snprintf(option_value, ARRAY_LENGTH(option_value), "%dx%d@%d", width, height, refresh_value);
}
else
- {
snprintf(option_value, ARRAY_LENGTH(option_value), "auto");
- }
+
opts->set_value(option_name, option_value, OPTION_PRIORITY_CMDLINE);
}
res++;
- return FALSE;
+ return false;
}
@@ -2088,7 +2058,7 @@ static BOOL ResolutionPopulateControl(datamap *map, HWND dialog, HWND control_,
res = ComboBox_SetCurSel(refresh_control, refresh_selection);
}
res++;
- return FALSE;
+ return false;
}
@@ -2231,7 +2201,9 @@ static void BuildDataMap(void)
datamap_add(properties_datamap, IDC_SYNCREFRESH, DM_BOOL, OSDOPTION_SYNCREFRESH);
// Direct3D specific options
+#ifdef D3DVERSION
datamap_add(properties_datamap, IDC_D3D_VERSION, DM_INT, WINOPTION_D3DVERSION);
+#endif
datamap_add(properties_datamap, IDC_D3D_FILTER, DM_BOOL, OSDOPTION_FILTER);
// per window video options
@@ -2332,10 +2304,8 @@ static void BuildDataMap(void)
static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled)
{
- BOOL enabled = FALSE;
- HWND hCtrl;
-
- hCtrl = GetDlgItem(hWnd, IDC_SAMPLES);
+ BOOL enabled = false;
+ HWND hCtrl = GetDlgItem(hWnd, IDC_SAMPLES);
if (hCtrl)
@@ -2347,7 +2317,7 @@ static void SetSamplesEnabled(HWND hWnd, int nIndex, BOOL bSoundEnabled)
for (device_sound_interface &sound : sound_interface_iterator(config.root_device()))
{
if (sound.device().type() == SAMPLES)
- enabled = TRUE;
+ enabled = true;
}
}
enabled = enabled && bSoundEnabled;
@@ -2364,7 +2334,9 @@ static void InitializeOptions(HWND hDlg)
InitializeSelectScreenUI(hDlg);
InitializeBIOSUI(hDlg);
InitializeControllerMappingUI(hDlg);
+#ifdef D3DVERSION
InitializeD3DVersionUI(hDlg);
+#endif
InitializeVideoUI(hDlg);
}
@@ -2402,10 +2374,9 @@ static void RefreshSelectionChange(HWND hWnd, HWND hWndCtrl)
/* Initialize the sound options */
static void InitializeSoundUI(HWND hwnd)
{
- HWND hCtrl;
int res = 0, i;
- hCtrl = GetDlgItem(hwnd, IDC_SOUND_MODE);
+ HWND hCtrl = GetDlgItem(hwnd, IDC_SOUND_MODE);
if (hCtrl)
{
for (i = 0; i < NUMSOUND; i++)
@@ -2488,14 +2459,12 @@ static void InitializeRotateUI(HWND hwnd)
/* Populate the Video Mode drop down */
static void InitializeVideoUI(HWND hwnd)
{
- HWND hCtrl;
int res = 0;
- hCtrl = GetDlgItem(hwnd, IDC_VIDEO_MODE);
+ HWND hCtrl = GetDlgItem(hwnd, IDC_VIDEO_MODE);
if (hCtrl)
{
- int i;
- for (i = 0; i < NUMVIDEO; i++)
+ for (int i = 0; i < NUMVIDEO; i++)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxVideo[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxVideo[i].m_pData);
@@ -2504,14 +2473,15 @@ static void InitializeVideoUI(HWND hwnd)
res++;
}
+#ifdef D3DVERSION
/* Populate the D3D Version drop down */
static void InitializeD3DVersionUI(HWND hwnd)
{
HWND hCtrl = GetDlgItem(hwnd, IDC_D3D_VERSION);
- int res = 0, i;
+ int res = 0;
if (hCtrl)
{
- for (i = 0; i < NUMD3DVERSIONS; i++)
+ for (int i = 0; i < NUMD3DVERSIONS; i++)
{
res = ComboBox_InsertString(hCtrl, i, g_ComboBoxD3DVersion[i].m_pText);
res = ComboBox_SetItemData( hCtrl, i, g_ComboBoxD3DVersion[i].m_pData);
@@ -2519,7 +2489,7 @@ static void InitializeD3DVersionUI(HWND hwnd)
}
res++;
}
-
+#endif
static void UpdateSelectScreenUI(HWND hwnd)
{
int res = 0, i, curSel;
@@ -2552,7 +2522,7 @@ static void InitializeSelectScreenUI(HWND hwnd)
static void InitializeControllerMappingUI(HWND hwnd)
{
- int res = 0, i;
+ int res = 0;
HWND hCtrl = GetDlgItem(hwnd,IDC_PADDLE);
HWND hCtrl1 = GetDlgItem(hwnd,IDC_ADSTICK);
HWND hCtrl2 = GetDlgItem(hwnd,IDC_PEDAL);
@@ -2562,7 +2532,7 @@ static void InitializeControllerMappingUI(HWND hwnd)
HWND hCtrl6 = GetDlgItem(hwnd,IDC_LIGHTGUNDEVICE);
HWND hCtrl7 = GetDlgItem(hwnd,IDC_POSITIONAL);
- for (i = 0; i < NUMDEVICES; i++)
+ for (int i = 0; i < NUMDEVICES; i++)
{
if (hCtrl)
{
@@ -2635,7 +2605,7 @@ static void InitializeBIOSUI(HWND hwnd)
if (g_nGame == LOCAL_OPTIONS) //Folder Options: This is the only place that LOCAL_OPTIONS is used, is this code ever executed?
{
gamedrv = &driver_list::driver(g_nFolderGame);
- if (DriverHasOptionalBIOS(g_nFolderGame) == FALSE)
+ if (DriverHasOptionalBIOS(g_nFolderGame) == false)
{
res = ComboBox_InsertString(hCtrl, i, TEXT("None"));
res = ComboBox_SetItemData( hCtrl, i++, "");
@@ -2665,7 +2635,7 @@ static void InitializeBIOSUI(HWND hwnd)
return;
}
- if (DriverHasOptionalBIOS(g_nGame) == FALSE)
+ if (DriverHasOptionalBIOS(g_nGame) == false)
{
res = ComboBox_InsertString(hCtrl, i, TEXT("None"));
res = ComboBox_SetItemData( hCtrl, i++, "");
@@ -2699,7 +2669,7 @@ static void InitializeBIOSUI(HWND hwnd)
static BOOL SelectEffect(HWND hWnd)
{
char filename[MAX_PATH];
- BOOL changed = FALSE;
+ BOOL changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_EFFECT_FILES))
@@ -2714,10 +2684,9 @@ static BOOL SelectEffect(HWND hWnd)
if( filename[i] == '.' )
k = i;
}
- for(i=j+1;i<k;i++)
- {
+ for(i=j+1; i<k; i++)
buff[l++] = filename[i];
- }
+
buff[l] = '\0';
if (strcmp(buff, pCurrentOpts.value(OPTION_EFFECT))!=0)
@@ -2726,7 +2695,7 @@ static BOOL SelectEffect(HWND hWnd)
pCurrentOpts.set_value(OPTION_EFFECT, buff, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, buff);
// datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_EFFECT);
- changed = TRUE;
+ changed = true;
}
}
return changed;
@@ -2734,7 +2703,7 @@ static BOOL SelectEffect(HWND hWnd)
static BOOL ResetEffect(HWND hWnd)
{
- BOOL changed = FALSE;
+ BOOL changed = false;
const char *new_value = "none";
if (strcmp(new_value, pCurrentOpts.value(OPTION_EFFECT))!=0)
@@ -2743,7 +2712,7 @@ static BOOL ResetEffect(HWND hWnd)
pCurrentOpts.set_value(OPTION_EFFECT, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, new_value);
// datamap_populate_control(properties_datamap, hWnd, pCurrentOpts, IDC_EFFECT);
- changed = TRUE;
+ changed = true;
}
return changed;
}
@@ -2751,7 +2720,7 @@ static BOOL ResetEffect(HWND hWnd)
static BOOL SelectJoystickMap(HWND hWnd)
{
char filename[MAX_PATH];
- BOOL changed = FALSE;
+ BOOL changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_JOYMAP_FILES))
@@ -2761,7 +2730,7 @@ static BOOL SelectJoystickMap(HWND hWnd)
HWND control = GetDlgItem(hWnd, IDC_JOYSTICKMAP);
pCurrentOpts.set_value(OPTION_JOYSTICK_MAP, filename, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, filename);
- changed = TRUE;
+ changed = true;
}
}
return changed;
@@ -2769,7 +2738,7 @@ static BOOL SelectJoystickMap(HWND hWnd)
static BOOL ResetJoystickMap(HWND hWnd)
{
- BOOL changed = FALSE;
+ BOOL changed = false;
const char *new_value = "auto";
if (strcmp(new_value, pCurrentOpts.value(OPTION_JOYSTICK_MAP))!=0)
@@ -2777,7 +2746,7 @@ static BOOL ResetJoystickMap(HWND hWnd)
HWND control = GetDlgItem(hWnd, IDC_JOYSTICKMAP);
pCurrentOpts.set_value(OPTION_JOYSTICK_MAP, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, new_value);
- changed = TRUE;
+ changed = true;
}
return changed;
}
@@ -2785,7 +2754,7 @@ static BOOL ResetJoystickMap(HWND hWnd)
static BOOL SelectDebugscript(HWND hWnd)
{
char filename[MAX_PATH];
- BOOL changed = FALSE;
+ BOOL changed = false;
*filename = 0;
if (CommonFileDialog(GetOpenFileName, filename, FILETYPE_DEBUGSCRIPT_FILES))
@@ -2795,7 +2764,7 @@ static BOOL SelectDebugscript(HWND hWnd)
HWND control = GetDlgItem(hWnd, IDC_DEBUGSCRIPT);
pCurrentOpts.set_value(OPTION_DEBUGSCRIPT, filename, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, filename);
- changed = TRUE;
+ changed = true;
}
}
return changed;
@@ -2803,7 +2772,7 @@ static BOOL SelectDebugscript(HWND hWnd)
static BOOL ResetDebugscript(HWND hWnd)
{
- BOOL changed = FALSE;
+ BOOL changed = false;
const char *new_value = "";
if (strcmp(new_value, pCurrentOpts.value(OPTION_DEBUGSCRIPT))!=0)
@@ -2811,7 +2780,7 @@ static BOOL ResetDebugscript(HWND hWnd)
HWND control = GetDlgItem(hWnd, IDC_DEBUGSCRIPT);
pCurrentOpts.set_value(OPTION_DEBUGSCRIPT, new_value, OPTION_PRIORITY_CMDLINE);
win_set_window_text_utf8(control, new_value);
- changed = TRUE;
+ changed = true;
}
return changed;
}
@@ -2827,19 +2796,17 @@ void UpdateBackgroundBrush(HWND hwndTab)
// Only do this if the theme is active
if (SafeIsAppThemed())
{
- RECT rc;
- HDC hDC, hDCMem;
- HBITMAP hBmp, hBmpOld;
// Get tab control dimensions
+ RECT rc;
GetWindowRect( hwndTab, &rc);
// Get the tab control DC
- hDC = GetDC(hwndTab);
+ HDC hDC = GetDC(hwndTab);
// Create a compatible DC
- hDCMem = CreateCompatibleDC(hDC);
- hBmp = CreateCompatibleBitmap(hDC, rc.right - rc.left, rc.bottom - rc.top);
- hBmpOld = (HBITMAP)(SelectObject(hDCMem, hBmp));
+ HDC hDCMem = CreateCompatibleDC(hDC);
+ HBITMAP hBmp = CreateCompatibleBitmap(hDC, rc.right - rc.left, rc.bottom - rc.top);
+ HBITMAP hBmpOld = (HBITMAP)(SelectObject(hDCMem, hBmp));
// Tell the tab control to paint in our DC
SendMessage(hwndTab, WM_PRINTCLIENT, (WPARAM)(hDCMem), (LPARAM)(PRF_ERASEBKGND | PRF_CLIENT | PRF_NONCLIENT));
@@ -2870,12 +2837,11 @@ void UpdateBackgroundBrush(HWND hwndTab)
static void AppendList(HWND hList, LPCTSTR lpItem, int nItem)
{
LV_ITEM Item;
- HRESULT res;
memset(&Item, 0, sizeof(LV_ITEM));
Item.mask = LVIF_TEXT;
Item.pszText = (LPTSTR) lpItem;
Item.iItem = nItem;
- res = ListView_InsertItem(hList, &Item);
+ HRESULT res = ListView_InsertItem(hList, &Item);
res++;
}
@@ -2884,7 +2850,7 @@ static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_
int directory_count;
LV_ITEM lvi;
TCHAR buffer[2048];
- int i, pos = 0;
+ int pos = 0;
BOOL res;
// determine the directory count; note that one item is the "< >" entry
@@ -2894,7 +2860,7 @@ static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_
buffer[0] = '\0';
- for (i = 0; i < directory_count; i++)
+ for (int i = 0; i < directory_count; i++)
{
// append a semicolon, if we're past the first entry
if (i > 0)
@@ -2912,52 +2878,49 @@ static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_
pos += _tcslen(&buffer[pos]);
}
- const char* paths = ui_utf8_from_wstring(buffer);
+ char* paths = ui_utf8_from_wstring(buffer);
if ((buffer[1] == 0x3A) || (buffer[0] == 0)) // must be a folder or null
- {
pCurrentOpts.set_value(OPTION_SWPATH, paths, OPTION_PRIORITY_CMDLINE);
- }
+
+ free (paths);
res++;
- return TRUE;
+ return true;
}
static BOOL DirListPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
- int driver_index, pos, new_pos, current_item;
- TCHAR *s;
- LV_COLUMN lvc;
- RECT r;
- HRESULT res;
- BOOL b_res;
+ int new_pos = 0;
// access the directory list, and convert to TCHARs
- driver_index = PropertiesCurrentGame(dialog);
+ int driver_index = PropertiesCurrentGame(dialog);
windows_options o;
load_options(o, OPTIONS_GAME, driver_index);
const char* paths = o.value(OPTION_SWPATH);
TCHAR* t_dir_list = ui_wstring_from_utf8(paths);
paths = 0;
if (!t_dir_list)
- return FALSE;
+ return false;
// delete all items in the list control
- b_res = ListView_DeleteAllItems(control);
+ BOOL b_res = ListView_DeleteAllItems(control);
// add the column
+ RECT r;
GetClientRect(control, &r);
+ LV_COLUMN lvc;
memset(&lvc, 0, sizeof(LVCOLUMN));
lvc.mask = LVCF_WIDTH;
lvc.cx = r.right - r.left - GetSystemMetrics(SM_CXHSCROLL);
- res = ListView_InsertColumn(control, 0, &lvc);
+ HRESULT res = ListView_InsertColumn(control, 0, &lvc);
// add each of the directories
- pos = 0;
- current_item = 0;
+ int pos = 0;
+ int current_item = 0;
while(t_dir_list[pos] != '\0')
{
// parse off this item
- s = _tcschr(&t_dir_list[pos], ';');
+ TCHAR *s = _tcschr(&t_dir_list[pos], ';');
if (s)
{
*s = '\0';
@@ -2980,7 +2943,7 @@ static BOOL DirListPopulateControl(datamap *map, HWND dialog, HWND control, wind
free(t_dir_list);
res++;
b_res++;
- return TRUE;
+ return true;
}
@@ -3019,13 +2982,13 @@ static uint32_t parse_string(const char *s)
unsigned multiple;
} s_suffixes[] =
{
- { "", 1 },
- { "k", 1024 },
- { "kb", 1024 },
- { "kib", 1024 },
- { "m", 1024 * 1024 },
- { "mb", 1024 * 1024 },
- { "mib", 1024 * 1024 }
+ { "", 1 },
+ { "k", 1024 },
+ { "kb", 1024 },
+ { "kib", 1024 },
+ { "m", 1024 * 1024 },
+ { "mb", 1024 * 1024 },
+ { "mib", 1024 * 1024 }
};
// parse the string
@@ -3034,15 +2997,11 @@ static uint32_t parse_string(const char *s)
sscanf(s, "%u%7s", &ram, suffix);
// perform the lookup
- auto iter = std::find_if(
- std::begin(s_suffixes),
- std::end(s_suffixes),
- [&suffix](const auto &potential_suffix) { return !core_stricmp(suffix, potential_suffix.suffix); });
+ auto iter = std::find_if(std::begin(s_suffixes), std::end(s_suffixes), [&suffix](const auto &potential_suffix)
+ { return !core_stricmp(suffix, potential_suffix.suffix); } );
// identify the multiplier (or 0 if not recognized, signalling a parse failure)
- unsigned multiple = iter != std::end(s_suffixes)
- ? iter->multiple
- : 0;
+ unsigned multiple = iter != std::end(s_suffixes) ? iter->multiple : 0;
// return the result
return ram * multiple;
@@ -3050,19 +3009,14 @@ static uint32_t parse_string(const char *s)
static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
- int res = 0, i = 0, current_index = 0, driver_index;
- const game_driver *gamedrv;
- uint32_t ram, current_ram;
- const char *this_ram_string;
- TCHAR* t_ramstring;
- char ramtext[20];
+ int i = 0, current_index = 0;
// identify the driver
- driver_index = PropertiesCurrentGame(dialog);
- gamedrv = &driver_list::driver(driver_index);
+ int driver_index = PropertiesCurrentGame(dialog);
+ const game_driver *gamedrv = &driver_list::driver(driver_index);
// clear out the combo box
- res = ComboBox_ResetContent(control);
+ int res = ComboBox_ResetContent(control);
// allocate the machine config
machine_config cfg(*gamedrv,*opts);
@@ -3079,16 +3033,17 @@ static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_
const ram_device *ramdev = dynamic_cast<const ram_device *>(device);
// identify the current amount of RAM
- this_ram_string = opts->value(OPTION_RAMSIZE);
- current_ram = (this_ram_string != NULL) ? parse_string(this_ram_string) : 0;
- ram = ramdev->default_size();
+ const char *this_ram_string = opts->value(OPTION_RAMSIZE);
+ uint32_t current_ram = (this_ram_string) ? parse_string(this_ram_string) : 0;
+ uint32_t ram = ramdev->default_size();
if (current_ram == 0)
current_ram = ram;
+ char ramtext[20];
messram_string(ramtext, ram);
- t_ramstring = ui_wstring_from_utf8(ramtext);
+ TCHAR *t_ramstring = ui_wstring_from_utf8(ramtext);
if( !t_ramstring )
- return FALSE;
+ return false;
res = ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
res = ComboBox_SetItemData(control, i, ram);
@@ -3106,7 +3061,7 @@ static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_
t_ramstring = ui_wstring_from_utf8(ramtext);
if( !t_ramstring )
- return FALSE;
+ return false;
// add this option to the combo box
res = ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
@@ -3123,40 +3078,36 @@ static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_
res = ComboBox_SetCurSel(control, current_index);
}
res++;
- return TRUE;
+ return true;
}
static void MarkChanged(HWND hDlg)
{
- HWND hCtrl;
-
/* fake a CBN_SELCHANGE event from IDC_SIZES to force it to be changed */
- hCtrl = GetDlgItem(hDlg, IDC_SIZES);
+ HWND hCtrl = GetDlgItem(hDlg, IDC_SIZES);
PostMessage(hDlg, WM_COMMAND, (CBN_SELCHANGE << 16) | IDC_SIZES, (LPARAM) hCtrl);
}
static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR lpItem)
{
- int nItem;
TCHAR inbuf[MAX_PATH];
TCHAR outbuf[MAX_PATH];
- HWND hList;
LPTSTR lpIn;
- BOOL res;
+ BOOL res = false;
- g_bModifiedSoftwarePaths = TRUE;
+ g_bModifiedSoftwarePaths = true;
- hList = GetDlgItem(hDlg, IDC_DIR_LIST);
- nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
+ HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
+ int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
if (nItem == -1)
- return FALSE;
+ return false;
/* Last item is placeholder for append */
if (nItem == ListView_GetItemCount(hList) - 1)
- bBrowse = FALSE;
+ bBrowse = false;
if (!lpItem)
{
@@ -3169,7 +3120,7 @@ static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR
lpIn = NULL;
if (!BrowseForDirectory(hDlg, lpIn, outbuf))
- return FALSE;
+ return false;
lpItem = outbuf;
}
@@ -3179,35 +3130,32 @@ static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR
res = ListView_DeleteItem(hList, nItem+1);
MarkChanged(hDlg);
res++;
- return TRUE;
+ return true;
}
static BOOL SoftwareDirectories_OnDelete(HWND hDlg)
{
- int nCount;
- int nSelect;
- int nItem;
+ int nSelect = 0;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
- BOOL res;
- g_bModifiedSoftwarePaths = TRUE;
+ g_bModifiedSoftwarePaths = true;
- nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);
+ int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);
if (nItem == -1)
- return FALSE;
+ return false;
/* Don't delete "Append" placeholder. */
if (nItem == ListView_GetItemCount(hList) - 1)
- return FALSE;
+ return false;
- res = ListView_DeleteItem(hList, nItem);
+ BOOL res = ListView_DeleteItem(hList, nItem);
- nCount = ListView_GetItemCount(hList);
+ int nCount = ListView_GetItemCount(hList);
if (nCount <= 1)
- return FALSE;
+ return false;
/* If the last item was removed, select the item above. */
if (nItem == nCount - 1)
@@ -3218,14 +3166,14 @@ static BOOL SoftwareDirectories_OnDelete(HWND hDlg)
ListView_SetItemState(hList, nSelect, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
MarkChanged(hDlg);
res++;
- return TRUE;
+ return true;
}
static BOOL SoftwareDirectories_OnBeginLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
- BOOL bResult = FALSE;
+ BOOL bResult = false;
NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
LVITEM* pItem = &pDispInfo->item;
HWND hList = GetDlgItem(hDlg, IDC_DIR_LIST);
@@ -3244,7 +3192,7 @@ static BOOL SoftwareDirectories_OnBeginLabelEdit(HWND hDlg, NMHDR* pNMHDR)
static BOOL SoftwareDirectories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
- BOOL bResult = FALSE;
+ BOOL bResult = false;
NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
LVITEM* pItem = &pDispInfo->item;
@@ -3254,18 +3202,18 @@ static BOOL SoftwareDirectories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
/* Don't allow empty entries. */
if (!_tcscmp(pItem->pszText, TEXT("")))
- return FALSE;
+ return false;
/* Check validity of edited directory. */
if ((_tstat(pItem->pszText, &file_stat) == 0) && (file_stat.st_mode & S_IFDIR))
- bResult = TRUE;
+ bResult = true;
else
if (win_message_box_utf8(NULL, "Folder does not exist, continue anyway?", MAMEUINAME, MB_OKCANCEL) == IDOK)
- bResult = TRUE;
+ bResult = true;
}
- if (bResult == TRUE)
- SoftwareDirectories_OnInsertBrowse(hDlg, TRUE, pItem->pszText);
+ if (bResult == true)
+ SoftwareDirectories_OnInsertBrowse(hDlg, true, pItem->pszText);
return bResult;
}
@@ -3273,16 +3221,18 @@ static BOOL SoftwareDirectories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
static BOOL DriverHasDevice(const game_driver *gamedrv, iodevice_t type)
{
- BOOL b = FALSE;
+ BOOL b = false;
// allocate the machine config
machine_config config(*gamedrv,MameUIGlobal());
for (device_image_interface &dev : image_interface_iterator(config.root_device()))
{
+ if (!dev.user_loadable())
+ continue;
if (dev.image_type() == type)
{
- b = TRUE;
+ b = true;
break;
}
}
@@ -3292,13 +3242,13 @@ static BOOL DriverHasDevice(const game_driver *gamedrv, iodevice_t type)
BOOL PropSheetFilter_Config(const machine_config *drv, const game_driver *gamedrv)
{
ram_device_iterator iter(drv->root_device());
- return (iter.first()!=NULL) || DriverHasDevice(gamedrv, IO_PRINTER);
+ return (iter.first()) || DriverHasDevice(gamedrv, IO_PRINTER);
}
INT_PTR CALLBACK GameMessOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
INT_PTR rc = 0;
- BOOL bHandled = FALSE;
+ BOOL bHandled = false;
switch (Msg)
{
@@ -3307,12 +3257,12 @@ INT_PTR CALLBACK GameMessOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
{
case LVN_ENDLABELEDIT:
rc = SoftwareDirectories_OnEndLabelEdit(hDlg, (NMHDR *) lParam);
- bHandled = TRUE;
+ bHandled = true;
break;
case LVN_BEGINLABELEDIT:
rc = SoftwareDirectories_OnBeginLabelEdit(hDlg, (NMHDR *) lParam);
- bHandled = TRUE;
+ bHandled = true;
break;
}
}
@@ -3327,18 +3277,18 @@ INT_PTR CALLBACK GameMessOptionsProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM
BOOL MessPropertiesCommand(HWND hWnd, WORD wNotifyCode, WORD wID, BOOL *changed)
{
- BOOL handled = TRUE;
+ BOOL handled = true;
switch(wID)
{
case IDC_DIR_BROWSE:
if (wNotifyCode == BN_CLICKED)
- *changed = SoftwareDirectories_OnInsertBrowse(hWnd, TRUE, NULL);
+ *changed = SoftwareDirectories_OnInsertBrowse(hWnd, true, NULL);
break;
case IDC_DIR_INSERT:
if (wNotifyCode == BN_CLICKED)
- *changed = SoftwareDirectories_OnInsertBrowse(hWnd, FALSE, NULL);
+ *changed = SoftwareDirectories_OnInsertBrowse(hWnd, false, NULL);
break;
case IDC_DIR_DELETE:
@@ -3347,7 +3297,7 @@ BOOL MessPropertiesCommand(HWND hWnd, WORD wNotifyCode, WORD wID, BOOL *changed)
break;
default:
- handled = FALSE;
+ handled = false;
break;
}
return handled;
@@ -3355,4 +3305,3 @@ BOOL MessPropertiesCommand(HWND hWnd, WORD wNotifyCode, WORD wID, BOOL *changed)
#endif
-
diff --git a/src/osd/winui/screenshot.cpp b/src/osd/winui/screenshot.cpp
index 121f406b37a..e2cfbb0bb07 100644
--- a/src/osd/winui/screenshot.cpp
+++ b/src/osd/winui/screenshot.cpp
@@ -259,22 +259,17 @@ static bool png_read_bitmap_gui(util::core_file &mfile, HGLOBAL *phDIB, HPALETTE
static osd_file::error OpenRawDIBFile(const char *dir_name, const char *filename, util::core_file::ptr &file)
{
- osd_file::error filerr;
-
// clear out result
file = NULL;
// look for the raw file
std::string fname = std::string(dir_name) + PATH_SEPARATOR + std::string(filename);
- filerr = util::core_file::open(fname.c_str(), OPEN_FLAG_READ, file);
-
- return filerr;
+ return util::core_file::open(fname.c_str(), OPEN_FLAG_READ, file);
}
static osd_file::error OpenZipDIBFile(const char *dir_name, const char *zip_name, const char *filename, util::core_file::ptr &file, void **buffer)
{
osd_file::error filerr = osd_file::error::NOT_FOUND;
- util::archive_file::error ziperr;
util::archive_file::ptr zip;
// clear out result
@@ -282,15 +277,12 @@ static osd_file::error OpenZipDIBFile(const char *dir_name, const char *zip_name
// look into zip file
std::string fname = std::string(dir_name) + PATH_SEPARATOR + std::string(zip_name) + ".zip";
- ziperr = util::archive_file::open_zip(fname, zip);
-
- if (ziperr == util::archive_file::error::NONE)
+ if (util::archive_file::open_zip(fname, zip) == util::archive_file::error::NONE)
{
if (zip->search(filename, false) >= 0)
{
*buffer = malloc(zip->current_uncompressed_length());
- ziperr = zip->decompress(*buffer, zip->current_uncompressed_length());
- if (ziperr == util::archive_file::error::NONE)
+ if (zip->decompress(*buffer, zip->current_uncompressed_length()) == util::archive_file::error::NONE)
filerr = util::core_file::open_ram(*buffer, zip->current_uncompressed_length(), OPEN_FLAG_READ, file);
}
zip.reset();
@@ -298,15 +290,12 @@ static osd_file::error OpenZipDIBFile(const char *dir_name, const char *zip_name
else
{
fname = std::string(dir_name) + PATH_SEPARATOR + std::string(zip_name) + ".7z";
- ziperr = util::archive_file::open_7z(fname, zip);
-
- if (ziperr == util::archive_file::error::NONE)
+ if (util::archive_file::open_7z(fname, zip) == util::archive_file::error::NONE)
{
if (zip->search(filename, false) >= 0)
{
*buffer = malloc(zip->current_uncompressed_length());
- ziperr = zip->decompress(*buffer, zip->current_uncompressed_length());
- if (ziperr == util::archive_file::error::NONE)
+ if (zip->decompress(*buffer, zip->current_uncompressed_length()) == util::archive_file::error::NONE)
filerr = util::core_file::open_ram(*buffer, zip->current_uncompressed_length(), OPEN_FLAG_READ, file);
}
zip.reset();
@@ -366,7 +355,6 @@ static BOOL LoadDIB(const char *filename, HGLOBAL *phDIB, HPALETTE *pPal, int pi
strcpy(tempfile, filename);
char* system_name = strtok(tempfile, ":");
char* file_name = strtok(NULL, ":");
-
void *buffer = NULL;
std::string fname;
diff --git a/src/osd/winui/splitters.cpp b/src/osd/winui/splitters.cpp
index ce934a14731..96a3cbcb2bf 100644
--- a/src/osd/winui/splitters.cpp
+++ b/src/osd/winui/splitters.cpp
@@ -4,7 +4,7 @@
/***************************************************************************
- splitters.c
+ splitters.cpp
Splitter GUI code. - Tree, splitter, list, splitter, pict
@@ -48,11 +48,11 @@ BOOL InitSplitters(void)
goto error;
memset(nSplitterOffset, 0, sizeof(int) * nSplitterCount);
- return TRUE;
+ return true;
error:
SplittersExit();
- return FALSE;
+ return false;
}
void SplittersExit(void)
@@ -74,12 +74,10 @@ void SplittersExit(void)
static void CalcSplitter(HWND hWnd, LPHZSPLITTER lpSplitter)
{
POINT p = {0,0};
- RECT leftRect, rightRect;
- int dragWidth;
-
ClientToScreen(hWnd, &p);
GetWindowRect(lpSplitter->m_hWnd, &lpSplitter->m_dragRect);
+ RECT leftRect, rightRect;
GetWindowRect(lpSplitter->m_hWndLeft, &leftRect);
GetWindowRect(lpSplitter->m_hWndRight, &rightRect);
@@ -87,7 +85,7 @@ static void CalcSplitter(HWND hWnd, LPHZSPLITTER lpSplitter)
OffsetRect(&leftRect, -p.x, -p.y);
OffsetRect(&rightRect, -p.x, -p.y);
- dragWidth = lpSplitter->m_dragRect.right - lpSplitter->m_dragRect.left;
+ int dragWidth = lpSplitter->m_dragRect.right - lpSplitter->m_dragRect.left;
lpSplitter->m_limitRect.left = leftRect.left + 20;
lpSplitter->m_limitRect.right = rightRect.right - 20;
@@ -148,9 +146,7 @@ void OnSizeSplitter(HWND hWnd)
RECT rWindowRect;
POINT p = {0,0};
int i;
- int nSplitterCount;
-
- nSplitterCount = GetSplitterCount();
+ int nSplitterCount = GetSplitterCount();
if (firstTime)
{
@@ -234,14 +230,14 @@ static void StartTracking(HWND hWnd, UINT hitArea)
{
if (!bTracking && lpCurSpltr != 0 && hitArea == SPLITTER_HITITEM)
{
- // Ensure we have and updated cursor structure
+ // Ensure we have an updated cursor structure
CalcSplitter(hWnd, lpCurSpltr);
// Draw the first splitter shadow
OnInvertTracker(hWnd, &lpCurSpltr->m_dragRect);
// Capture the mouse
SetCapture(hWnd);
// Set tracking to TRUE
- bTracking = TRUE;
+ bTracking = true;
SetCursor(hSplitterCursor);
}
}
@@ -255,30 +251,28 @@ static void StopTracking(HWND hWnd)
// Release the mouse
ReleaseCapture();
// set tracking to false
- bTracking = FALSE;
+ bTracking = false;
SetCursor(LoadCursor(0, IDC_ARROW));
// set the new splitter position
nSplitterOffset[currentSplitter] = lpCurSpltr->m_dragRect.left;
// Redraw the screen area
ResizePickerControls(hWnd);
UpdateScreenShot();
- InvalidateRect(GetMainWindow(),NULL,TRUE);
+ InvalidateRect(GetMainWindow(), NULL, true);
}
}
static UINT SplitterHitTest(HWND hWnd, POINTS p)
{
- RECT rect;
POINT pt;
- int i;
-
pt.x = p.x;
pt.y = p.y;
// Check which area we hit
ClientToScreen(hWnd, &pt);
- for (i = 0; i < numSplitters; i++)
+ RECT rect;
+ for (int i = 0; i < numSplitters; i++)
{
GetWindowRect(splitter[i].m_hWnd, &rect);
if (PtInRect(&rect, pt))
@@ -298,14 +292,12 @@ void OnMouseMove(HWND hWnd, UINT nFlags, POINTS p)
{
if (bTracking) // move the tracking image
{
- int nWidth;
- RECT rect;
POINT pt;
-
pt.x = (int)p.x;
pt.y = (int)p.y;
ClientToScreen(hWnd, &pt);
+ RECT rect;
GetWindowRect(hWnd, &rect);
if (! PtInRect(&rect, pt))
{
@@ -322,7 +314,7 @@ void OnMouseMove(HWND hWnd, UINT nFlags, POINTS p)
OnInvertTracker(hWnd, &lpCurSpltr->m_dragRect);
// calc the new one based on p.x draw it
- nWidth = lpCurSpltr->m_dragRect.right - lpCurSpltr->m_dragRect.left;
+ int nWidth = lpCurSpltr->m_dragRect.right - lpCurSpltr->m_dragRect.left;
lpCurSpltr->m_dragRect.right = pt.x + nWidth / 2;
lpCurSpltr->m_dragRect.left = pt.x - nWidth / 2;
diff --git a/src/osd/winui/splitters.h b/src/osd/winui/splitters.h
index bbf700b0f32..12818d5bb65 100644
--- a/src/osd/winui/splitters.h
+++ b/src/osd/winui/splitters.h
@@ -38,8 +38,7 @@ void OnMouseMove(HWND hWnd, UINT nFlags, POINTS p);
void OnLButtonDown(HWND hWnd, UINT nFlags, POINTS p);
void OnLButtonUp(HWND hWnd, UINT nFlags, POINTS p);
void OnSizeSplitter(HWND hWnd);
-void AddSplitter(HWND hWnd, HWND hWndLeft, HWND hWndRight,
- void (*func)(HWND hWnd,LPRECT lpRect));
+void AddSplitter(HWND hWnd, HWND hWndLeft, HWND hWndRight, void (*func)(HWND hWnd,LPRECT lpRect));
void RecalcSplitters(void);
void AdjustSplitter2Rect(HWND hWnd, LPRECT lpRect);
void AdjustSplitter1Rect(HWND hWnd, LPRECT lpRect);
diff --git a/src/osd/winui/tabview.cpp b/src/osd/winui/tabview.cpp
index d5971275819..31671f12a22 100644
--- a/src/osd/winui/tabview.cpp
+++ b/src/osd/winui/tabview.cpp
@@ -1,25 +1,15 @@
// For licensing and usage information, read docs/winui_license.txt
+// MASTER
//****************************************************************************
// standard windows headers
#include <windows.h>
#include <windowsx.h>
-#include <shellapi.h>
#include <commctrl.h>
-#include <commdlg.h>
-#include <wingdi.h>
// MAME/MAMEUI headers
-#include "winui.h"
#include "tabview.h"
-#include "emu.h"
#include "mui_util.h"
-#include "strconv.h"
-
-
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#endif
struct TabViewInfo
@@ -33,21 +23,18 @@ struct TabViewInfo
static struct TabViewInfo *GetTabViewInfo(HWND hWnd)
{
- LONG_PTR l;
- l = GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ LONG_PTR l = GetWindowLongPtr(hWnd, GWLP_USERDATA);
return (struct TabViewInfo *) l;
}
-static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc,
- HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- LRESULT rc;
-
if (!pfnParentWndProc)
pfnParentWndProc = GetTabViewInfo(hWnd)->pfnParentWndProc;
+ LRESULT rc;
if (IsWindowUnicode(hWnd))
rc = CallWindowProcW(pfnParentWndProc, hWnd, message, wParam, lParam);
else
@@ -60,12 +47,9 @@ static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc,
static LRESULT CALLBACK TabViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct TabViewInfo *pTabViewInfo;
- WNDPROC pfnParentWndProc;
- BOOL bHandled = FALSE;
- LRESULT rc = 0;
-
pTabViewInfo = GetTabViewInfo(hWnd);
- pfnParentWndProc = pTabViewInfo->pfnParentWndProc;
+
+ WNDPROC pfnParentWndProc = pTabViewInfo->pfnParentWndProc;
switch(message)
{
@@ -76,6 +60,9 @@ static LRESULT CALLBACK TabViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L
break;
}
+ LRESULT rc = 0;
+ // this is weird...
+ BOOL bHandled = false;
if (!bHandled)
rc = CallParentWndProc(pfnParentWndProc, hWnd, message, wParam, lParam);
@@ -96,12 +83,11 @@ static LRESULT CALLBACK TabViewWndProc(HWND hWnd, UINT message, WPARAM wParam, L
static int TabView_GetTabFromTabIndex(HWND hwndTabView, int tab_index)
{
int shown_tabs = -1;
- int i;
struct TabViewInfo *pTabViewInfo;
pTabViewInfo = GetTabViewInfo(hwndTabView);
- for (i = 0; i < pTabViewInfo->nTabCount; i++)
+ for (int i = 0; i < pTabViewInfo->nTabCount; i++)
{
if (!pTabViewInfo->pCallbacks->pfnGetShowTab || pTabViewInfo->pCallbacks->pfnGetShowTab(i))
{
@@ -121,7 +107,7 @@ int TabView_GetCurrentTab(HWND hwndTabView)
struct TabViewInfo *pTabViewInfo;
LPCSTR pszTab = NULL;
LPCSTR pszThatTab;
- int i, nTab = -1;
+ int nTab = -1;
pTabViewInfo = GetTabViewInfo(hwndTabView);
@@ -132,10 +118,10 @@ int TabView_GetCurrentTab(HWND hwndTabView)
{
if (pTabViewInfo->pCallbacks->pfnGetTabShortName)
{
- for (i = 0; i < pTabViewInfo->nTabCount; i++)
+ for (int i = 0; i < pTabViewInfo->nTabCount; i++)
{
pszThatTab = pTabViewInfo->pCallbacks->pfnGetTabShortName(i);
- if (pszThatTab && !core_stricmp(pszTab, pszThatTab))
+ if (pszThatTab && (core_stricmp(pszTab, pszThatTab)==0))
{
nTab = i;
break;
@@ -166,13 +152,10 @@ void TabView_SetCurrentTab(HWND hwndTabView, int nTab)
pTabViewInfo = GetTabViewInfo(hwndTabView);
if (pTabViewInfo->pCallbacks->pfnGetTabShortName)
- {
pszName = pTabViewInfo->pCallbacks->pfnGetTabShortName(nTab);
- }
else
{
- snprintf(szBuffer, ARRAY_LENGTH(szBuffer),
- "%d", nTab);
+ snprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), "%d", nTab);
pszName = szBuffer;
}
@@ -185,14 +168,12 @@ void TabView_SetCurrentTab(HWND hwndTabView, int nTab)
static int TabView_GetCurrentTabIndex(HWND hwndTabView)
{
int shown_tabs = 0;
- int i;
- int nCurrentTab;
struct TabViewInfo *pTabViewInfo;
pTabViewInfo = GetTabViewInfo(hwndTabView);
- nCurrentTab = TabView_GetCurrentTab(hwndTabView);
+ int nCurrentTab = TabView_GetCurrentTab(hwndTabView);
- for (i = 0; i < pTabViewInfo->nTabCount; i++)
+ for (int i = 0; i < pTabViewInfo->nTabCount; i++)
{
if (i == nCurrentTab)
break;
@@ -207,31 +188,29 @@ static int TabView_GetCurrentTabIndex(HWND hwndTabView)
void TabView_UpdateSelection(HWND hwndTabView)
{
- HRESULT res;
- res = TabCtrl_SetCurSel(hwndTabView, TabView_GetCurrentTabIndex(hwndTabView));
+ HRESULT res = TabCtrl_SetCurSel(hwndTabView, TabView_GetCurrentTabIndex(hwndTabView));
+ res++;
}
BOOL TabView_HandleNotify(LPNMHDR lpNmHdr)
{
- HWND hwndTabView;
struct TabViewInfo *pTabViewInfo;
- BOOL bResult = FALSE;
- int nTabIndex, nTab;
+ BOOL bResult = false;
- hwndTabView = lpNmHdr->hwndFrom;
+ HWND hwndTabView = lpNmHdr->hwndFrom;
pTabViewInfo = GetTabViewInfo(hwndTabView);
switch (lpNmHdr->code)
{
case TCN_SELCHANGE:
- nTabIndex = TabCtrl_GetCurSel(hwndTabView);
- nTab = TabView_GetTabFromTabIndex(hwndTabView, nTabIndex);
+ int nTabIndex = TabCtrl_GetCurSel(hwndTabView);
+ int nTab = TabView_GetTabFromTabIndex(hwndTabView, nTabIndex);
TabView_SetCurrentTab(hwndTabView, nTab);
if (pTabViewInfo->pCallbacks->pfnOnSelectionChanged)
pTabViewInfo->pCallbacks->pfnOnSelectionChanged();
- bResult = TRUE;
+ bResult = true;
break;
}
return bResult;
@@ -242,13 +221,12 @@ BOOL TabView_HandleNotify(LPNMHDR lpNmHdr)
void TabView_CalculateNextTab(HWND hwndTabView)
{
struct TabViewInfo *pTabViewInfo;
- int i;
int nCurrentTab;
pTabViewInfo = GetTabViewInfo(hwndTabView);
// at most loop once through all options
- for (i = 0; i < pTabViewInfo->nTabCount; i++)
+ for (int i = 0; i < pTabViewInfo->nTabCount; i++)
{
nCurrentTab = TabView_GetCurrentTab(hwndTabView);
TabView_SetCurrentTab(hwndTabView, (nCurrentTab + 1) % pTabViewInfo->nTabCount);
@@ -263,33 +241,29 @@ void TabView_CalculateNextTab(HWND hwndTabView)
}
-
void TabView_Reset(HWND hwndTabView)
{
struct TabViewInfo *pTabViewInfo;
- TC_ITEM tci;
- int i;
- TCHAR* t_text;
- HRESULT res;
- BOOL b_res;
-
pTabViewInfo = GetTabViewInfo(hwndTabView);
- b_res = TabCtrl_DeleteAllItems(hwndTabView);
+ BOOL b_res = TabCtrl_DeleteAllItems(hwndTabView);
+ b_res++;
+ TC_ITEM tci;
memset(&tci, 0, sizeof(tci));
tci.mask = TCIF_TEXT;
tci.cchTextMax = 20;
- for (i = 0; i < pTabViewInfo->nTabCount; i++)
+ for (int i = 0; i < pTabViewInfo->nTabCount; i++)
{
if (!pTabViewInfo->pCallbacks->pfnGetShowTab || pTabViewInfo->pCallbacks->pfnGetShowTab(i))
{
- t_text = ui_wstring_from_utf8(pTabViewInfo->pCallbacks->pfnGetTabLongName(i));
+ TCHAR* t_text = ui_wstring_from_utf8(pTabViewInfo->pCallbacks->pfnGetTabLongName(i));
if( !t_text )
return;
tci.pszText = t_text;
- res = TabCtrl_InsertItem(hwndTabView, i, &tci);
+ HRESULT res = TabCtrl_InsertItem(hwndTabView, i, &tci);
+ res++;
free(t_text);
}
}
@@ -297,19 +271,15 @@ void TabView_Reset(HWND hwndTabView)
}
-
BOOL SetupTabView(HWND hwndTabView, const struct TabViewOptions *pOptions)
{
- struct TabViewInfo *pTabViewInfo;
- LONG_PTR l;
- BOOL bShowTabView;
-
assert(hwndTabView);
+ struct TabViewInfo *pTabViewInfo;
// Allocate the list view struct
pTabViewInfo = (struct TabViewInfo *) malloc(sizeof(struct TabViewInfo));
if (!pTabViewInfo)
- return FALSE;
+ return false;
// And fill it out
memset(pTabViewInfo, 0, sizeof(*pTabViewInfo));
@@ -317,19 +287,18 @@ BOOL SetupTabView(HWND hwndTabView, const struct TabViewOptions *pOptions)
pTabViewInfo->nTabCount = pOptions->nTabCount;
// Hook in our wndproc and userdata pointer
- l = GetWindowLongPtr(hwndTabView, GWLP_WNDPROC);
+ LONG_PTR l = GetWindowLongPtr(hwndTabView, GWLP_WNDPROC);
pTabViewInfo->pfnParentWndProc = (WNDPROC) l;
SetWindowLongPtr(hwndTabView, GWLP_USERDATA, (LONG_PTR) pTabViewInfo);
SetWindowLongPtr(hwndTabView, GWLP_WNDPROC, (LONG_PTR) TabViewWndProc);
- bShowTabView = pTabViewInfo->pCallbacks->pfnGetShowTabCtrl ?
- pTabViewInfo->pCallbacks->pfnGetShowTabCtrl() : TRUE;
+ BOOL bShowTabView = pTabViewInfo->pCallbacks->pfnGetShowTabCtrl ? pTabViewInfo->pCallbacks->pfnGetShowTabCtrl() : true;
ShowWindow(hwndTabView, bShowTabView ? SW_SHOW : SW_HIDE);
TabView_Reset(hwndTabView);
if (pTabViewInfo->pCallbacks->pfnOnSelectionChanged)
pTabViewInfo->pCallbacks->pfnOnSelectionChanged();
- return TRUE;
+ return true;
}
diff --git a/src/osd/winui/treeview.h b/src/osd/winui/treeview.h
index e61747dc981..85218b73134 100644
--- a/src/osd/winui/treeview.h
+++ b/src/osd/winui/treeview.h
@@ -30,6 +30,7 @@
SNDMSG(w,TVM_EDITLABEL,0,(LPARAM)(i))
#endif /* defined(__GNUC__) */
+#include "bitmask.h"
/***************************************************************************
Folder And Filter Definitions
diff --git a/src/osd/winui/winui.cpp b/src/osd/winui/winui.cpp
index 17d6220826a..141d6873846 100644
--- a/src/osd/winui/winui.cpp
+++ b/src/osd/winui/winui.cpp
@@ -3,7 +3,7 @@
/***************************************************************************
- winui.c
+ winui.cpp
Win32 GUI code.
@@ -34,6 +34,8 @@
#include <time.h>
#include <tchar.h>
+/* Uncomment to add Direct Draw support (has to be added back to the core too) */
+//#define UI_DIRECTDRAW
// MAME/MAMEUI headers
#include "emu.h"
@@ -66,7 +68,9 @@
#include "help.h"
#include "history.h"
#include "dialogs.h"
+#ifdef UI_DIRECTDRAW
#include "directdraw.h"
+#endif
#include "directinput.h"
#include "dijoystick.h" /* For DIJoystick availability. */
@@ -74,10 +78,6 @@
#define snprintf _snprintf
#endif
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#endif
-
#ifndef LVS_EX_LABELTIP
#define LVS_EX_LABELTIP 0x00004000 // listview unfolds partly hidden labels if it does not have infotip text
#endif // LVS_EX_LABELTIP
@@ -233,12 +233,12 @@ UINT8 playopts_apply = 0;
typedef struct _play_options play_options;
struct _play_options
{
- const char *record; // OPTION_RECORD
- const char *playback; // OPTION_PLAYBACK
- const char *state; // OPTION_STATE
- const char *wavwrite; // OPTION_WAVWRITE
- const char *mngwrite; // OPTION_MNGWRITE
- const char *aviwrite; // OPTION_AVIWRITE
+ const char *record; // OPTION_RECORD
+ const char *playback; // OPTION_PLAYBACK
+ const char *state; // OPTION_STATE
+ const char *wavwrite; // OPTION_WAVWRITE
+ const char *mngwrite; // OPTION_MNGWRITE
+ const char *aviwrite; // OPTION_AVIWRITE
};
/***************************************************************************
@@ -406,7 +406,7 @@ typedef struct
int id; /* Window control id */
HWND hwnd; /* Window handle */
} u;
- BOOL setfont; /* Do we set this item's font? */
+ BOOL setfont; /* Do we set this item's font? */
int action; /* What to do when control is resized */
void *subwindow; /* Points to a Resize structure for this subwindow; NULL if none */
} ResizeItem;
@@ -475,18 +475,18 @@ static object_pool *mameui_pool;
static int game_index;
static int progBarStep;
-static BOOL bDoGameCheck = FALSE;
+static BOOL bDoGameCheck = false;
/* Tree control variables */
static BOOL bShowTree = 1;
static BOOL bShowToolBar = 1;
static BOOL bShowStatusBar = 1;
static BOOL bShowTabCtrl = 1;
-static BOOL bProgressShown = FALSE;
-static BOOL bListReady = FALSE;
+static BOOL bProgressShown = false;
+static BOOL bListReady = false;
-#define WM_MAME32_FILECHANGED (WM_USER + 0)
-#define WM_MAME32_AUDITGAME (WM_USER + 1)
+#define WM_MAME32_FILECHANGED (WM_USER + 0)
+#define WM_MAME32_AUDITGAME (WM_USER + 1)
static PDIRWATCHER s_pWatcher;
@@ -500,10 +500,10 @@ static bool keyboard_state[4096]; /* __code_max #defines the number of internal
static char g_SearchText[256];
/* table copied from windows/inputs.c */
// table entry indices
-#define MAME_KEY 0
-#define DI_KEY 1
-#define VIRTUAL_KEY 2
-#define ASCII_KEY 3
+#define MAME_KEY 0
+#define DI_KEY 1
+#define VIRTUAL_KEY 2
+#define ASCII_KEY 3
// master keyboard translation table
static const int win_key_trans_table[][4] =
@@ -680,15 +680,15 @@ static HWND hStatusBar = 0;
static HWND s_hToolBar = 0;
/* Column Order as Displayed */
-static BOOL oldControl = FALSE;
-static BOOL xpControl = FALSE;
+static BOOL oldControl = false;
+static BOOL xpControl = false;
/* Used to recalculate the main window layout */
static int bottomMargin;
static int topMargin;
-static int have_history = FALSE;
+static int have_history = false;
-static BOOL have_selection = FALSE;
+static BOOL have_selection = false;
static HBITMAP hMissing_bitmap = NULL;
@@ -753,8 +753,8 @@ static const int s_nPickers[] =
/* How to resize toolbar sub window */
static ResizeItem toolbar_resize_items[] =
{
- { RA_ID, { ID_TOOLBAR_EDIT }, TRUE, RA_LEFT | RA_TOP, NULL },
- { RA_END, { 0 }, FALSE, 0, NULL }
+ { RA_ID, { ID_TOOLBAR_EDIT }, true, RA_LEFT | RA_TOP, NULL },
+ { RA_END, { 0 }, false, 0, NULL }
};
static Resize toolbar_resize = { {0, 0, 0, 0}, toolbar_resize_items };
@@ -762,18 +762,18 @@ static Resize toolbar_resize = { {0, 0, 0, 0}, toolbar_resize_items };
/* How to resize main window */
static ResizeItem main_resize_items[] =
{
- { RA_HWND, { 0 }, FALSE, RA_LEFT | RA_RIGHT | RA_TOP, &toolbar_resize },
- { RA_HWND, { 0 }, FALSE, RA_LEFT | RA_RIGHT | RA_BOTTOM, NULL },
- { RA_ID, { IDC_DIVIDER }, FALSE, RA_LEFT | RA_RIGHT | RA_TOP, NULL },
- { RA_ID, { IDC_TREE }, TRUE, RA_LEFT | RA_BOTTOM | RA_TOP, NULL },
- { RA_ID, { IDC_LIST }, TRUE, RA_ALL, NULL },
- { RA_ID, { IDC_SPLITTER }, FALSE, RA_LEFT | RA_BOTTOM | RA_TOP, NULL },
- { RA_ID, { IDC_SPLITTER2 },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
- { RA_ID, { IDC_SSFRAME }, FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
- { RA_ID, { IDC_SSPICTURE },FALSE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
- { RA_ID, { IDC_HISTORY }, TRUE, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
- { RA_ID, { IDC_SSTAB }, FALSE, RA_RIGHT | RA_TOP, NULL },
- { RA_END, { 0 }, FALSE, 0, NULL }
+ { RA_HWND, { 0 }, false, RA_LEFT | RA_RIGHT | RA_TOP, &toolbar_resize },
+ { RA_HWND, { 0 }, false, RA_LEFT | RA_RIGHT | RA_BOTTOM, NULL },
+ { RA_ID, { IDC_DIVIDER }, false, RA_LEFT | RA_RIGHT | RA_TOP, NULL },
+ { RA_ID, { IDC_TREE }, true, RA_LEFT | RA_BOTTOM | RA_TOP, NULL },
+ { RA_ID, { IDC_LIST }, true, RA_ALL, NULL },
+ { RA_ID, { IDC_SPLITTER }, false, RA_LEFT | RA_BOTTOM | RA_TOP, NULL },
+ { RA_ID, { IDC_SPLITTER2 },false, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
+ { RA_ID, { IDC_SSFRAME }, false, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
+ { RA_ID, { IDC_SSPICTURE },false, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
+ { RA_ID, { IDC_HISTORY }, true, RA_RIGHT | RA_BOTTOM | RA_TOP, NULL },
+ { RA_ID, { IDC_SSTAB }, false, RA_RIGHT | RA_TOP, NULL },
+ { RA_END, { 0 }, false, 0, NULL }
};
static Resize main_resize = { {0, 0, 0, 0}, main_resize_items };
@@ -785,12 +785,12 @@ TCHAR last_directory[MAX_PATH];
each time it changes */
static UINT g_mame32_message = 0;
-static BOOL g_listview_dragging = FALSE;
+static BOOL g_listview_dragging = false;
static HIMAGELIST himl_drag;
static int game_dragged; /* which game started the drag */
static HTREEITEM prev_drag_drop_target; /* which tree view item we're currently highlighting */
-static BOOL g_in_treeview_edit = FALSE;
+static BOOL g_in_treeview_edit = false;
/***************************************************************************
Global variables
@@ -815,12 +815,8 @@ extern const LPCTSTR column_names[COLUMN_MAX] =
TEXT("Play Time"),
TEXT("Clone Of"),
TEXT("Trackball"),
-#ifdef SHOW_COLUMN_SAMPLES
TEXT("Samples"),
-#endif
-#ifdef SHOW_COLUMN_ROMS
TEXT("ROMs"),
-#endif
};
/***************************************************************************
@@ -884,7 +880,7 @@ static DWORD RunMAME(int nGameIndex, const play_options *playopts)
time_t start, end;
double elapsedtime;
int i;
- //mame_options mame_opts; seems useless....
+ //mame_options mame_opts; //seems useless....
windows_options global_opts;
// set up MAME options
// mame_opts = mame_options_init(mame_win_options);
@@ -1023,22 +1019,17 @@ object_pool *GetMameUIMemoryPool(void)
void GetRealColumnOrder(int order[])
{
- int tmpOrder[COLUMN_MAX];
- int nColumnMax;
- int i;
- BOOL res;
-
- nColumnMax = Picker_GetNumColumns(hwndList);
+ int nColumnMax = Picker_GetNumColumns(hwndList);
/* Get the Column Order and save it */
if (!oldControl)
{
- res = ListView_GetColumnOrderArray(hwndList, nColumnMax, tmpOrder);
+ int tmpOrder[COLUMN_MAX];
+ BOOL res = ListView_GetColumnOrderArray(hwndList, nColumnMax, tmpOrder);
+ res++;
- for (i = 0; i < nColumnMax; i++)
- {
+ for (int i = 0; i < nColumnMax; i++)
order[i] = Picker_GetRealColumnFromViewColumn(hwndList, tmpOrder[i]);
- }
}
}
@@ -1053,94 +1044,71 @@ void GetRealColumnOrder(int order[])
*/
static HICON FormatICOInMemoryToHICON(PBYTE ptrBuffer, UINT nBufferSize)
{
- ICONIMAGE IconImage;
- LPICONDIRENTRY lpIDE = NULL;
- UINT nNumImages;
- UINT nBufferIndex = 0;
- HICON hIcon = NULL;
-
/* Is there a WORD? */
if (nBufferSize < sizeof(WORD))
- {
return NULL;
- }
/* Was it 'reserved' ? (ie 0) */
+ UINT nBufferIndex = 0;
if ((WORD)(ptrBuffer[nBufferIndex]) != 0)
- {
return NULL;
- }
nBufferIndex += sizeof(WORD);
/* Is there a WORD? */
if (nBufferSize - nBufferIndex < sizeof(WORD))
- {
return NULL;
- }
/* Was it type 1? */
if ((WORD)(ptrBuffer[nBufferIndex]) != 1)
- {
return NULL;
- }
nBufferIndex += sizeof(WORD);
/* Is there a WORD? */
if (nBufferSize - nBufferIndex < sizeof(WORD))
- {
return NULL;
- }
/* Then that's the number of images in the ICO file */
- nNumImages = (WORD)(ptrBuffer[nBufferIndex]);
+ UINT nNumImages = (WORD)(ptrBuffer[nBufferIndex]);
/* Is there at least one icon in the file? */
if ( nNumImages < 1 )
- {
return NULL;
- }
nBufferIndex += sizeof(WORD);
/* Is there enough space for the icon directory entries? */
if ((nBufferIndex + nNumImages * sizeof(ICONDIRENTRY)) > nBufferSize)
- {
return NULL;
- }
/* Assign icon directory entries from buffer */
- lpIDE = (LPICONDIRENTRY)(&ptrBuffer[nBufferIndex]);
+ LPICONDIRENTRY lpIDE = (LPICONDIRENTRY)(&ptrBuffer[nBufferIndex]);
nBufferIndex += nNumImages * sizeof (ICONDIRENTRY);
+ ICONIMAGE IconImage;
IconImage.dwNumBytes = lpIDE->dwBytesInRes;
/* Seek to beginning of this image */
if ( lpIDE->dwImageOffset > nBufferSize )
- {
return NULL;
- }
nBufferIndex = lpIDE->dwImageOffset;
/* Read it in */
if ((nBufferIndex + lpIDE->dwBytesInRes) > nBufferSize)
- {
return NULL;
- }
IconImage.lpBits = &ptrBuffer[nBufferIndex];
nBufferIndex += lpIDE->dwBytesInRes;
+
/* It failed, odds are good we're on NT so try the non-Ex way */
+ HICON hIcon = NULL;
if (hIcon == NULL)
- {
/* We would break on NT if we try with a 16bpp image */
if (((LPBITMAPINFO)IconImage.lpBits)->bmiHeader.biBitCount != 16)
- {
- hIcon = CreateIconFromResourceEx(IconImage.lpBits, IconImage.dwNumBytes, TRUE, 0x00030000,0,0,LR_DEFAULTSIZE);
- }
- }
+ hIcon = CreateIconFromResourceEx(IconImage.lpBits, IconImage.dwNumBytes, true, 0x00030000,0,0,LR_DEFAULTSIZE);
+
return hIcon;
}
@@ -1152,7 +1120,6 @@ HICON LoadIconFromFile(const char *iconname)
char tmpIcoName[MAX_PATH];
const char* sDirName = GetImgDir();
PBYTE bufferPtr;
- util::archive_file::error ziperr;
util::archive_file::ptr zip;
int res = 0;
@@ -1160,14 +1127,12 @@ HICON LoadIconFromFile(const char *iconname)
if (stat(tmpStr, &file_stat) != 0 || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0)
{
sprintf(tmpStr, "%s/%s.ico", sDirName, iconname);
- if (stat(tmpStr, &file_stat) != 0
- || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0)
+ if (stat(tmpStr, &file_stat) != 0 || (hIcon = win_extract_icon_utf8(hInst, tmpStr, 0)) == 0)
{
sprintf(tmpStr, "%s/icons.zip", GetIconsDir());
sprintf(tmpIcoName, "%s.ico", iconname);
- ziperr = util::archive_file::open_zip(tmpStr, zip);
- if (ziperr == util::archive_file::error::NONE)
+ if (util::archive_file::open_zip(tmpStr, zip) == util::archive_file::error::NONE)
{
res = zip->search(tmpIcoName, false);
if (res >= 0)
@@ -1175,11 +1140,9 @@ HICON LoadIconFromFile(const char *iconname)
bufferPtr = (PBYTE)malloc(zip->current_uncompressed_length());
if (bufferPtr)
{
- ziperr = zip->decompress(bufferPtr, zip->current_uncompressed_length());
- if (ziperr == util::archive_file::error::NONE)
- {
+ if (zip->decompress(bufferPtr, zip->current_uncompressed_length()) == util::archive_file::error::NONE)
hIcon = FormatICOInMemoryToHICON(bufferPtr, zip->current_uncompressed_length());
- }
+
free(bufferPtr);
}
}
@@ -1190,8 +1153,7 @@ HICON LoadIconFromFile(const char *iconname)
sprintf(tmpStr, "%s/icons.7z", GetIconsDir());
sprintf(tmpIcoName, "%s.ico", iconname);
- ziperr = util::archive_file::open_7z(tmpStr, zip);
- if (ziperr == util::archive_file::error::NONE)
+ if (util::archive_file::open_7z(tmpStr, zip) == util::archive_file::error::NONE)
{
res = zip->search(tmpIcoName, false);
if (res >= 0)
@@ -1199,11 +1161,9 @@ HICON LoadIconFromFile(const char *iconname)
bufferPtr = (PBYTE)malloc(zip->current_uncompressed_length());
if (bufferPtr)
{
- ziperr = zip->decompress(bufferPtr, zip->current_uncompressed_length());
- if (ziperr == util::archive_file::error::NONE)
- {
+ if (zip->decompress(bufferPtr, zip->current_uncompressed_length()) == util::archive_file::error::NONE)
hIcon = FormatICOInMemoryToHICON(bufferPtr, zip->current_uncompressed_length());
- }
+
free(bufferPtr);
}
}
@@ -1231,7 +1191,6 @@ const char * GetSearchText(void)
/* Sets the treeview and listviews sizes in accordance with their visibility and the splitters */
static void ResizeTreeAndListViews(BOOL bResizeHidden)
{
- int i;
int nLastWidth = 0;
int nLastWidth2 = 0;
int nLeftWindowWidth = 0;
@@ -1250,9 +1209,9 @@ static void ResizeTreeAndListViews(BOOL bResizeHidden)
/* Tree control */
ShowWindow(GetDlgItem(hMain, IDC_TREE), bShowTree ? SW_SHOW : SW_HIDE);
- for (i = 0; g_splitterInfo[i].nSplitterWindow; i++)
+ for (int i = 0; g_splitterInfo[i].nSplitterWindow; i++)
{
- bVisible = GetWindowLong(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), GWL_STYLE) & WS_VISIBLE ? TRUE : FALSE;
+ bVisible = GetWindowLong(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), GWL_STYLE) & WS_VISIBLE ? true : false;
if (bResizeHidden || bVisible)
{
nLeftWindowWidth = nSplitterOffset[i] - SPLITTER_WIDTH/2 - nLastWidth;
@@ -1270,11 +1229,9 @@ static void ResizeTreeAndListViews(BOOL bResizeHidden)
i--;
}
- MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), nLastWidth, rect.top + 2,
- nLeftWindowWidth, (rect.bottom - rect.top) - 4 , TRUE);
+ MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nLeftWindow), nLastWidth, rect.top + 2, nLeftWindowWidth, (rect.bottom - rect.top) - 4 , true);
- MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nSplitterWindow), nSplitterOffset[i], rect.top + 2,
- SPLITTER_WIDTH, (rect.bottom - rect.top) - 4, TRUE);
+ MoveWindow(GetDlgItem(hMain, g_splitterInfo[i].nSplitterWindow), nSplitterOffset[i], rect.top + 2, SPLITTER_WIDTH, (rect.bottom - rect.top) - 4, true);
}
if (bVisible)
@@ -1288,15 +1245,15 @@ static void ResizeTreeAndListViews(BOOL bResizeHidden)
/* Adjust the list view and screenshot button based on GetShowScreenShot() */
void UpdateScreenShot(void)
{
+ /* first time through can't do this stuff */
+ if (hwndList == NULL)
+ return;
+
RECT rect;
//int nWidth;
RECT fRect;
POINT p = {0, 0};
- /* first time through can't do this stuff */
- if (hwndList == NULL)
- return;
-
/* Size the List Control in the Picker */
GetClientRect(hMain, &rect);
@@ -1318,15 +1275,13 @@ void UpdateScreenShot(void)
ToolBar_CheckButton(s_hToolBar, ID_VIEW_PICTURE_AREA, MF_UNCHECKED);
}
- ResizeTreeAndListViews(FALSE);
+ ResizeTreeAndListViews(false);
FreeScreenShot();
if (have_selection)
- {
// load and set image, or empty it if we don't have one
LoadScreenShot(Picker_GetSelectedItem(hwndList), NULL, TabView_GetCurrentTab(hTabCtrl));
- }
// figure out if we have a history or not, to place our other windows properly
UpdateHistory();
@@ -1347,27 +1302,20 @@ void UpdateScreenShot(void)
// - we have history for the game
// - we're on the first tab
// - we DON'T have a separate history tab
- showing_history = (have_history && (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() || GetHistoryTab() == TAB_ALL ) &&
- GetShowTab(TAB_HISTORY) == FALSE);
+ showing_history = (have_history && (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() || GetHistoryTab() == TAB_ALL ) && GetShowTab(TAB_HISTORY) == false);
CalculateBestScreenShotRect(GetDlgItem(hMain, IDC_SSFRAME), &rect,showing_history);
dwStyle = GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_STYLE);
dwStyleEx = GetWindowLong(GetDlgItem(hMain, IDC_SSPICTURE), GWL_EXSTYLE);
- AdjustWindowRectEx(&rect, dwStyle, FALSE, dwStyleEx);
- MoveWindow(GetDlgItem(hMain, IDC_SSPICTURE),
- fRect.left + rect.left,
- fRect.top + rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- TRUE);
+ AdjustWindowRectEx(&rect, dwStyle, false, dwStyleEx);
+ MoveWindow(GetDlgItem(hMain, IDC_SSPICTURE), fRect.left + rect.left, fRect.top + rect.top, rect.right - rect.left, rect.bottom - rect.top, true);
- ShowWindow(GetDlgItem(hMain,IDC_SSPICTURE),
- (TabView_GetCurrentTab(hTabCtrl) != TAB_HISTORY) ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(hMain,IDC_SSPICTURE), (TabView_GetCurrentTab(hTabCtrl) != TAB_HISTORY) ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hMain,IDC_SSFRAME),SW_SHOW);
ShowWindow(GetDlgItem(hMain,IDC_SSTAB),bShowTabCtrl ? SW_SHOW : SW_HIDE);
- InvalidateRect(GetDlgItem(hMain,IDC_SSPICTURE),NULL,FALSE);
+ InvalidateRect(GetDlgItem(hMain,IDC_SSPICTURE),NULL,false);
}
else
{
@@ -1382,12 +1330,10 @@ void ResizePickerControls(HWND hWnd)
{
RECT frameRect;
RECT rect, sRect;
- int nListWidth, nScreenShotWidth;
- static BOOL firstTime = TRUE;
- int doSSControls = TRUE;
- int i, nSplitterCount;
+ static BOOL firstTime = true;
+ int doSSControls = true;
- nSplitterCount = GetSplitterCount();
+ int nSplitterCount = GetSplitterCount();
/* Size the List Control in the Picker */
GetClientRect(hWnd, &rect);
@@ -1397,7 +1343,7 @@ void ResizePickerControls(HWND hWnd)
{
RECT rWindow;
- for (i = 0; i < nSplitterCount; i++)
+ for (int i = 0; i < nSplitterCount; i++)
nSplitterOffset[i] = rect.right * g_splitterInfo[i].dPosition;
GetWindowRect(hStatusBar, &rWindow);
@@ -1406,12 +1352,10 @@ void ResizePickerControls(HWND hWnd)
topMargin = rWindow.bottom - rWindow.top;
/*buttonMargin = (sRect.bottom + 4); */
- firstTime = FALSE;
+ firstTime = false;
}
else
- {
doSSControls = GetShowScreenShot();
- }
if (bShowStatusBar)
rect.bottom -= bottomMargin;
@@ -1419,24 +1363,22 @@ void ResizePickerControls(HWND hWnd)
if (bShowToolBar)
rect.top += topMargin;
- MoveWindow(GetDlgItem(hWnd, IDC_DIVIDER), rect.left, rect.top - 4, rect.right, 2, TRUE);
+ MoveWindow(GetDlgItem(hWnd, IDC_DIVIDER), rect.left, rect.top - 4, rect.right, 2, true);
- ResizeTreeAndListViews(TRUE);
+ ResizeTreeAndListViews(true);
- nListWidth = nSplitterOffset[nSplitterCount-1];
- nScreenShotWidth = (rect.right - nListWidth) - 4;
+ int nListWidth = nSplitterOffset[nSplitterCount-1];
+ int nScreenShotWidth = (rect.right - nListWidth) - 4;
/* Screen shot Page tab control */
if (bShowTabCtrl)
{
- MoveWindow(GetDlgItem(hWnd, IDC_SSTAB), nListWidth + 4, rect.top + 2,
- nScreenShotWidth - 2, rect.top + 20, doSSControls);
+ MoveWindow(GetDlgItem(hWnd, IDC_SSTAB), nListWidth + 4, rect.top + 2, nScreenShotWidth - 2, rect.top + 20, doSSControls);
rect.top += 20;
}
/* resize the Screen shot frame */
- MoveWindow(GetDlgItem(hWnd, IDC_SSFRAME), nListWidth + 4, rect.top + 2,
- nScreenShotWidth - 2, (rect.bottom - rect.top) - 4, doSSControls);
+ MoveWindow(GetDlgItem(hWnd, IDC_SSFRAME), nListWidth + 4, rect.top + 2, nScreenShotWidth - 2, (rect.bottom - rect.top) - 4, doSSControls);
/* The screen shot controls */
GetClientRect(GetDlgItem(hWnd, IDC_SSFRAME), &frameRect);
@@ -1445,7 +1387,6 @@ void ResizePickerControls(HWND hWnd)
sRect.left = nListWidth + 14;
sRect.right = sRect.left + (nScreenShotWidth - 22);
-
if (GetShowTab(TAB_HISTORY))
{
// We're using the new mode, with the history filling the entire tab (almost)
@@ -1459,12 +1400,9 @@ void ResizePickerControls(HWND hWnd)
sRect.bottom = (rect.bottom - rect.top) - 278;
}
- MoveWindow(GetDlgItem(hWnd, IDC_HISTORY),
- sRect.left, sRect.top,
- sRect.right - sRect.left, sRect.bottom, doSSControls);
+ MoveWindow(GetDlgItem(hWnd, IDC_HISTORY), sRect.left, sRect.top, sRect.right - sRect.left, sRect.bottom, doSSControls);
/* the other screen shot controls will be properly placed in UpdateScreenshot() */
-
}
@@ -1515,7 +1453,7 @@ HPALETTE GetBackgroundPalette(void)
return hPALbg;
}
-MYBITMAPINFO * GetBackgroundInfo(void)
+MYBITMAPINFO *GetBackgroundInfo(void)
{
return &bmDesc;
}
@@ -1549,10 +1487,8 @@ int GetParentRomSetIndex(const game_driver *driver)
int nParentIndex = GetGameNameIndex(driver->parent);
if( nParentIndex >= 0)
- {
if ((driver_list::driver(nParentIndex).flags & MACHINE_IS_BIOS_ROOT) == 0)
return nParentIndex;
- }
return -1;
}
@@ -1597,7 +1533,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
LONG_PTR l;
if (!OptionsInit())
- return FALSE;
+ return false;
srand((unsigned)time(NULL));
@@ -1609,13 +1545,13 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
memset(icon_index, '\0', sizeof(int) * driver_list::total());
// set up window class
- wndclass.style = CS_HREDRAW | CS_VREDRAW;
+ wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = MameWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
- wndclass.hInstance = hInstance;
- wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAMEUI_ICON));
- wndclass.hCursor = NULL;
+ wndclass.hInstance = hInstance;
+ wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAMEUI_ICON));
+ wndclass.hCursor = NULL;
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_UI_MENU);
wndclass.lpszClassName = TEXT("MainClass");
@@ -1644,7 +1580,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
t_inpdir = ui_wstring_from_utf8(GetInpDir());
if( ! t_inpdir )
- return FALSE;
+ return false;
_tcscpy(last_directory,t_inpdir);
free(t_inpdir);
@@ -1652,14 +1588,14 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
if (hMain == NULL)
{
dprintf("error creating main dialog, aborting\n");
- return FALSE;
+ return false;
}
s_pWatcher = DirWatcher_Init(hMain, WM_MAME32_FILECHANGED);
if (s_pWatcher)
{
- DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), TRUE);
- DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), TRUE);
+ DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), true);
+ DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), true);
}
SetMainTitle();
@@ -1686,7 +1622,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
opts.nTabCount = MAX_TAB_TYPES;
if (!SetupTabView(hTabCtrl, &opts))
- return FALSE;
+ return false;
}
/* subclass history window */
@@ -1736,7 +1672,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
hwndList = GetDlgItem(hMain, IDC_LIST);
if (!InitSplitters())
- return FALSE;
+ return false;
nSplitterCount = GetSplitterCount();
for (i = 0; i < nSplitterCount; i++)
@@ -1758,7 +1694,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
TabView_UpdateSelection(hTabCtrl);
bDoGameCheck = GetGameCheck();
- idle_work = TRUE;
+ idle_work = true;
game_index = 0;
bShowTree = GetShowFolderList();
@@ -1781,12 +1717,14 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
EnableMenuItem(GetMenu(hMain), ID_OPTIONS_DEFAULTS, MF_GRAYED);
}
+#ifdef UI_DIRECTDRAW
/* Init DirectDraw */
if (!DirectDraw_Initialize())
{
DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIRECTX), NULL, DirectXDialogProc);
- return FALSE;
+ return false;
}
+#endif
LoadBackgroundBitmap();
@@ -1809,14 +1747,14 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
}
hFont = CreateFontIndirect(&logfont);
if (hFont )
- SetAllWindowsFont(hMain, &main_resize, hFont, FALSE);
+ SetAllWindowsFont(hMain, &main_resize, hFont, false);
}
/* Init DirectInput */
if (!DirectInputInitialize())
{
DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIRECTX), NULL, DirectXDialogProc);
- return FALSE;
+ return false;
}
AdjustMetrics();
@@ -1827,7 +1765,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
/* clear keyboard state */
KeyboardStateClear();
- if (GetJoyGUI() == TRUE)
+ if (GetJoyGUI() == true)
{
g_pJoyGUI = &DIJoystick;
if (g_pJoyGUI->init() != 0)
@@ -1848,7 +1786,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
SetCursorPos(GetSystemMetrics(SM_CXSCREEN)/2,GetSystemMetrics(SM_CYSCREEN)/2);
// Then hide it
- ShowCursor(FALSE);
+ ShowCursor(false);
}
nCmdShow = GetWindowState();
@@ -1905,7 +1843,7 @@ static BOOL Win32UI_init(HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow)
"still work, but emulations will fail to execute", MAMEUINAME, MB_OK | MB_ICONERROR);
}
- return TRUE;
+ return true;
}
@@ -1949,7 +1887,9 @@ static void Win32UI_exit()
DestroyAcceleratorTable(hAccel);
DirectInputClose();
+#ifdef UI_DIRECTDRAW
DirectDraw_Close();
+#endif
SetSavedFolderID(GetCurrentFolderID());
SaveGameListOptions();
@@ -1999,7 +1939,7 @@ static LRESULT CALLBACK MameWindowProc(HWND hWnd, UINT message, WPARAM wParam, L
case WM_INITDIALOG:
/* Initialize info for resizing subitems */
GetClientRect(hWnd, &main_resize.rect);
- return TRUE;
+ return true;
case WM_SETFOCUS:
SetFocus(hwndList);
@@ -2011,23 +1951,22 @@ static LRESULT CALLBACK MameWindowProc(HWND hWnd, UINT message, WPARAM wParam, L
case WM_SIZE:
OnSize(hWnd, wParam, LOWORD(lParam), HIWORD(wParam));
- return TRUE;
+ return true;
case WM_MENUSELECT:
return Statusbar_MenuSelect(hWnd, wParam, lParam);
case MM_PLAY_GAME:
MamePlayGame();
- return TRUE;
+ return true;
case WM_INITMENUPOPUP:
UpdateMenu(GetMenu(hWnd));
break;
case WM_CONTEXTMENU:
- if (HandleTreeContextMenu(hWnd, wParam, lParam)
- || HandleScreenShotContextMenu(hWnd, wParam, lParam))
- return FALSE;
+ if (HandleTreeContextMenu(hWnd, wParam, lParam) || HandleScreenShotContextMenu(hWnd, wParam, lParam))
+ return false;
break;
case WM_COMMAND:
@@ -2054,7 +1993,7 @@ static LRESULT CALLBACK MameWindowProc(HWND hWnd, UINT message, WPARAM wParam, L
default:
break;
}
- return TRUE;
+ return true;
case WM_CLOSE:
{
@@ -2140,7 +2079,7 @@ static LRESULT CALLBACK MameWindowProc(HWND hWnd, UINT message, WPARAM wParam, L
case WM_MOUSEMOVE:
{
if (MouseHasBeenMoved())
- ShowCursor(TRUE);
+ ShowCursor(true);
if (g_listview_dragging)
MouseMoveListViewDrag(MAKEPOINTS(lParam));
@@ -2213,7 +2152,7 @@ static LRESULT CALLBACK MameWindowProc(HWND hWnd, UINT message, WPARAM wParam, L
SelectObject(hDC,hFontOld);
ReleaseDC(NULL,hDC);
- return TRUE;
+ return true;
}
case WM_MAME32_FILECHANGED:
@@ -2300,6 +2239,7 @@ static LRESULT CALLBACK MameWindowProc(HWND hWnd, UINT message, WPARAM wParam, L
default:
break;
}
+ res++;
return DefWindowProc(hWnd, message, wParam, lParam);
}
@@ -2309,26 +2249,26 @@ static int HandleKeyboardGUIMessage(HWND hWnd, UINT message, UINT wParam, LONG l
{
case WM_CHAR: /* List-View controls use this message for searching the items "as user types" */
//MessageBox(NULL,"wm_char message arrived","TitleBox",MB_OK);
- return TRUE;
+ return true;
case WM_KEYDOWN:
KeyboardKeyDown(0, wParam, lParam);
- return TRUE;
+ return true;
case WM_KEYUP:
KeyboardKeyUp(0, wParam, lParam);
- return TRUE;
+ return true;
case WM_SYSKEYDOWN:
KeyboardKeyDown(1, wParam, lParam);
- return TRUE;
+ return true;
case WM_SYSKEYUP:
KeyboardKeyUp(1, wParam, lParam);
- return TRUE;
+ return true;
}
- return FALSE; /* message not processed */
+ return false; /* message not processed */
}
static BOOL PumpMessage()
@@ -2336,11 +2276,11 @@ static BOOL PumpMessage()
MSG msg;
if (!GetMessage(&msg, NULL, 0, 0))
- return FALSE;
+ return false;
if (IsWindow(hMain))
{
- BOOL absorbed_key = FALSE;
+ BOOL absorbed_key = false;
if (GetKeyGUI())
absorbed_key = HandleKeyboardGUIMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
else
@@ -2356,7 +2296,7 @@ static BOOL PumpMessage()
}
}
- return TRUE;
+ return true;
}
static BOOL FolderCheck(void)
@@ -2368,7 +2308,7 @@ static BOOL FolderCheck(void)
int iStep = 0;
LV_FINDINFO lvfi;
int nCount = ListView_GetItemCount(hwndList);
- BOOL changed = FALSE;
+ BOOL changed = false;
BOOL res;
MSG msg;
@@ -2387,7 +2327,7 @@ static BOOL FolderCheck(void)
if( nCount > 0)
ProgressBarShow();
else
- return FALSE;
+ return false;
if( nCount < 100 )
iStep = 100 / nCount;
else
@@ -2406,13 +2346,13 @@ static BOOL FolderCheck(void)
if (GetRomAuditResults(nGameIndex) == UNKNOWN)
{
MameUIVerifyRomSet(nGameIndex, 0);
- changed = TRUE;
+ changed = true;
}
if (GetSampleAuditResults(nGameIndex) == UNKNOWN)
{
MameUIVerifySampleSet(nGameIndex);
- changed = TRUE;
+ changed = true;
}
lvfi.flags = LVFI_PARAM;
@@ -2428,7 +2368,7 @@ static BOOL FolderCheck(void)
DispatchMessage(&msg);
}
}
- changed = FALSE;
+ changed = false;
if ((i % iStep) == 0)
ProgressBarStepParam(i, nCount);
}
@@ -2436,14 +2376,15 @@ static BOOL FolderCheck(void)
pDescription = ModifyThe(driver_list::driver(Picker_GetSelectedItem(hwndList)).type.fullname());
SetStatusBarText(0, pDescription);
UpdateStatusBar();
- return TRUE;
+ res++;
+ return true;
}
static BOOL GameCheck(void)
{
LV_FINDINFO lvfi;
int i;
- BOOL changed = FALSE;
+ BOOL changed = false;
BOOL res;
if (game_index == 0)
@@ -2451,22 +2392,22 @@ static BOOL GameCheck(void)
if (game_index >= driver_list::total())
{
- bDoGameCheck = FALSE;
+ bDoGameCheck = false;
ProgressBarHide();
ResetWhichGamesInFolders();
- return FALSE;
+ return false;
}
if (GetRomAuditResults(game_index) == UNKNOWN)
{
MameUIVerifyRomSet(game_index, 0);
- changed = TRUE;
+ changed = true;
}
if (GetSampleAuditResults(game_index) == UNKNOWN)
{
MameUIVerifySampleSet(game_index);
- changed = TRUE;
+ changed = true;
}
lvfi.flags = LVFI_PARAM;
@@ -2478,22 +2419,22 @@ static BOOL GameCheck(void)
if ((game_index % progBarStep) == 0)
ProgressBarStep();
game_index++;
-
+ res++;
return changed;
}
static BOOL OnIdle(HWND hWnd)
{
- static int bFirstTime = TRUE;
- static int bResetList = TRUE;
+ static int bFirstTime = true;
+ static int bResetList = true;
char *pDescription;
int driver_index;
if (bFirstTime)
{
- bResetList = FALSE;
- bFirstTime = FALSE;
+ bResetList = false;
+ bFirstTime = false;
}
if (bDoGameCheck)
{
@@ -2511,32 +2452,32 @@ static BOOL OnIdle(HWND hWnd)
pDescription = ModifyThe(driver_list::driver(driver_index).type.fullname());
SetStatusBarText(0, pDescription);
- idle_work = FALSE;
+ idle_work = false;
UpdateStatusBar();
- bFirstTime = TRUE;
+ bFirstTime = true;
if (!idle_work)
- PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, TRUE),(LPARAM)NULL);
+ PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, true),(LPARAM)NULL);
return idle_work;
}
static void OnSize(HWND hWnd, UINT nState, int nWidth, int nHeight)
{
- static BOOL firstTime = TRUE;
+ static BOOL firstTime = true;
if (nState != SIZE_MAXIMIZED && nState != SIZE_RESTORED)
return;
ResizeWindow(hWnd, &main_resize);
ResizeProgressBar();
- if (firstTime == FALSE)
+ if (firstTime == false)
OnSizeSplitter(hMain);
- //firstTime = FALSE;
+ //firstTime = false;
/* Update the splitters structures as appropriate */
RecalcSplitters();
- if (firstTime == FALSE)
+ if (firstTime == false)
ResizePickerControls(hMain);
- firstTime = FALSE;
+ firstTime = false;
UpdateScreenShot();
}
@@ -2647,7 +2588,7 @@ static void ResizeWindow(HWND hParent, Resize *r)
}
MoveWindow(hControl, rect.left, rect.top,
(rect.right - rect.left),
- (rect.bottom - rect.top), TRUE);
+ (rect.bottom - rect.top), true);
/* Take care of subcontrols, if appropriate */
if (ri->subwindow )
@@ -2679,9 +2620,9 @@ static void ProgressBarShow()
MoveWindow(hProgWnd, rect.left, rect.top,
rect.right - rect.left,
- rect.bottom - rect.top, TRUE);
+ rect.bottom - rect.top, true);
- bProgressShown = TRUE;
+ bProgressShown = true;
}
static void ProgressBarHide()
@@ -2721,7 +2662,7 @@ static void ProgressBarHide()
SendMessage(hStatusBar, SB_SETPARTS, (WPARAM)numParts, (LPARAM)(LPINT)widths);
UpdateStatusBar();
- bProgressShown = FALSE;
+ bProgressShown = false;
}
static void ResizeProgressBar()
@@ -2735,7 +2676,7 @@ static void ResizeProgressBar()
StatusBar_GetItemRect(hStatusBar, 1, &rect);
MoveWindow(hProgWnd, rect.left, rect.top,
rect.right - rect.left,
- rect.bottom - rect.top, TRUE);
+ rect.bottom - rect.top, true);
}
else
{
@@ -2774,7 +2715,7 @@ static void CopyToolTipText(LPTOOLTIPTEXT lpttt)
int i;
int iButton = lpttt->hdr.idFrom;
static TCHAR String[1024];
- BOOL bConverted = FALSE;
+ BOOL bConverted = false;
TCHAR* t_gameinfostatus;
/* Map command ID to string index */
@@ -2783,7 +2724,7 @@ static void CopyToolTipText(LPTOOLTIPTEXT lpttt)
if (CommandToString[i] == iButton)
{
iButton = i;
- bConverted = TRUE;
+ bConverted = true;
break;
}
}
@@ -2807,7 +2748,7 @@ static void CopyToolTipText(LPTOOLTIPTEXT lpttt)
SendMessage(hStatusBar, SB_GETTEXT, (WPARAM)iButton, (LPARAM)&String );
else {
//for first pane we get the Status directly, to get the line breaks
- t_gameinfostatus = ui_wstring_from_utf8( GameInfoStatus(Picker_GetSelectedItem(hwndList), FALSE));
+ t_gameinfostatus = ui_wstring_from_utf8( GameInfoStatus(Picker_GetSelectedItem(hwndList), false));
if( !t_gameinfostatus )
return;
_tcscpy(String, t_gameinfostatus);
@@ -2927,7 +2868,7 @@ static void UpdateStatusBar()
DisableSelection();
else
{
- const char* pStatus = GameInfoStatus(i, FALSE);
+ const char* pStatus = GameInfoStatus(i, false);
SetStatusBarText(1, pStatus);
}
}
@@ -2939,20 +2880,20 @@ static void UpdateHistory(void)
TEXTMETRIC tm ;
int nLines, nLineHeight;
//DWORD dwStyle = GetWindowLong(GetDlgItem(hMain, IDC_HISTORY), GWL_STYLE);
- have_history = FALSE;
+ have_history = false;
if (GetSelectedPick() >= 0)
{
char *histText = GetArcadeHistory(Picker_GetSelectedItem(hwndList));
- have_history = (histText && histText[0]) ? TRUE : FALSE;
+ have_history = (histText && histText[0]) ? true : false;
win_set_window_text_utf8(GetDlgItem(hMain, IDC_HISTORY), histText);
}
if (have_history && GetShowScreenShot()
&& ((TabView_GetCurrentTab(hTabCtrl) == TAB_HISTORY) ||
- (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) ||
- (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) ))
+ (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == false) ||
+ (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == false) ))
{
Edit_GetRect(GetDlgItem(hMain, IDC_HISTORY),&rect);
nLines = Edit_GetLineCount(GetDlgItem(hMain, IDC_HISTORY) );
@@ -2962,12 +2903,12 @@ static void UpdateHistory(void)
if( ( (rect.bottom - rect.top) / nLineHeight) < (nLines) )
{
//more than one Page, so show Scrollbar
- SetScrollRange(GetDlgItem(hMain, IDC_HISTORY), SB_VERT, 0, nLines, TRUE);
+ SetScrollRange(GetDlgItem(hMain, IDC_HISTORY), SB_VERT, 0, nLines, true);
}
else
{
//hide Scrollbar
- SetScrollRange(GetDlgItem(hMain, IDC_HISTORY),SB_VERT, 0, 0, TRUE);
+ SetScrollRange(GetDlgItem(hMain, IDC_HISTORY),SB_VERT, 0, 0, true);
}
ShowWindow(GetDlgItem(hMain, IDC_HISTORY), SW_SHOW);
@@ -2989,7 +2930,7 @@ static void DisableSelection()
mmi.fType = MFT_STRING;
mmi.dwTypeData = (TCHAR *) TEXT("&Play");
mmi.cch = _tcslen(mmi.dwTypeData);
- SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mmi);
+ SetMenuItemInfo(hMenu, ID_FILE_PLAY, false, &mmi);
EnableMenuItem(hMenu, ID_FILE_PLAY, MF_GRAYED);
EnableMenuItem(hMenu, ID_FILE_PLAY_RECORD, MF_GRAYED);
@@ -2999,7 +2940,7 @@ static void DisableSelection()
SetStatusBarText(1, "");
SetStatusBarText(3, "");
- have_selection = FALSE;
+ have_selection = false;
if (prev_have_selection != have_selection)
UpdateScreenShot();
@@ -3023,12 +2964,12 @@ static void EnableSelection(int nGame)
mmi.fType = MFT_STRING;
mmi.dwTypeData = buf;
mmi.cch = _tcslen(mmi.dwTypeData);
- SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mmi);
+ SetMenuItemInfo(hMenu, ID_FILE_PLAY, false, &mmi);
pText = ModifyThe(driver_list::driver(nGame).type.fullname());
SetStatusBarText(0, pText);
/* Add this game's status to the status bar */
- pText = GameInfoStatus(nGame, FALSE);
+ pText = GameInfoStatus(nGame, false);
SetStatusBarText(1, pText);
SetStatusBarText(3, "");
@@ -3040,11 +2981,11 @@ static void EnableSelection(int nGame)
if (!oldControl)
EnableMenuItem(hMenu, ID_GAME_PROPERTIES, MF_ENABLED);
- if (bProgressShown && bListReady == TRUE)
+ if (bProgressShown && bListReady == true)
{
SetDefaultGame(ModifyThe(driver_list::driver(nGame).name));
}
- have_selection = TRUE;
+ have_selection = true;
UpdateScreenShot();
@@ -3088,7 +3029,7 @@ static void PaintBackgroundImage(HWND hWnd, HRGN hRgn, int x, int y)
if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL)
{
- SelectPalette(htempDC, hPAL, FALSE);
+ SelectPalette(htempDC, hPAL, false);
RealizePalette(htempDC);
}
@@ -3112,7 +3053,7 @@ static LPCSTR GetCloneParentName(int nItem)
{
int nParentIndex = -1;
- if (DriverIsClone(nItem) == TRUE)
+ if (DriverIsClone(nItem) == true)
{
nParentIndex = GetParentIndex(&driver_list::driver(nItem));
if( nParentIndex >= 0)
@@ -3142,7 +3083,7 @@ static BOOL TreeViewNotify(LPNMHDR nm)
UpdateScreenShot();
}
}
- return TRUE;
+ return true;
}
case TVN_BEGINLABELEDIT :
{
@@ -3152,11 +3093,11 @@ static BOOL TreeViewNotify(LPNMHDR nm)
if (folder->m_dwFlags & F_CUSTOM)
{
// user can edit custom folder names
- g_in_treeview_edit = TRUE;
- return FALSE;
+ g_in_treeview_edit = true;
+ return false;
}
// user can't edit built in folder names
- return TRUE;
+ return true;
}
case TVN_ENDLABELEDIT :
{
@@ -3165,14 +3106,14 @@ static BOOL TreeViewNotify(LPNMHDR nm)
char* utf8_szText;
BOOL result;
- g_in_treeview_edit = FALSE;
+ g_in_treeview_edit = false;
if (ptvdi->item.pszText == NULL || _tcslen(ptvdi->item.pszText) == 0)
- return FALSE;
+ return false;
utf8_szText = ui_utf8_from_wstring(ptvdi->item.pszText);
if( !utf8_szText )
- return FALSE;
+ return false;
result = TryRenameCustomFolder(folder, utf8_szText);
@@ -3181,7 +3122,7 @@ static BOOL TreeViewNotify(LPNMHDR nm)
return result;
}
}
- return FALSE;
+ return false;
}
@@ -3542,7 +3483,7 @@ static void PollGUIJoystick()
t_exec_command = ui_wstring_from_utf8(exec_command);
if( !t_exec_command )
return;
- CreateProcess(NULL, t_exec_command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+ CreateProcess(NULL, t_exec_command, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
free(t_exec_command);
@@ -3563,7 +3504,7 @@ static void PollGUIJoystick()
static void SetView(int menu_id)
{
- BOOL force_reset = FALSE;
+ BOOL force_reset = false;
int i;
// first uncheck previous menu item, check new one
@@ -3573,7 +3514,7 @@ static void SetView(int menu_id)
if (Picker_GetViewID(hwndList) == VIEW_GROUPED || menu_id == ID_VIEW_GROUPED)
{
// this changes the sort order, so redo everything
- force_reset = TRUE;
+ force_reset = true;
}
for (i = 0; i < sizeof(s_nPickers) / sizeof(s_nPickers[0]); i++)
@@ -3591,7 +3532,7 @@ static void ResetListView()
int i;
int current_game;
LV_ITEM lvi;
- BOOL no_selection = FALSE;
+ BOOL no_selection = false;
LPTREEFOLDER lpFolder = GetCurrentFolder();
HRESULT res;
BOOL b_res;
@@ -3599,13 +3540,13 @@ static void ResetListView()
if (!lpFolder)
return;
- /* If the last folder was empty, no_selection is TRUE */
- if (have_selection == FALSE)
- no_selection = TRUE;
+ /* If the last folder was empty, no_selection is true */
+ if (have_selection == false)
+ no_selection = true;
current_game = Picker_GetSelectedItem(hwndList);
- SetWindowRedraw(hwndList,FALSE);
+ SetWindowRedraw(hwndList,false);
b_res = ListView_DeleteAllItems(hwndList);
@@ -3651,10 +3592,11 @@ static void ResetListView()
if (GetViewMode() == VIEW_SMALL_ICONS)
SetView(ID_VIEW_SMALL_ICON);
- SetWindowRedraw(hwndList, TRUE);
+ SetWindowRedraw(hwndList, true);
UpdateStatusBar();
-
+ res++;
+ b_res++;
}
static void UpdateGameList(BOOL bUpdateRomAudit, BOOL bUpdateSampleAudit)
@@ -3669,15 +3611,15 @@ static void UpdateGameList(BOOL bUpdateRomAudit, BOOL bUpdateSampleAudit)
SetSampleAuditResults(i, UNKNOWN);
}
- idle_work = TRUE;
- bDoGameCheck = TRUE;
+ idle_work = true;
+ bDoGameCheck = true;
game_index = 0;
ReloadIcons();
// Let REFRESH also load new background if found
LoadBackgroundBitmap();
- InvalidateRect(hMain,NULL,TRUE);
+ InvalidateRect(hMain,NULL,true);
Picker_ResetIdle(hwndList);
}
@@ -3724,13 +3666,13 @@ UINT_PTR CALLBACK CFHookProc(
SendDlgItemMessage(hdlg, cmb4, CB_ADDSTRING, 0, (LPARAM)TEXT("Custom"));
SendDlgItemMessage(hdlg, cmb4, CB_SETITEMDATA,(WPARAM)iIndex,(LPARAM)cList);
SendDlgItemMessage(hdlg, cmb4, CB_SETCURSEL,(WPARAM)iIndex,0 );
- return TRUE;
+ return true;
}
}
}
break;
}
- return FALSE;
+ return false;
}
static void PickFont(void)
@@ -3767,7 +3709,7 @@ static void PickFont(void)
textColor = RGB(240, 240, 240);
}
- SetAllWindowsFont(hMain, &main_resize, hFont, TRUE);
+ SetAllWindowsFont(hMain, &main_resize, hFont, true);
hWnd = GetWindow(hMain, GW_CHILD);
while(hWnd)
@@ -3777,10 +3719,12 @@ static void PickFont(void)
if (!_tcscmp(szClass, TEXT("SysListView32")))
{
b_res = ListView_SetTextColor(hWnd, textColor);
+ b_res++;
}
else if (!_tcscmp(szClass, TEXT("SysTreeView32")))
{
res = TreeView_SetTextColor(hTreeView, textColor);
+ res++;
}
}
hWnd = GetWindow(hWnd, GW_HWNDNEXT);
@@ -3817,7 +3761,7 @@ static void PickCloneColor(void)
cClonecolor = GetListCloneColor();
PickColor( &cClonecolor);
SetListCloneColor(cClonecolor);
- InvalidateRect(hwndList,NULL,FALSE);
+ InvalidateRect(hwndList,NULL,false);
}
static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
@@ -3831,104 +3775,104 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
{
case ID_FILE_PLAY:
MamePlayGame();
- return TRUE;
+ return true;
case ID_FILE_PLAY_RECORD:
MamePlayRecordGame();
- return TRUE;
+ return true;
case ID_FILE_PLAY_BACK:
MamePlayBackGame();
- return TRUE;
+ return true;
case ID_FILE_PLAY_RECORD_WAVE:
MamePlayRecordWave();
- return TRUE;
+ return true;
case ID_FILE_PLAY_RECORD_MNG:
MamePlayRecordMNG();
- return TRUE;
+ return true;
case ID_FILE_PLAY_RECORD_AVI:
MamePlayRecordAVI();
- return TRUE;
+ return true;
case ID_FILE_LOADSTATE :
MameLoadState();
- return TRUE;
+ return true;
case ID_FILE_AUDIT:
AuditDialog(hMain, 1);
ResetWhichGamesInFolders();
ResetListView();
SetFocus(hwndList);
- return TRUE;
+ return true;
case ID_FILE_AUDIT_X:
AuditDialog(hMain, 2);
ResetWhichGamesInFolders();
ResetListView();
SetFocus(hwndList);
- return TRUE;
+ return true;
case ID_FILE_EXIT:
PostMessage(hMain, WM_CLOSE, 0, 0);
- return TRUE;
+ return true;
case ID_VIEW_LARGE_ICON:
SetView(ID_VIEW_LARGE_ICON);
- return TRUE;
+ return true;
case ID_VIEW_SMALL_ICON:
SetView(ID_VIEW_SMALL_ICON);
ResetListView();
- return TRUE;
+ return true;
case ID_VIEW_LIST_MENU:
SetView(ID_VIEW_LIST_MENU);
- return TRUE;
+ return true;
case ID_VIEW_DETAIL:
SetView(ID_VIEW_DETAIL);
- return TRUE;
+ return true;
case ID_VIEW_GROUPED:
SetView(ID_VIEW_GROUPED);
- return TRUE;
+ return true;
/* Arrange Icons submenu */
case ID_VIEW_BYGAME:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(COLUMN_GAMES);
Picker_Sort(hwndList);
break;
case ID_VIEW_BYDIRECTORY:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(COLUMN_DIRECTORY);
Picker_Sort(hwndList);
break;
case ID_VIEW_BYMANUFACTURER:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(COLUMN_MANUFACTURER);
Picker_Sort(hwndList);
break;
case ID_VIEW_BYTIMESPLAYED:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(COLUMN_PLAYED);
Picker_Sort(hwndList);
break;
case ID_VIEW_BYTYPE:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(COLUMN_TYPE);
Picker_Sort(hwndList);
break;
case ID_VIEW_BYYEAR:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(COLUMN_YEAR);
Picker_Sort(hwndList);
break;
@@ -3967,7 +3911,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
ShowWindow(hTabCtrl, (bShowTabCtrl) ? SW_SHOW : SW_HIDE);
ResizePickerControls(hMain);
UpdateScreenShot();
- InvalidateRect(hMain,NULL,TRUE);
+ InvalidateRect(hMain,NULL,true);
break;
/*
@@ -4041,10 +3985,10 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
/* Tree Context Menu */
case ID_CONTEXT_FILTERS:
if (DialogBox(GetModuleHandle(NULL),
- MAKEINTRESOURCE(IDD_FILTERS), hMain, FilterDialogProc) == TRUE)
+ MAKEINTRESOURCE(IDD_FILTERS), hMain, FilterDialogProc) == true)
ResetListView();
SetFocus(hwndList);
- return TRUE;
+ return true;
// ScreenShot Context Menu
// select current tab
@@ -4056,7 +4000,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
case ID_VIEW_TAB_CONTROL_PANEL :
case ID_VIEW_TAB_PCB :
case ID_VIEW_TAB_HISTORY:
- if (id == ID_VIEW_TAB_HISTORY && GetShowTab(TAB_HISTORY) == FALSE)
+ if (id == ID_VIEW_TAB_HISTORY && GetShowTab(TAB_HISTORY) == false)
break;
TabView_SetCurrentTab(hTabCtrl, id - ID_VIEW_TAB_SCREENSHOT);
@@ -4076,7 +4020,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
{
int toggle_flag = id - ID_TOGGLE_TAB_SCREENSHOT;
- if (AllowedToSetShowTab(toggle_flag,!GetShowTab(toggle_flag)) == FALSE)
+ if (AllowedToSetShowTab(toggle_flag,!GetShowTab(toggle_flag)) == false)
{
// attempt to hide the last tab
// should show error dialog? hide picture area? or ignore?
@@ -4087,7 +4031,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
TabView_Reset(hTabCtrl);
- if (TabView_GetCurrentTab(hTabCtrl) == toggle_flag && GetShowTab(toggle_flag) == FALSE)
+ if (TabView_GetCurrentTab(hTabCtrl) == toggle_flag && GetShowTab(toggle_flag) == false)
{
// we're deleting the tab we're on, so go to the next one
TabView_CalculateNextTab(hTabCtrl);
@@ -4107,27 +4051,27 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
/* Header Context Menu */
case ID_SORT_ASCENDING:
- SetSortReverse(FALSE);
+ SetSortReverse(false);
SetSortColumn(Picker_GetRealColumnFromViewColumn(hwndList, lastColumnClick));
Picker_Sort(hwndList);
break;
case ID_SORT_DESCENDING:
- SetSortReverse(TRUE);
+ SetSortReverse(true);
SetSortColumn(Picker_GetRealColumnFromViewColumn(hwndList, lastColumnClick));
Picker_Sort(hwndList);
break;
case ID_CUSTOMIZE_FIELDS:
if (DialogBox(GetModuleHandle(NULL),
- MAKEINTRESOURCE(IDD_COLUMNS), hMain, ColumnDialogProc) == TRUE)
- ResetColumnDisplay(FALSE);
+ MAKEINTRESOURCE(IDD_COLUMNS), hMain, ColumnDialogProc) == true)
+ ResetColumnDisplay(false);
SetFocus(hwndList);
- return TRUE;
+ return true;
/* View Menu */
case ID_VIEW_LINEUPICONS:
- if( codeNotify == FALSE)
+ if( codeNotify == false)
ResetListView();
else
{
@@ -4195,16 +4139,16 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
break;
case ID_UPDATE_GAMELIST:
- UpdateGameList(TRUE, TRUE);
+ UpdateGameList(true, true);
break;
case ID_OPTIONS_FONT:
PickFont();
- return TRUE;
+ return true;
case ID_OPTIONS_CLONE_COLOR:
PickCloneColor();
- return TRUE;
+ return true;
case ID_OPTIONS_DEFAULTS:
/* Check the return value to see if changes were applied */
@@ -4213,7 +4157,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
InitDefaultPropertyPage(hInst, hwnd);
}
SetFocus(hwndList);
- return TRUE;
+ return true;
case ID_OPTIONS_DIR:
{
@@ -4225,27 +4169,27 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
SaveDefaultOptions();
SaveOptions();
- BOOL bUpdateRoms = ((nResult & DIRDLG_ROMS) == DIRDLG_ROMS) ? TRUE : FALSE;
- BOOL bUpdateSamples = ((nResult & DIRDLG_SAMPLES) == DIRDLG_SAMPLES) ? TRUE : FALSE;
+ BOOL bUpdateRoms = ((nResult & DIRDLG_ROMS) == DIRDLG_ROMS) ? true : false;
+ BOOL bUpdateSamples = ((nResult & DIRDLG_SAMPLES) == DIRDLG_SAMPLES) ? true : false;
if (s_pWatcher)
{
if (bUpdateRoms)
- DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), TRUE);
+ DirWatcher_Watch(s_pWatcher, 0, GetRomDirs(), true);
if (bUpdateSamples)
- DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), TRUE);
+ DirWatcher_Watch(s_pWatcher, 1, GetSampleDirs(), true);
}
/* update game list */
- if (bUpdateRoms == TRUE || bUpdateSamples == TRUE)
+ if (bUpdateRoms == true || bUpdateSamples == true)
UpdateGameList(bUpdateRoms, bUpdateSamples);
SetFocus(hwndList);
}
- return TRUE;
+ return true;
case ID_OPTIONS_RESET_DEFAULTS:
- if (DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_RESET), hMain, ResetDialogProc) == TRUE)
+ if (DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_RESET), hMain, ResetDialogProc) == true)
{
// these may have been changed
SaveDefaultOptions();
@@ -4258,7 +4202,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
ResetListView();
SetFocus(hwndList);
}
- return TRUE;
+ return true;
case ID_OPTIONS_INTERFACE:
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_INTERFACE_OPTIONS), hMain, InterfaceDialogProc);
@@ -4270,7 +4214,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL ); // Scale to seconds
}
- return TRUE;
+ return true;
case ID_OPTIONS_BG:
{
@@ -4289,7 +4233,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
OPENFILENAME OFN;
static TCHAR szFile[MAX_PATH] = TEXT("\0");
if( !t_bgdir )
- return FALSE;
+ return false;
OFN.lStructSize = sizeof(OPENFILENAME);
OFN.hwndOwner = hMain;
@@ -4317,16 +4261,16 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
free(t_bgdir);
utf8_szFile = ui_utf8_from_wstring(szFile);
if( !utf8_szFile )
- return FALSE;
+ return false;
// Make this file as the new default
SetBgDir(utf8_szFile);
// Display new background
LoadBackgroundBitmap();
- InvalidateRect(hMain, NULL, TRUE);
+ InvalidateRect(hMain, NULL, true);
free(utf8_szFile);
- return TRUE;
+ return true;
}
free(t_bgdir);
}
@@ -4340,7 +4284,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
{
SetHistoryFileName(filename);
}
- return TRUE;
+ return true;
}
case ID_OPTIONS_MAMEINFO:
{
@@ -4350,13 +4294,13 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
{
SetMAMEInfoFileName(filename);
}
- return TRUE;
+ return true;
}
#endif
case ID_HELP_ABOUT:
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hMain, AboutDialogProc);
SetFocus(hwndList);
- return TRUE;
+ return true;
case IDOK :
/* cmk -- might need to check more codes here, not sure */
@@ -4365,8 +4309,8 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
/* enter key */
if (g_in_treeview_edit)
{
- res = TreeView_EndEditLabelNow(hTreeView, FALSE);
- return TRUE;
+ res = TreeView_EndEditLabelNow(hTreeView, false);
+ return true;
}
else
if (have_selection)
@@ -4376,7 +4320,7 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
case IDCANCEL : /* esc key */
if (g_in_treeview_edit)
- res = TreeView_EndEditLabelNow(hTreeView, TRUE);
+ res = TreeView_EndEditLabelNow(hTreeView, true);
break;
case IDC_PLAY_GAME :
@@ -4487,13 +4431,13 @@ static BOOL MameCommand(HWND hwnd,int id, HWND hwndCtl, UINT codeNotify)
ShellExecute(hMain, TEXT("open"), g_helpInfo[i].lpFile, TEXT(""), NULL, SW_SHOWNORMAL);
// else
// DisplayTextFile(hMain, g_helpInfo[i].lpFile);
- return FALSE;
+ return false;
}
}
break;
}
-
- return FALSE;
+ res++;
+ return false;
}
static void LoadBackgroundBitmap()
@@ -4556,12 +4500,10 @@ static const TCHAR *GamePicker_GetItemString(HWND hwndPicker, int nItem, int nCo
utf8_s = DriverIsVertical(nItem) ? "Vertical" : "Horizontal";
break;
-#ifdef SHOW_COLUMN_ROMS
case COLUMN_ROMS:
utf8_s = GetAuditString(GetRomAuditResults(nItem));
break;
-#endif
-#ifdef SHOW_COLUMN_SAMPLES
+
case COLUMN_SAMPLES:
/* Samples */
if (DriverUsesSamples(nItem))
@@ -4569,7 +4511,7 @@ static const TCHAR *GamePicker_GetItemString(HWND hwndPicker, int nItem, int nCo
else
s = TEXT("-");
break;
-#endif
+
case COLUMN_DIRECTORY:
/* Driver name (directory) */
utf8_s = driver_list::driver(nItem).name;
@@ -4721,11 +4663,12 @@ static void InitListView()
CreateIcons();
- ResetColumnDisplay(TRUE);
+ ResetColumnDisplay(true);
// Allow selection to change the default saved game
- bListReady = TRUE;
+ bListReady = true;
free(t_bgdir);
+ res++;
}
static void AddDriverIcon(int nItem,int default_icon_index)
@@ -4954,15 +4897,14 @@ static int GamePicker_Compare(HWND hwndPicker, int index1, int index2, int sort_
switch (sort_subitem)
{
case COLUMN_GAMES:
- return core_stricmp(ModifyThe(driver_list::driver(index1).type.fullname()),
- ModifyThe(driver_list::driver(index2).type.fullname()));
+ return core_stricmp(ModifyThe(driver_list::driver(index1).type.fullname()), ModifyThe(driver_list::driver(index2).type.fullname()));
case COLUMN_ORIENTATION:
nTemp1 = DriverIsVertical(index1) ? 1 : 0;
nTemp2 = DriverIsVertical(index2) ? 1 : 0;
value = nTemp1 - nTemp2;
break;
-#ifdef SHOW_COLUMN_SAMPLES
+
case COLUMN_SAMPLES:
nTemp1 = -1;
if (DriverUsesSamples(index1))
@@ -4995,7 +4937,7 @@ static int GamePicker_Compare(HWND hwndPicker, int index1, int index2, int sort_
}
value = nTemp2 - nTemp1;
break;
-#endif
+
case COLUMN_DIRECTORY:
value = core_stricmp(driver_list::driver(index1).name, driver_list::driver(index2).name);
break;
@@ -5071,26 +5013,20 @@ int GetSelectedPick()
static HICON GetSelectedPickItemIcon()
{
LV_ITEM lvi;
- BOOL res;
-
lvi.iItem = GetSelectedPick();
lvi.iSubItem = 0;
lvi.mask = LVIF_IMAGE;
- res = ListView_GetItem(hwndList, &lvi);
-
+ BOOL res = ListView_GetItem(hwndList, &lvi);
+ res++;
return ImageList_GetIcon(hLarge, lvi.iImage, ILD_TRANSPARENT);
}
static void SetRandomPickItem()
{
- int nListCount;
-
- nListCount = ListView_GetItemCount(hwndList);
+ int nListCount = ListView_GetItemCount(hwndList);
if (nListCount > 0)
- {
Picker_SetSelectedPick(hwndList, rand() % nListCount);
- }
}
BOOL CommonFileDialog(common_file_dialog_proc cfd, char *filename, int filetype)
@@ -5542,7 +5478,7 @@ static void MamePlayGameWithOptions(int nGame, const play_options *playopts)
if (GetCycleScreenshot() > 0)
KillTimer(hMain, SCREENSHOT_TIMER);
- in_emulation = TRUE;
+ in_emulation = true;
dwExitCode = RunMAME(nGame, playopts);
if (dwExitCode == 0)
@@ -5555,7 +5491,7 @@ static void MamePlayGameWithOptions(int nGame, const play_options *playopts)
ShowWindow(hMain, SW_SHOW);
}
- in_emulation = FALSE;
+ in_emulation = false;
// re-sort if sorting on # of times played
if (GetSortColumn() == COLUMN_PLAYED)
@@ -5570,6 +5506,7 @@ static void MamePlayGameWithOptions(int nGame, const play_options *playopts)
SetTimer(hMain, JOYGUI_TIMER, JOYGUI_MS, NULL);
if (GetCycleScreenshot() > 0)
SetTimer(hMain, SCREENSHOT_TIMER, GetCycleScreenshot()*1000, NULL); //scale to seconds
+ res++;
}
/* Toggle ScreenShot ON/OFF */
@@ -5577,12 +5514,12 @@ static void ToggleScreenShot(void)
{
BOOL showScreenShot = GetShowScreenShot();
- SetShowScreenShot((showScreenShot) ? FALSE : TRUE);
+ SetShowScreenShot((showScreenShot) ? false : true);
UpdateScreenShot();
/* Redraw list view */
if (hBackground && showScreenShot)
- InvalidateRect(hwndList, NULL, FALSE);
+ InvalidateRect(hwndList, NULL, false);
}
static void AdjustMetrics(void)
@@ -5655,6 +5592,8 @@ static void AdjustMetrics(void)
SetWindowArea(&area);
SetWindowPos(hMain, 0, area.x, area.y, area.width, area.height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
+ res++;
+ b_res++;
}
int FindIconIndex(int nIconResource)
@@ -5686,7 +5625,7 @@ static int GetIconForDriver(int nItem)
if (DriverUsesRoms(nItem))
{
int audit_result = GetRomAuditResults(nItem);
- if (IsAuditResultKnown(audit_result) == FALSE)
+ if (IsAuditResultKnown(audit_result) == false)
return 2;
#ifdef SHOW_MISSING_ROMS_ICON
if (IsAuditResultYes(audit_result))
@@ -5726,7 +5665,7 @@ static BOOL HandleTreeContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam)
BOOL res;
if ((HWND)wParam != GetDlgItem(hWnd, IDC_TREE))
- return FALSE;
+ return false;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
@@ -5751,8 +5690,8 @@ static BOOL HandleTreeContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam)
TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,0,hWnd,NULL);
DestroyMenu(hTreeMenu);
-
- return TRUE;
+ res++;
+ return true;
}
@@ -5782,7 +5721,7 @@ static BOOL HandleScreenShotContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam)
POINT pt;
if ((HWND)wParam != GetDlgItem(hWnd, IDC_SSPICTURE) && (HWND)wParam != GetDlgItem(hWnd, IDC_SSFRAME))
- return FALSE;
+ return false;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
@@ -5798,7 +5737,7 @@ static BOOL HandleScreenShotContextMenu(HWND hWnd, WPARAM wParam, LPARAM lParam)
DestroyMenu(hMenuLoad);
- return TRUE;
+ return true;
}
static void UpdateMenu(HMENU hMenu)
@@ -5825,7 +5764,7 @@ static void UpdateMenu(HMENU hMenu)
mItem.dwTypeData = buf;
mItem.cch = _tcslen(mItem.dwTypeData);
- SetMenuItemInfo(hMenu, ID_FILE_PLAY, FALSE, &mItem);
+ SetMenuItemInfo(hMenu, ID_FILE_PLAY, false, &mItem);
EnableMenuItem(hMenu, ID_CONTEXT_SELECT_RANDOM, MF_ENABLED);
@@ -5913,7 +5852,7 @@ void InitTreeContextMenu(HMENU hTreeMenu)
hMenu = GetSubMenu(hTreeMenu, 0);
- if (GetMenuItemInfo(hMenu,3,TRUE,&mii) == FALSE)
+ if (GetMenuItemInfo(hMenu,3,true,&mii) == false)
{
dprintf("can't find show folders context menu\n");
return;
@@ -5943,9 +5882,9 @@ void InitTreeContextMenu(HMENU hTreeMenu)
// menu in resources has one empty item (needed for the submenu to setup properly)
// so overwrite this one, append after
if (i == 0)
- SetMenuItemInfo(hMenu,ID_CONTEXT_SHOW_FOLDER_START,FALSE,&mii);
+ SetMenuItemInfo(hMenu,ID_CONTEXT_SHOW_FOLDER_START,false,&mii);
else
- InsertMenuItem(hMenu,i,FALSE,&mii);
+ InsertMenuItem(hMenu,i,false,&mii);
free(t_title);
}
@@ -5960,7 +5899,7 @@ void InitBodyContextMenu(HMENU hBodyContextMenu)
ZeroMemory(&mii,sizeof(mii));
mii.cbSize = sizeof(mii);
- if (GetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,FALSE,&mii) == FALSE)
+ if (GetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,false,&mii) == false)
{
dprintf("can't find show folders context menu\n");
return;
@@ -5976,7 +5915,7 @@ void InitBodyContextMenu(HMENU hBodyContextMenu)
// menu in resources has one default item
// so overwrite this one
- SetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,FALSE,&mii);
+ SetMenuItemInfo(hBodyContextMenu,ID_FOLDER_SOURCEPROPERTIES,false,&mii);
if( ! DriverIsVector(Picker_GetSelectedItem(hwndList) ) )
EnableMenuItem(hBodyContextMenu, ID_FOLDER_VECTORPROPERTIES, MF_GRAYED);
}
@@ -5986,14 +5925,14 @@ void ToggleShowFolder(int folder)
{
int current_id = GetCurrentFolderID();
- SetWindowRedraw(hwndList,FALSE);
+ SetWindowRedraw(hwndList,false);
SetShowFolder(folder,!GetShowFolder(folder));
ResetTreeViewFolders();
SelectTreeViewFolder(current_id);
- SetWindowRedraw(hwndList,TRUE);
+ SetWindowRedraw(hwndList,true);
}
static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -6005,12 +5944,12 @@ static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
case WM_MOUSEMOVE:
{
if (MouseHasBeenMoved())
- ShowCursor(TRUE);
+ ShowCursor(true);
break;
}
case WM_ERASEBKGND:
- return TRUE;
+ return true;
case WM_PAINT:
{
POINT p = { 0, 0 };
@@ -6019,7 +5958,7 @@ static LRESULT CALLBACK HistoryWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
MapWindowPoints(hWnd,hTreeView,&p,1);
PaintBackgroundImage(hWnd, NULL, p.x, p.y);
/* to ensure our parent procedure repaints the whole client area */
- InvalidateRect(hWnd, NULL, FALSE);
+ InvalidateRect(hWnd, NULL, false);
break;
}
}
@@ -6034,7 +5973,7 @@ static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
case WM_MOUSEMOVE:
{
if (MouseHasBeenMoved())
- ShowCursor(TRUE);
+ ShowCursor(true);
break;
}
@@ -6052,8 +5991,8 @@ static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
// no more no man's land, the Cursor changes when Edit control is left, should be enough feedback
if (have_history &&
( ( (TabView_GetCurrentTab(hTabCtrl) == TAB_HISTORY) ||
- (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) ||
- (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == FALSE) ) &&
+ (TabView_GetCurrentTab(hTabCtrl) == GetHistoryTab() && GetShowTab(TAB_HISTORY) == false) ||
+ (TAB_ALL == GetHistoryTab() && GetShowTab(TAB_HISTORY) == false) ) &&
// (rect.top - 6) < pt.y && pt.y < (rect.bottom + 6) ) )
PtInRect( &rect, pt ) ) )
@@ -6068,7 +6007,7 @@ static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
break;
case WM_CONTEXTMENU:
if ( HandleScreenShotContextMenu(hWnd, wParam, lParam))
- return FALSE;
+ return false;
break;
}
@@ -6077,7 +6016,7 @@ static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
switch (uMsg)
{
case WM_ERASEBKGND :
- return TRUE;
+ return true;
case WM_PAINT :
{
RECT rect,nodraw_rect;
@@ -6115,7 +6054,7 @@ static LRESULT CALLBACK PictureFrameWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
DeleteObject(region);
/* to ensure our parent procedure repaints the whole client area */
- InvalidateRect(hWnd, NULL, FALSE);
+ InvalidateRect(hWnd, NULL, false);
break;
}
@@ -6129,7 +6068,7 @@ static LRESULT CALLBACK PictureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
switch (uMsg)
{
case WM_ERASEBKGND :
- return TRUE;
+ return true;
case WM_PAINT :
{
PAINTSTRUCT ps;
@@ -6203,7 +6142,7 @@ static LRESULT CALLBACK PictureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
EndPaint(hWnd,&ps);
- return TRUE;
+ return true;
}
}
@@ -6253,38 +6192,34 @@ static void RemoveGameCustomFolder(int driver_index)
static void BeginListViewDrag(NM_LISTVIEW *pnmv)
{
- LV_ITEM lvi;
- POINT pt;
- BOOL res;
-
+ LV_ITEM lvi;
lvi.iItem = pnmv->iItem;
lvi.mask = LVIF_PARAM;
- res = ListView_GetItem(hwndList, &lvi);
+ BOOL res = ListView_GetItem(hwndList, &lvi);
+ res++;
game_dragged = lvi.lParam;
+ POINT pt;
pt.x = 0;
pt.y = 0;
- /* Tell the list view control to create an image to use
- for dragging. */
- himl_drag = ListView_CreateDragImage(hwndList,pnmv->iItem,&pt);
+ /* Tell the list view control to create an image to use for dragging. */
+ himl_drag = ListView_CreateDragImage(hwndList,pnmv->iItem,&pt);
- /* Start the drag operation. */
- ImageList_BeginDrag(himl_drag, 0, 0, 0);
+ /* Start the drag operation. */
+ ImageList_BeginDrag(himl_drag, 0, 0, 0);
pt = pnmv->ptAction;
ClientToScreen(hwndList,&pt);
ImageList_DragEnter(GetDesktopWindow(),pt.x,pt.y);
- /* Hide the mouse cursor, and direct mouse input to the
- parent window. */
- SetCapture(hMain);
+ /* Hide the mouse cursor, and direct mouse input to the parent window. */
+ SetCapture(hMain);
prev_drag_drop_target = NULL;
- g_listview_dragging = TRUE;
-
+ g_listview_dragging = true;
}
static void MouseMoveListViewDrag(POINTS p)
@@ -6308,15 +6243,16 @@ static void MouseMoveListViewDrag(POINTS p)
if (htiTarget != prev_drag_drop_target)
{
- ImageList_DragShowNolock(FALSE);
+ ImageList_DragShowNolock(false);
if (htiTarget)
res = TreeView_SelectDropTarget(hTreeView,htiTarget);
else
res = TreeView_SelectDropTarget(hTreeView,NULL);
- ImageList_DragShowNolock(TRUE);
+ ImageList_DragShowNolock(true);
prev_drag_drop_target = htiTarget;
}
+ res++;
}
static void ButtonUpListViewDrag(POINTS p)
@@ -6325,7 +6261,6 @@ static void ButtonUpListViewDrag(POINTS p)
HTREEITEM htiTarget;
TV_HITTESTINFO tvht;
TVITEM tvi;
- BOOL res;
ReleaseCapture();
@@ -6333,9 +6268,10 @@ static void ButtonUpListViewDrag(POINTS p)
ImageList_EndDrag();
ImageList_Destroy(himl_drag);
- res = TreeView_SelectDropTarget(hTreeView,NULL);
+ BOOL res = TreeView_SelectDropTarget(hTreeView,NULL);
+ res++;
- g_listview_dragging = FALSE;
+ g_listview_dragging = false;
/* see where the game was dragged */
@@ -6373,7 +6309,6 @@ static void ButtonUpListViewDrag(POINTS p)
return;
}
-
tvi.lParam = 0;
tvi.mask = TVIF_PARAM | TVIF_HANDLE;
tvi.hItem = htiTarget;
@@ -6383,21 +6318,18 @@ static void ButtonUpListViewDrag(POINTS p)
LPTREEFOLDER folder = (LPTREEFOLDER)tvi.lParam;
AddToCustomFolder(folder,game_dragged);
}
-
}
static LPTREEFOLDER GetSelectedFolder(void)
{
- HTREEITEM htree;
- TVITEM tvi;
- BOOL res;
-
- htree = TreeView_GetSelection(hTreeView);
+ HTREEITEM htree = TreeView_GetSelection(hTreeView);
if(htree)
{
+ TVITEM tvi;
tvi.hItem = htree;
tvi.mask = TVIF_PARAM;
- res = TreeView_GetItem(hTreeView,&tvi);
+ BOOL res = TreeView_GetItem(hTreeView,&tvi);
+ res++;
return (LPTREEFOLDER)tvi.lParam;
}
return NULL;
@@ -6405,22 +6337,17 @@ static LPTREEFOLDER GetSelectedFolder(void)
static HICON GetSelectedFolderIcon(void)
{
- HTREEITEM htree;
- TVITEM tvi;
- HIMAGELIST hSmall_icon;
- LPTREEFOLDER folder;
- BOOL res;
-
- htree = TreeView_GetSelection(hTreeView);
+ HTREEITEM htree = TreeView_GetSelection(hTreeView);
if (htree)
{
+ TVITEM tvi;
tvi.hItem = htree;
tvi.mask = TVIF_PARAM;
- res = TreeView_GetItem(hTreeView,&tvi);
-
- folder = (LPTREEFOLDER)tvi.lParam;
+ BOOL res = TreeView_GetItem(hTreeView,&tvi);
+ res++;
+ //LPTREEFOLDER folder = (LPTREEFOLDER)tvi.lParam;
//hSmall_icon = TreeView_GetImageList(hTreeView,(int)tvi.iImage);
- hSmall_icon = NULL;
+ HIMAGELIST hSmall_icon = NULL;
return ImageList_GetIcon(hSmall_icon, tvi.iImage, ILD_TRANSPARENT);
}
return NULL;
@@ -6432,8 +6359,9 @@ void UpdateListView(void)
BOOL res;
if( (GetViewMode() == VIEW_GROUPED) || (GetViewMode() == VIEW_DETAILS ) )
- res = ListView_RedrawItems(hwndList,ListView_GetTopIndex(hwndList),
- ListView_GetTopIndex(hwndList)+ ListView_GetCountPerPage(hwndList) );
+ res = ListView_RedrawItems(hwndList,ListView_GetTopIndex(hwndList), ListView_GetTopIndex(hwndList)+ ListView_GetCountPerPage(hwndList) );
+
+ res++;
}
static void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_height)
@@ -6446,7 +6374,7 @@ static void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_he
int x, y;
int rWidth, rHeight;
double scale;
- BOOL bReduce = FALSE;
+ BOOL bReduce = false;
GetClientRect(hWnd, &rect);
@@ -6468,7 +6396,7 @@ static void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_he
rHeight = (rect.bottom - rect.top);
/* Limit the screen shot to max height of 264 */
- if (restrict_height == TRUE && rHeight > 264)
+ if (restrict_height == true && rHeight > 264)
{
rect.bottom = rect.top + 264;
rHeight = 264;
@@ -6481,7 +6409,7 @@ static void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_he
rect.bottom -= 10;
rWidth -= 10;
rHeight -= 10;
- bReduce = TRUE;
+ bReduce = true;
/* Try to scale it properly */
/* assumes square pixels, doesn't consider aspect ratio */
if (x > y)
@@ -6512,7 +6440,7 @@ static void CalculateBestScreenShotRect(HWND hWnd, RECT *pRect, BOOL restrict_he
rect.bottom -= 10;
rWidth -= 10;
rHeight -= 10;
- bReduce = TRUE;
+ bReduce = true;
// Try to scale it properly
// assumes square pixels, doesn't consider aspect ratio
if (x < y)
@@ -6614,7 +6542,7 @@ static void SwitchFullScreenMode(void)
else
ShowWindow(hMain, SW_RESTORE);
- SetRunFullScreen(FALSE);
+ SetRunFullScreen(false);
}
else
{
@@ -6639,7 +6567,7 @@ static void SwitchFullScreenMode(void)
ShowWindow(hMain, SW_MAXIMIZE);
- SetRunFullScreen(TRUE);
+ SetRunFullScreen(true);
}
}
diff --git a/src/osd/winui/winui.h b/src/osd/winui/winui.h
index 5579d9c3943..99eec7e5c54 100644
--- a/src/osd/winui/winui.h
+++ b/src/osd/winui/winui.h
@@ -21,8 +21,6 @@
#endif
#define SEARCH_PROMPT ""
-#define SHOW_COLUMN_ROMS
-#define SHOW_COLUMN_SAMPLES
enum
{