Johny777
20-09-2012, 01:19
спорить не буду, взял пример от сюда: »
+fps_max60-console »
пардон
мой косяк
пробелы быть должны
между параметрами ком строки и значениями. Везде!
в противном случае они будут являться тарабарщиной которую двиг игры не сможет прочитать при этом жутко ругаясь
поэтому сделал вот такую вот функцию (вроде работает но как-то медленно) но почему-то в параметр - hideconsole записывается как -h ideconsole
вот код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[ code]
var
Param_Edit: TEdit;
function DelSp(const st: String): String; /// укоротить до одинарных пробелов
begin
while pos(' ',st)>0 do delete(st,pos(' ',st),1);
Result := st;
end;
function InsertSp(AllText:String):String; //// добавить пробелы
var
pos_simbol: Integer;
Param: String;
i: Integer;
begin
i := 1;
repeat
begin
case i of
1: Param := '-console';
2: Param := '-hideconsole';
3: Param := '-safe';
4: Param := '-dev';
5: Param := '-condebug';
6: Param := '-autoconfig';
7: Param := '-dxlevel';
8: Param := '-32bit';
9: Param := '-fullscreen';
10: Param := '-windowed';
11: Param := '-w';
12: Param := '-h';
13: Param := '-x';
14: Param := '-y';
15: Param := '-nocrashdialog';
16: Param := '-novid';
17: Param := '-noborder';
18: Param := '-nojoy';
19: Param := '-noforcemspd';
20: Param := '-noforcemparms';
21: Param := '-noforcemaccel';
22: Param := '-refresh';
23: Param := '-d3d';
24: Param := '-gl';
25: Param := '-wavonly';
26: Param := '+cl_showfps';
27: Param := '+map';
28: Param := '+map_background';
29: Param := '+sv_cheats';
30: Param := '+exec';
31: Param := '+fps_max';
32: Param := '+skill';
33: Param := '+playdemo';
34: Param := '+mat_dxlevel';
end;
if pos(Param,AllText) > 0 then
begin
pos_simbol := Pos(Param, AllText);
Insert(' ',AllText, pos_simbol);
Insert(' ',AllText, pos_simbol+Length(Param)+1);
end;
i := i + 1;
end;
until i = 35;
Result := Trim(DelSp(AllText));
end;
function DeleteAllSp(const st: String): String; /// убрать все пробелы
begin
while pos(' ',st)>0 do delete(st,pos(' ',st),1);
Result := st;
end;
procedure Buttons_OnClick(Sender:TObject);
begin
case TButton(Sender).Caption of
'Insert': Param_Edit.Text := InsertSp(Param_Edit.Text);
'Delete': Param_Edit.Text := DeleteAllSp(Param_Edit.Text);
end;
end;
procedure InitializeWizard();
begin
WizardForm.OuterNotebook.Hide;
WizardForm.Width := 900;
WizardForm.Position := poScreenCenter;
Param_Edit := TNewEdit.Create(nil);
with Param_Edit do
begin
Parent := WizardForm;
SetBounds(ScaleX(40), ScaleY(100), ScaleX(700), ScaleY(21));
Text := InsertSp('+fps_max80-dxlevel80-hideconsole-32bit-gl-novid+cl_showfps1-dev1+sv_cheats1+playdemoTheBestDemo-condebug+skill2');
end;
with TButton.Create(nil) do
begin
Parent := WizardForm;
SetBounds(Param_Edit.Left + Param_Edit.Width + ScaleX(5), Param_Edit.Top, ScaleX(65), Param_Edit.Height);
Caption := 'Insert';
Cursor := crHand;
OnClick := @Buttons_OnClick;
end;
with TButton.Create(nil) do
begin
Parent := WizardForm;
SetBounds(Param_Edit.Left + Param_Edit.Width + ScaleX(5) + ScaleX(70), Param_Edit.Top, ScaleX(65), Param_Edit.Height);
Caption := 'Delete';
Cursor := crHand;
OnClick := @Buttons_OnClick;
end;
end;
кажись проблема в том что есть параметр -h
и есть параметр -hideconsole который в начале тоже имеет -h
подскажите пожалуйста как это поправить и можно ли как-то ускорить работу функции InserSp?
также порывшись на форумах по дельфи улучшил функцию проверки строки на целое число
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[ code]
function IsInt(const Value: string): Boolean;
begin
Result := StrToIntDef(Value,0) <> 0;
end;
procedure InitializeWizard();
begin
if IsInt('10') then MsgBox('yes', mbInformation, MB_OK);
if not IsInt('hfhfrh') then MsgBox('no', mbInformation, MB_OK);
end;
и кому надо функция получения разрешения монитора (верт., гор.) и частоты обновления (мне нужна для +fps_max и для -refresh и других параметров)
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[ code]
function GetDC(HWND: DWord): DWord; external 'GetDC@user32.dll stdcall';
function GetDeviceCaps(DC: DWord; Index: Integer): Integer; external 'GetDeviceCaps@gdi32.dll stdcall';
function ReleaseDC(HWND: DWord;DC: DWord): Integer; external 'ReleaseDC@user32.dll stdcall';
function GetMonitorInfo(MetricType:Byte;Descriptor:THandle): Word;
var
dc: DWord;
begin
Result := 0;
case MetricType of
1: /// разрешение по ширине
begin
dc := GetDC(Descriptor);
Result := GetDeviceCaps(dc,8);
end;
2: /// разрешение по высоте
begin
dc := GetDC(Descriptor);
Result := GetDeviceCaps(dc,10);
end;
3: /// частота обновления экрана
begin
dc := GetDC(Descriptor);
Result := GetDeviceCaps(dc,116);
end;
end;
ReleaseDC(Descriptor,dc);
end;
procedure InitializeWizard();
begin
MsgBox(
'разрешение по горизонтали - ' + IntToStr(GetMonitorInfo(1,MainForm.Handle)) + #13#10 +
'разрешение по вертикали - ' + IntToStr(GetMonitorInfo(2,MainForm.Handle)) + #13#10 +
'частота обновления - ' + IntToStr(GetMonitorInfo(3,MainForm.Handle)),
mbConfirmation, MB_OK);
end;
Извиняюсь, поторопился... исправил предыдущее сообщение. »
держи еще вариант: »
Спасибо добрые люди! :)
предстоит много работы но теперь у меня есть всё для того чтоб завершить код
+fps_max60-console »
пардон
мой косяк
пробелы быть должны
между параметрами ком строки и значениями. Везде!
в противном случае они будут являться тарабарщиной которую двиг игры не сможет прочитать при этом жутко ругаясь
поэтому сделал вот такую вот функцию (вроде работает но как-то медленно) но почему-то в параметр - hideconsole записывается как -h ideconsole
вот код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[ code]
var
Param_Edit: TEdit;
function DelSp(const st: String): String; /// укоротить до одинарных пробелов
begin
while pos(' ',st)>0 do delete(st,pos(' ',st),1);
Result := st;
end;
function InsertSp(AllText:String):String; //// добавить пробелы
var
pos_simbol: Integer;
Param: String;
i: Integer;
begin
i := 1;
repeat
begin
case i of
1: Param := '-console';
2: Param := '-hideconsole';
3: Param := '-safe';
4: Param := '-dev';
5: Param := '-condebug';
6: Param := '-autoconfig';
7: Param := '-dxlevel';
8: Param := '-32bit';
9: Param := '-fullscreen';
10: Param := '-windowed';
11: Param := '-w';
12: Param := '-h';
13: Param := '-x';
14: Param := '-y';
15: Param := '-nocrashdialog';
16: Param := '-novid';
17: Param := '-noborder';
18: Param := '-nojoy';
19: Param := '-noforcemspd';
20: Param := '-noforcemparms';
21: Param := '-noforcemaccel';
22: Param := '-refresh';
23: Param := '-d3d';
24: Param := '-gl';
25: Param := '-wavonly';
26: Param := '+cl_showfps';
27: Param := '+map';
28: Param := '+map_background';
29: Param := '+sv_cheats';
30: Param := '+exec';
31: Param := '+fps_max';
32: Param := '+skill';
33: Param := '+playdemo';
34: Param := '+mat_dxlevel';
end;
if pos(Param,AllText) > 0 then
begin
pos_simbol := Pos(Param, AllText);
Insert(' ',AllText, pos_simbol);
Insert(' ',AllText, pos_simbol+Length(Param)+1);
end;
i := i + 1;
end;
until i = 35;
Result := Trim(DelSp(AllText));
end;
function DeleteAllSp(const st: String): String; /// убрать все пробелы
begin
while pos(' ',st)>0 do delete(st,pos(' ',st),1);
Result := st;
end;
procedure Buttons_OnClick(Sender:TObject);
begin
case TButton(Sender).Caption of
'Insert': Param_Edit.Text := InsertSp(Param_Edit.Text);
'Delete': Param_Edit.Text := DeleteAllSp(Param_Edit.Text);
end;
end;
procedure InitializeWizard();
begin
WizardForm.OuterNotebook.Hide;
WizardForm.Width := 900;
WizardForm.Position := poScreenCenter;
Param_Edit := TNewEdit.Create(nil);
with Param_Edit do
begin
Parent := WizardForm;
SetBounds(ScaleX(40), ScaleY(100), ScaleX(700), ScaleY(21));
Text := InsertSp('+fps_max80-dxlevel80-hideconsole-32bit-gl-novid+cl_showfps1-dev1+sv_cheats1+playdemoTheBestDemo-condebug+skill2');
end;
with TButton.Create(nil) do
begin
Parent := WizardForm;
SetBounds(Param_Edit.Left + Param_Edit.Width + ScaleX(5), Param_Edit.Top, ScaleX(65), Param_Edit.Height);
Caption := 'Insert';
Cursor := crHand;
OnClick := @Buttons_OnClick;
end;
with TButton.Create(nil) do
begin
Parent := WizardForm;
SetBounds(Param_Edit.Left + Param_Edit.Width + ScaleX(5) + ScaleX(70), Param_Edit.Top, ScaleX(65), Param_Edit.Height);
Caption := 'Delete';
Cursor := crHand;
OnClick := @Buttons_OnClick;
end;
end;
кажись проблема в том что есть параметр -h
и есть параметр -hideconsole который в начале тоже имеет -h
подскажите пожалуйста как это поправить и можно ли как-то ускорить работу функции InserSp?
также порывшись на форумах по дельфи улучшил функцию проверки строки на целое число
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[ code]
function IsInt(const Value: string): Boolean;
begin
Result := StrToIntDef(Value,0) <> 0;
end;
procedure InitializeWizard();
begin
if IsInt('10') then MsgBox('yes', mbInformation, MB_OK);
if not IsInt('hfhfrh') then MsgBox('no', mbInformation, MB_OK);
end;
и кому надо функция получения разрешения монитора (верт., гор.) и частоты обновления (мне нужна для +fps_max и для -refresh и других параметров)
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[ code]
function GetDC(HWND: DWord): DWord; external 'GetDC@user32.dll stdcall';
function GetDeviceCaps(DC: DWord; Index: Integer): Integer; external 'GetDeviceCaps@gdi32.dll stdcall';
function ReleaseDC(HWND: DWord;DC: DWord): Integer; external 'ReleaseDC@user32.dll stdcall';
function GetMonitorInfo(MetricType:Byte;Descriptor:THandle): Word;
var
dc: DWord;
begin
Result := 0;
case MetricType of
1: /// разрешение по ширине
begin
dc := GetDC(Descriptor);
Result := GetDeviceCaps(dc,8);
end;
2: /// разрешение по высоте
begin
dc := GetDC(Descriptor);
Result := GetDeviceCaps(dc,10);
end;
3: /// частота обновления экрана
begin
dc := GetDC(Descriptor);
Result := GetDeviceCaps(dc,116);
end;
end;
ReleaseDC(Descriptor,dc);
end;
procedure InitializeWizard();
begin
MsgBox(
'разрешение по горизонтали - ' + IntToStr(GetMonitorInfo(1,MainForm.Handle)) + #13#10 +
'разрешение по вертикали - ' + IntToStr(GetMonitorInfo(2,MainForm.Handle)) + #13#10 +
'частота обновления - ' + IntToStr(GetMonitorInfo(3,MainForm.Handle)),
mbConfirmation, MB_OK);
end;
Извиняюсь, поторопился... исправил предыдущее сообщение. »
держи еще вариант: »
Спасибо добрые люди! :)
предстоит много работы но теперь у меня есть всё для того чтоб завершить код