Example #1
0
optreserr_t win_add_resolution_parameter(HWND control, option_resolution *resolution)
{
	const option_guide *guide;
	char buf[256];
	optreserr_t err;
	const char *text;
	const char *old_text;
	int i;

	if (!win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf)))
	{
		err = OPTIONRESOLTUION_ERROR_INTERNAL;
		return err;
	}
	text = buf;

	guide = (const option_guide *) GetProp(control, guide_prop);
	if (!guide)
	{
		err = OPTIONRESOLTUION_ERROR_INTERNAL;
		return err;
	}

	if (guide->option_type == OPTIONTYPE_ENUM_BEGIN)
	{
		/* need to convert display name to identifier */
		old_text = text;
		text = NULL;

		for (i = 1; guide[i].option_type == OPTIONTYPE_ENUM_VALUE; i++)
		{
			if (!strcmp(guide[i].display_name, old_text))
			{
				text = guide[i].identifier;
				break;
			}
		}
	}

	if (text)
	{
		err = option_resolution_add_param(resolution, guide->identifier, text);
		if (err)
			return err;
	}

	err = OPTIONRESOLUTION_ERROR_SUCCESS;

	return err;
}
Example #2
0
void consolewin_info::set_cpu(device_t &device)
{
	// first set all the views to the new cpu number
	m_views[0]->set_source_for_device(device);
	m_views[1]->set_source_for_device(device);

	// then update the caption
	std::string title = string_format("Debug: %s - %s '%s'", device.machine().system().name, device.name(), device.tag());
	std::string curtitle = win_get_window_text_utf8(window());
	if (title != curtitle)
		win_set_window_text_utf8(window(), title.c_str());

	// and recompute the children
	recompute_children();
}
Example #3
0
BOOL win_adjust_option_control(HWND control, int delta)
{
	const option_guide *guide;
	const char *optspec;
	struct OptionRange ranges[128];
	char buf[64];
	int val, original_val, i;
	BOOL changed = FALSE;

	guide = (const option_guide *) GetProp(control, guide_prop);
	optspec = (const char *) GetProp(control, spec_prop);

	assert(guide->option_type == OPTIONTYPE_INT);

	if (delta == 0)
		return TRUE;

	option_resolution_listranges(optspec, guide->parameter,
		ranges, ARRAY_LENGTH(ranges));

	win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf));
	original_val = atoi(buf);
	val = original_val + delta;

	for (i = 0; ranges[i].min >= 0; i++)
	{
		if (ranges[i].min > val)
		{
			if ((delta < 0) && (i > 0))
				val = ranges[i-1].max;
			else
				val = ranges[i].min;
			changed = TRUE;
			break;
		}
	}
	if (!changed && (i > 0) && (ranges[i-1].max < val))
		val = ranges[i-1].max;

	if (val != original_val)
	{
		_snprintf(buf, ARRAY_LENGTH(buf), "%d", val);
		win_set_window_text_utf8(control, buf);
	}
	return TRUE;
}
Example #4
0
void consolewin_info::set_cpu(device_t &device)
{
	// first set all the views to the new cpu number
	m_views[0]->set_source_for_device(device);
	m_views[1]->set_source_for_device(device);

	// then update the caption
	char curtitle[256];
	astring title;

	title.printf("Debug: %s - %s '%s'", device.machine().system().name, device.name(), device.tag());
	win_get_window_text_utf8(window(), curtitle, ARRAY_LENGTH(curtitle));
	if (title.cmp(curtitle) != 0)
		win_set_window_text_utf8(window(), title.c_str());

	// and recompute the children
	recompute_children();
}
Example #5
0
static BOOL check_editbox(HWND control)
{
	char buf[256];
	const option_guide *guide;
	const char *optspec;
	optreserr_t err;
	HANDLE h;
	void *val;
	int i_val;


	guide = (const option_guide *) GetProp(control, guide_prop);
	optspec = (const char *) GetProp(control, spec_prop);

	win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf));

	switch(guide->option_type)
	{
		case OPTIONTYPE_INT:
			i_val = atoi(buf);
			err = option_resolution_isvalidvalue(optspec, guide->parameter, i_val);
			if (err)
			{
				h = GetProp(control, value_prop);
				val = (void*) h;
				_snprintf(buf, ARRAY_LENGTH(buf), "%d", val);
				win_set_window_text_utf8(control, buf);
			}
			else
			{
				SetProp(control, value_prop, (HANDLE) i_val);
			}
			break;

		default:
			err = OPTIONRESOLTUION_ERROR_INTERNAL;
			goto done;
	}

done:
	assert(err != OPTIONRESOLTUION_ERROR_INTERNAL);
	return (err != OPTIONRESOLUTION_ERROR_SUCCESS);
}
Example #6
0
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	static DWORD			dwFilters;
	static DWORD			dwpFilters;
	static LPCFOLDERDATA	lpFilterRecord;
	char					strText[250];
	int 					i;

	switch (Msg)
	{
	case WM_INITDIALOG:
	{
		LPTREEFOLDER folder = GetCurrentFolder();
		LPTREEFOLDER lpParent = NULL;
		LPCFILTER_ITEM g_lpFilterList = GetFilterList();

		dwFilters = 0;

		if (folder != NULL)
		{
			char tmp[80];

			win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText);
			Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
			// Mask out non filter flags
			dwFilters = folder->m_dwFlags & F_MASK;
			// Display current folder name in dialog titlebar
			snprintf(tmp,ARRAY_LENGTH(tmp),"Filters for %s Folder",folder->m_lpTitle);
			win_set_window_text_utf8(hDlg, tmp);
			if ( GetFilterInherit() )
			{
				BOOL bShowExplanation = FALSE;
				lpParent = GetFolder( folder->m_nParent );
				if( lpParent )
				{
					/* Check the Parent Filters and inherit them on child,
                     * No need to promote all games to parent folder, works as is */
					dwpFilters = lpParent->m_dwFlags & F_MASK;
					/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/
					if( (dwpFilters & F_CLONES) && !(dwFilters & F_CLONES) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_RASTER) && !(dwFilters & F_RASTER) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_WORKING) && !(dwFilters & F_WORKING) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText);
						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 );
				}
			}
			else
			{
				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;
	}
	case WM_HELP:
		// User clicked the ? from the upper right on a control
		HelpFunction((HWND)((LPHELPINFO)lParam)->hItemHandle, MAMEUICONTEXTHELP,
					 HH_TP_HELP_WM_HELP, GetHelpIDs());
		break;

	case WM_CONTEXTMENU:
		HelpFunction((HWND)wParam, MAMEUICONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs());
		break;

	case WM_COMMAND:
	{
		WORD wID		 = GET_WM_COMMAND_ID(wParam, lParam);
		WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
		LPTREEFOLDER folder = GetCurrentFolder();
		LPCFILTER_ITEM g_lpFilterList = GetFilterList();

		switch (wID)
		{
		case IDOK:
			dwFilters = 0;

			win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText, FILTERTEXT_LEN);

			// 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);

			// Keep non filter flags
			folder->m_dwFlags &= ~F_MASK;

			// put in the set filters
			folder->m_dwFlags |= dwFilters;

			EndDialog(hDlg, 1);
			return TRUE;

		case IDCANCEL:
			EndDialog(hDlg, 0);
			return TRUE;

		default:
			// Handle unchecking mutually exclusive filters
			if (wNotifyCode == BN_CLICKED)
				EnableFilterExclusions(hDlg, wID);
		}
	}
	break;
	}
	return 0;
}
Example #7
0
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
		case WM_INITDIALOG:
		{
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));
			DisableVisualStylesFilters(hDlg);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPTREEFOLDER lpParent = NULL;
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();
			dwFilters = 0;

			if (folder != NULL)
			{
				char tmp[80];
				win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText.c_str());
				Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
				// Mask out non filter flags
				dwFilters = folder->m_dwFlags & F_MASK;
				// Display current folder name in dialog titlebar
				snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle);
				win_set_window_text_utf8(hDlg, tmp);

				if (GetFilterInherit())
				{
					lpParent = GetFolder(folder->m_nParent);
					bool bShowExplanation = false;

					if (lpParent)
					{
						std::string strText;
						/* Check the Parent Filters and inherit them on child,
						* No need to promote all games to parent folder, works as is */
						dwpFilters = lpParent->m_dwFlags & F_MASK;
						/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/

						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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText.c_str());
							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(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText.c_str());
							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), true);
					}
				}
				else
				{
					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 (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
				{
					DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters);
				}
			}

			SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT));
			return false;
		}

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_COMMAND:
		{
			WORD wID = GET_WM_COMMAND_ID(wParam, lParam);
			WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();

			switch (wID)
			{
				case IDOK:
					dwFilters = 0;
					g_FilterText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT));

					// see which buttons are checked
					for (int 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);
					// Keep non filter flags
					folder->m_dwFlags &= ~F_MASK;
					// put in the set filters
					folder->m_dwFlags |= dwFilters;
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 1);
					return true;

				case IDCANCEL:
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;

				default:
					// Handle unchecking mutually exclusive filters
					if (wNotifyCode == BN_CLICKED)
						EnableFilterExclusions(hDlg, wID);
			}

			break;
		}
	}

	return false;
}