Ejemplo n.º 1
0
static void Directories_OnBrowse(HWND hDlg)
{
	int 	nType;
	int 	nItem;
	TCHAR	inbuf[MAX_PATH];
	TCHAR	outbuf[MAX_PATH];
	HWND	hList;

	hList = GetDlgItem(hDlg, IDC_DIR_LIST);
	nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);

	if (nItem == -1)
		return;

	nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
	if (IsMultiDir(nType))
	{
		/* Last item is placeholder for append */
		if (nItem == ListView_GetItemCount(hList) - 1)
		{
			Directories_OnInsert(hDlg); 
			return;
		}
	}

	ListView_GetItemText(hList, nItem, 0, inbuf, MAX_PATH);

	if (BrowseForDirectory(hDlg, inbuf, outbuf) == TRUE)
	{
		nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
		DirInfo_SetDir(g_pDirInfo, nType, nItem, outbuf);
		UpdateDirectoryList(hDlg);
	}
}
Ejemplo n.º 2
0
int SetListDirectory(DIRECTORY_INFO *lpDirectoryInfo, char *directorypath)
{
	if (directorypath==NULL)
			GetCurrentDirectory(MAX_PATH, &(lpDirectoryInfo->directoryName[0]));	//start in the current directory
	else
		strcpy(&(lpDirectoryInfo->directoryName[0]), directorypath);

	strcpy(lpDirectoryInfo->directoryFilter, "????Z*");
	UpdateDirectoryList(lpDirectoryInfo);

	lpDirectoryInfo->parentListWindowInfo->firstLine=0;
	return 0;
}
Ejemplo n.º 3
0
static void Directories_OnDelete(HWND hDlg)
{
    int     nType;
    int     nCount;
    int     nSelect;
    int     i;
    int     nItem;
    HWND    hList = GetDlgItem(hDlg, IDC_DIR_LIST);

    nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);

    if (nItem == -1)
        return;

    /* Don't delete "Append" placeholder. */
    if (nItem == ListView_GetItemCount(hList) - 1)
        return;

    nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
    switch (nType)
    {
    case ROM:
    case SAMPLE:

        for (i = nItem; i < DirInfo_NumDir(pDirInfo, nType) - 1; i++)
            strcpy(DirInfo_Path(pDirInfo, nType, i),
                   DirInfo_Path(pDirInfo, nType, i + 1));

        strcpy(DirInfo_Path(pDirInfo, nType, DirInfo_NumDir(pDirInfo, nType) - 1), "");
        DirInfo_NumDir(pDirInfo, nType)--;

        pDirInfo->m_Paths[nType].m_bModified = TRUE;

        break;
    }

    UpdateDirectoryList(hDlg);
    

    nCount = ListView_GetItemCount(hList);
    if (nCount <= 1)
        return;

    /* If the last item was removed, select the item above. */
    if (nItem == nCount - 1)
        nSelect = nCount - 2;
    else
        nSelect = nItem;

    ListView_SetItemState(hList, nSelect, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
}
Ejemplo n.º 4
0
static void Directories_OnSelChange(HWND hDlg)
{
	UpdateDirectoryList(hDlg);
	
	if (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO)) == 0
	||	ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO)) == 1)
	{
		EnableWindow(GetDlgItem(hDlg, IDC_DIR_DELETE), TRUE);
		EnableWindow(GetDlgItem(hDlg, IDC_DIR_INSERT), TRUE);
	}
	else
	{
		EnableWindow(GetDlgItem(hDlg, IDC_DIR_DELETE), FALSE);
		EnableWindow(GetDlgItem(hDlg, IDC_DIR_INSERT), FALSE);
	}
}
Ejemplo n.º 5
0
static void Directories_OnDelete(HWND hDlg)
{
	int 	nType;
	int 	nCount;
	int 	nSelect;
	int 	i;
	int 	nItem;
	HWND	hList = GetDlgItem(hDlg, IDC_DIR_LIST);

	nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);

	if (nItem == -1)
		return;

	/* Don't delete "Append" placeholder. */
	if (nItem == ListView_GetItemCount(hList) - 1)
		return;

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

		_tcscpy(DirInfo_Path(g_pDirInfo, nType, DirInfo_NumDir(g_pDirInfo, nType) - 1), TEXT(""));
		DirInfo_NumDir(g_pDirInfo, nType)--;

		DirInfo_SetModified(g_pDirInfo, nType, TRUE);
	}

	UpdateDirectoryList(hDlg);
	

	nCount = ListView_GetItemCount(hList);
	if (nCount <= 1)
		return;

	/* If the last item was removed, select the item above. */
	if (nItem == nCount - 1)
		nSelect = nCount - 2;
	else
		nSelect = nItem;

	ListView_SetItemState(hList, nSelect, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
}
Ejemplo n.º 6
0
static void Directories_OnSelChange(HWND hDlg)
{
    UpdateDirectoryList(hDlg);

    HWND hCombo = GetDlgItem(hDlg, IDC_DIR_COMBO);
    int nType = ComboBox_GetCurSel(hCombo);
    if (IsMultiDir(nType))
    {
        EnableWindow(GetDlgItem(hDlg, IDC_DIR_DELETE), TRUE);
        EnableWindow(GetDlgItem(hDlg, IDC_DIR_INSERT), TRUE);
    }
    else
    {
        EnableWindow(GetDlgItem(hDlg, IDC_DIR_DELETE), FALSE);
        EnableWindow(GetDlgItem(hDlg, IDC_DIR_INSERT), FALSE);
    }
}
Ejemplo n.º 7
0
static void Directories_OnInsert(HWND hDlg)
{
    int     nItem;
    char    buf[MAX_PATH];
    HWND    hList;

    hList = GetDlgItem(hDlg, IDC_DIR_LIST);
    nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);

    if (BrowseForDirectory(hDlg, NULL, buf) == TRUE)
    {
        int     i;
        int     nType;

        /* list was empty */
        if (nItem == -1)
            nItem = 0;

        nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
        switch (nType)
        {
        case ROM:
        case SAMPLE:

            if (MAX_DIRS <= DirInfo_NumDir(pDirInfo, nType))
                return;

            for (i = DirInfo_NumDir(pDirInfo, nType); nItem < i; i--)
                strcpy(DirInfo_Path(pDirInfo, nType, i),
                       DirInfo_Path(pDirInfo, nType, i - 1));

            strcpy(DirInfo_Path(pDirInfo, nType, nItem), buf);
            DirInfo_NumDir(pDirInfo, nType)++;

            pDirInfo->m_Paths[nType].m_bModified = TRUE;

            break;
        }

        UpdateDirectoryList(hDlg);

        ListView_SetItemState(hList, nItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
    }
}
Ejemplo n.º 8
0
static void Directories_OnInsert(HWND hDlg)
{
	int 	nItem;
	TCHAR	buf[MAX_PATH];
	HWND	hList;

	hList = GetDlgItem(hDlg, IDC_DIR_LIST);
	nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);

	if (BrowseForDirectory(hDlg, NULL, buf) == TRUE)
	{
		int 	i;
		int 	nType;

		/* list was empty */
		if (nItem == -1)
			nItem = 0;

		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--)
				_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);
		}

		UpdateDirectoryList(hDlg);

		ListView_SetItemState(hList, nItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
	}
}
Ejemplo n.º 9
0
static BOOL Directories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
	BOOL		  bResult = FALSE;
	NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
	LVITEM* 	  pItem = &pDispInfo->item;

	if (pItem->pszText != NULL)
	{
		struct _stat file_stat;

		/* Don't allow empty entries. */
		if (!_tcscmp(pItem->pszText, TEXT("")))
		{
			return FALSE;
		}

		/* Check validity of edited directory. */
		if (_tstat(pItem->pszText, &file_stat) == 0
		&&	(file_stat.st_mode & S_IFDIR))
		{
			bResult = TRUE;
		}
		else
		{
			if (MessageBox(NULL, TEXT("Directory does not exist, continue anyway?"), TEXT(MAMEUINAME), MB_OKCANCEL) == IDOK)
				bResult = TRUE;
		}
	}

	if (bResult == TRUE)
	{
		int nType;
		int i;

		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;

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

				_tcscpy(DirInfo_Path(g_pDirInfo, nType, pItem->iItem), pItem->pszText);

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

	}

	return bResult;
}
Ejemplo n.º 10
0
static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
{
	RECT		rectClient;
	LVCOLUMN	LVCol;
	int 		i;
	int			nDirInfoCount;
	LPCSTR		s;
	TCHAR       *token;
	TCHAR       buf[MAX_PATH * MAX_DIRS];
	TCHAR*      t_s = NULL;
	HRESULT 	res;

	/* count how many dirinfos there are */
	nDirInfoCount = 0;
	while(g_directoryInfo[nDirInfoCount].lpName)
		nDirInfoCount++;

	g_pDirInfo = (tDirInfo *) malloc(sizeof(tDirInfo) * nDirInfoCount);
	if (!g_pDirInfo) /* bummer */
		goto error;
	memset(g_pDirInfo, 0, sizeof(tDirInfo) * nDirInfoCount);

	for (i = nDirInfoCount - 1; i >= 0; i--)
	{
		t_s = tstring_from_utf8(g_directoryInfo[i].lpName);
		if( !t_s )
			return FALSE;
		(void)ComboBox_InsertString(GetDlgItem(hDlg, IDC_DIR_COMBO), 0, win_tstring_strdup(t_s));
		osd_free(t_s);
		t_s = NULL;
	}

	(void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO), 0);

	GetClientRect(GetDlgItem(hDlg, IDC_DIR_LIST), &rectClient);

	memset(&LVCol, 0, sizeof(LVCOLUMN));
	LVCol.mask	  = LVCF_WIDTH;
	LVCol.cx	  = rectClient.right - rectClient.left - GetSystemMetrics(SM_CXHSCROLL);
	
	res = ListView_InsertColumn(GetDlgItem(hDlg, IDC_DIR_LIST), 0, &LVCol);

	/* Keep a temporary copy of the directory strings in g_pDirInfo. */
	for (i = 0; i < nDirInfoCount; i++)
	{
		s = g_directoryInfo[i].pfnGetTheseDirs();
		t_s = tstring_from_utf8(s);
		if( !t_s )
			return FALSE;
		if (g_directoryInfo[i].bMulti)
		{
			/* Copy the string to our own buffer so that we can mutilate it */
			_tcscpy(buf, t_s);

			g_pDirInfo[i].m_Path = (tPath*)malloc(sizeof(tPath));
			if (!g_pDirInfo[i].m_Path)
				goto error;

			g_pDirInfo[i].m_Path->m_NumDirectories = 0;
			token = _tcstok(buf, TEXT(";"));
			while ((DirInfo_NumDir(g_pDirInfo, i) < MAX_DIRS) && token)
			{
				_tcscpy(DirInfo_Path(g_pDirInfo, i, DirInfo_NumDir(g_pDirInfo, i)), token);
				DirInfo_NumDir(g_pDirInfo, i)++;
				token = _tcstok(NULL, TEXT(";"));
			}
			DirInfo_SetModified(g_pDirInfo, i, FALSE);
		}
		else
		{
			DirInfo_SetDir(g_pDirInfo, i, -1, t_s);
		}
		osd_free(t_s);
		t_s = NULL;
	}

	UpdateDirectoryList(hDlg);
	return TRUE;

error:
	if( t_s )
		osd_free(t_s);
	Directories_OnDestroy(hDlg);
	EndDialog(hDlg, -1);
	return FALSE;
}
Ejemplo n.º 11
0
static BOOL Directories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
    BOOL          bResult = FALSE;
    NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
    LVITEM*       pItem = &pDispInfo->item;

    if (pItem->pszText != NULL)
    {
        struct stat file_stat;

        /* Don't allow empty entries. */
        if (!strcmp(pItem->pszText, ""))
        {
            return FALSE;
        }

        /* Check validity of edited directory. */
        if (stat(pItem->pszText, &file_stat) == 0
        &&  (file_stat.st_mode & S_IFDIR))
        {
            bResult = TRUE;
        }
        else
        {
            if (MessageBox(NULL, "Directory does not exist, continue anyway?", "MAME32", MB_OKCANCEL) == IDOK)
                bResult = TRUE;
        }
    }

    if (bResult == TRUE)
    {
        int nType;
        int i;

        nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
        switch (nType)
        {
        case ROM:
        case SAMPLE:

            /* Last item is placeholder for append */
            if (pItem->iItem == ListView_GetItemCount(GetDlgItem(hDlg, IDC_DIR_LIST)) - 1)
            {
                if (MAX_DIRS <= DirInfo_NumDir(pDirInfo, nType))
                    return FALSE;

                for (i = DirInfo_NumDir(pDirInfo, nType); pItem->iItem < i; i--)
                    strcpy(DirInfo_Path(pDirInfo, nType, i),
                           DirInfo_Path(pDirInfo, nType, i - 1));

                strcpy(DirInfo_Path(pDirInfo, nType, pItem->iItem), pItem->pszText);
                pDirInfo->m_Paths[nType].m_bModified = TRUE;

                DirInfo_NumDir(pDirInfo, nType)++;
            }
            else
                DirInfo_SetDir(pDirInfo, nType, pItem->iItem, pItem->pszText);


            break;

        case CFG:
        case HI:
        case IMG:
        case INP:
        case STATE:
        case ART:
		case MEMCARD:
		case FLYER:
		case CABINET:
		case NVRAM:
            DirInfo_SetDir(pDirInfo, nType, pItem->iItem, pItem->pszText);
            break;
        }

        UpdateDirectoryList(hDlg);
        ListView_SetItemState(GetDlgItem(hDlg, IDC_DIR_LIST), pItem->iItem,
                              LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);

    }

    return bResult;
}
Ejemplo n.º 12
0
static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
{
    RECT        rectClient;
    LVCOLUMN    LVCol;
    char*       token;
    char        buf[MAX_PATH * MAX_DIRS];
	int			i;

    pDirInfo = (struct tDirInfo*) malloc(sizeof(struct tDirInfo));
    if (pDirInfo == NULL) /* bummer */
    {
        EndDialog(hDlg, -1);
        return FALSE;
    }

	for (i = LASTDIR - 1; i >= 0; i--)
	{
		ComboBox_InsertString(GetDlgItem(hDlg, IDC_DIR_COMBO), 0, dir_names[i]);
	}

    ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO), 0);

    GetClientRect(GetDlgItem(hDlg, IDC_DIR_LIST), &rectClient);

    memset(&LVCol, 0, sizeof(LVCOLUMN));
    LVCol.mask    = LVCF_WIDTH;
    LVCol.cx      = rectClient.right - rectClient.left - GetSystemMetrics(SM_CXHSCROLL);
    
    ListView_InsertColumn(GetDlgItem(hDlg, IDC_DIR_LIST), 0, &LVCol);


    /* Keep a temporary copy of the directory strings in pDirInfo. */
    memset(pDirInfo, 0, sizeof(struct tDirInfo));

    strcpy(buf, GetRomDirs());

    pDirInfo->m_Paths[ROM].m_NumDirectories = 0;
    token = strtok(buf, ";");
    while ((DirInfo_NumDir(pDirInfo, ROM) < MAX_DIRS) && token)
    {
        strcpy(DirInfo_Path(pDirInfo, ROM, DirInfo_NumDir(pDirInfo, ROM)), token);
        DirInfo_NumDir(pDirInfo, ROM)++;
        token = strtok(NULL, ";");
    }
    pDirInfo->m_Paths[ROM].m_bModified = FALSE;

    strcpy(buf, GetSampleDirs());

    pDirInfo->m_Paths[SAMPLE].m_NumDirectories = 0;
    token = strtok(buf, ";");
    while ((DirInfo_NumDir(pDirInfo, SAMPLE) < MAX_DIRS) && token)
    {
        strcpy(DirInfo_Path(pDirInfo, SAMPLE, DirInfo_NumDir(pDirInfo, SAMPLE)), token);
        DirInfo_NumDir(pDirInfo, SAMPLE)++;
        token = strtok(NULL, ";");
    }
    pDirInfo->m_Paths[SAMPLE].m_bModified = FALSE;

    strcpy(DirInfo_Dir(pDirInfo, CFG),		GetCfgDir());
    strcpy(DirInfo_Dir(pDirInfo, HI),		GetHiDir());
    strcpy(DirInfo_Dir(pDirInfo, IMG),		GetImgDir());
    strcpy(DirInfo_Dir(pDirInfo, INP),		GetInpDir());
    strcpy(DirInfo_Dir(pDirInfo, STATE),	GetStateDir());
    strcpy(DirInfo_Dir(pDirInfo, ART),		GetArtDir());
	strcpy(DirInfo_Dir(pDirInfo, MEMCARD),	GetMemcardDir());
	strcpy(DirInfo_Dir(pDirInfo, FLYER),	GetFlyerDir());
	strcpy(DirInfo_Dir(pDirInfo, CABINET),	GetCabinetDir());
	strcpy(DirInfo_Dir(pDirInfo, NVRAM),	GetNvramDir());

    UpdateDirectoryList(hDlg);

    return TRUE;
}