aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_dshow/config.cpp
blob: 451d9307bd8b89903a2fb1c4ae3b8bc37cef1894 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <windows.h>
#include "resource.h"
#include "../Agave/Language/api_language.h"
#include "main.h"
#include <strsafe.h>

extern const char *INI_FILE;

static char app_name[] = "in_dshow";

static char default_extlist[]="MPG;MPEG;M2V;AVI";

char config_extlist[129] = {0};

static int _r_i(char *name, int def)
{
	if (!_strnicmp(name,"config_",7)) name += 7;
	return GetPrivateProfileIntA(app_name,name,def,INI_FILE);
}
#define RI(x) (( x ) = _r_i(#x,( x )))
static void _w_i(char *name, int d)
{
	char str[120] = {0};
	StringCchPrintfA(str, 120, "%d",d);
	if (!_strnicmp(name,"config_",7)) name += 7;
	WritePrivateProfileStringA(app_name,name,str,INI_FILE);
}
#define WI(x) _w_i(#x,( x ))

static void _r_s(char *name,char *data, int mlen)
{
	char buf[2048] = {0};
	lstrcpynA(buf,data, 2048);
	if (!_strnicmp(name,"config_",7)) name += 7;
	GetPrivateProfileStringA(app_name,name,buf,data,mlen,INI_FILE);
}
#define RS(x) (_r_s(#x,x,sizeof(x)))

static void _w_s(char *name, char *data)
{
	if (!_strnicmp(name,"config_",7)) name += 7;
	WritePrivateProfileStringA(app_name,name,data,INI_FILE);
}
#define WS(x) (_w_s(#x,x))

#define ISSEP(x) ((x) == ' ' || (x) == ';' || (x) == ',' || (x) == ':' || (x) == '.')
char *getfileextensions()
{
	static char list[512];
	char *op=list;
	//  char *g_fileassos="MP3;MP2;MP1\0MPEG Audio Files (*.MP3;*.MP2;*.MP1)\0";

	char *p=config_extlist;
	int s=0;
	while (p && *p)
	{
		while (ISSEP(*p)) p++;
		if (!*p) break;
		if (s) *op++=';';
		s=1;
		while (p && *p && !ISSEP(*p)) *op++=*p++;
	}
	*op++=0;
	lstrcpynA(op,WASABI_API_LNGSTRING(IDS_VIDEO_FILES_OFD),512);
	while (op && *op) op++;
	p=config_extlist;
	s=0;
	while (p && *p)
	{
		while (ISSEP(*p)) p++;
		if (!p || !*p) break;
		if (s) *op++=';';
		s=1;
		*op++='*';
		*op++='.';
		while (p && *p && !ISSEP(*p)) *op++=*p++;     
	}
	*op++=')';
	*op++=0;
	*op++=0;
	return list;
}

void config_read()
{
  lstrcpynA(config_extlist,default_extlist, 129);
  RS(config_extlist);
}

void config_write()
{
  WS(config_extlist);
}

INT_PTR CALLBACK configProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg)
  {
  case WM_INITDIALOG:
    SetDlgItemTextA(hwndDlg,IDC_TYPES,config_extlist);
    SendDlgItemMessage(hwndDlg,IDC_TYPES,EM_LIMITTEXT,128,0);
    return TRUE;
  case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case IDC_DEFAULTTYPES:
      SetDlgItemTextA(hwndDlg,IDC_TYPES,default_extlist);
      break;
    case IDOK:
      GetDlgItemTextA(hwndDlg,IDC_TYPES,config_extlist,128);
      config_write();
    case IDCANCEL:
      EndDialog(hwndDlg,0);
      break;
    }
    break;
  }
  return FALSE;
}

void doConfig(HINSTANCE hInstance, HWND hwndParent)
{
	WASABI_API_DIALOGBOXW(IDD_CONFIG,hwndParent,configProc);
}