Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для Johny777

Ветеран


Сообщения: 649
Благодарности: 444

Профиль | Отправить PM | Цитировать


Serega,
вот спасибо!
правда Inno ругалась на отсутствие двоеточия
поменял 0..9:
на '0','1','2','3','4','5','6','7','8','9':

Цитата Serega:
Функция GetText1 вернёт пустую строку »
тут проблема
дело в том что не совсем известно каким будет закрывающий тег
это может быть - (для например -dev) или + (для +cl_chowfps)
при использовании с предыдущим кодом возвращает 0

может можно по другому ?
лучший вариант :
заюзать Trim
и искать после заданного слова всё что там находится вплоть до + или - тк все параметры с них и начинаются
+fps_max60-console - возвращать 60 из между +fps_max и -
-dev-console возвращать пустую строку (у параметра dev может не быть значения а может быть 1 или 2)
весь этот поиск значений нужен мне тк у меня реализовано следующее
если во время работающего инсталла вводить значения
например +fps_max 60 то 60 пишется в переменную а вся строка в эдит
если ввести +fps_max 50 то слово и значение удалится и заменится на новые
но когда текст в эдите при запуске уже есть я не могу(в отличии от слов) удалять значения пока они не будут найдены
а с поиском между параметром целиком и минусом или плюсом следующего параметра можно будет даже выловить название карты
+map MyMapName -console
вот ранняя версия целевого кода для наглядности
читать дальше »
Код: Выделить весь код
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application



[  code]
const
  gwl_style = (-16);
  ES_NUMBER = $2000;

function GetSystemMenu(hWnd: HWND; bRevert: BOOL): LongWord; external 'GetSystemMenu@user32.dll stdcall';
function DeleteMenu(hMenu: LongWord; uPosition, uFlags: UINT): BOOL; external 'DeleteMenu@user32.dll stdcall';
function GetClassLong(Wnd: HWnd; Index: Integer): Longint; external 'GetClassLongA@user32.dll stdcall';
function SetClassLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetClassLongA@user32.dll stdcall';

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 SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';



var
  Param_Edit, Add_Param_Edit, wEdit, hEdit, Empty_Edit: TEdit;
  OK_Button: TButton;
  Param_PopMenu: TPopupMenu;
  h, w, hi, wi, RefrehRate: Integer;
  
  User_FPS, Dev_Value, DX_Value: Integer;
  User_Map: String;
    

procedure Edits_OnKeyPress(Sender: TObject; var Key: Char);    ///добавть переход на кнопку Ok для всех эдитов
begin
  case TEdit(Sender) of
    wEdit:
    begin
    // if Pos(Key, '0123456789'#8) = 0 then Key := #0;
    /// if Pos(Key, '0123456789'#13) = 0 then hEdit.SetFocus; как правильно нажать на ентер
    end else
    begin
    //  if Pos(Key, '0123456789'#8) = 0 then Key := #0;
      ///if Pos(Key, #13) = 0 then OK_Button.SetFocus;
    end;
  end;
end;


// Удаление начальных, конечных и повторных пробелов
function DelSp(const st: String): String;
var
  c, i: integer;
  stt, st1: string;
begin
  c := 0;

  for i := 1 to Length(st) do
  begin
    stt := copy(st, i, 1);
    if (stt = ' ') and (c >= 1) then
    begin
      st1 := st1;
      c := c + 1;
    end
    else if (stt = ' ') and (c = 0) then
    begin
      c := c + 1;
      st1 := st1 + stt;
    end
    else if (stt <> ' ') then
    begin
      c := 0;
      st1 := st1 + stt;
    end
  end;

  Result := st1;
end;


function OnlyInt(const Value: string): string; /// оставлять только цифры
var
  i, len: Integer;
begin
  Result := '';
  len := Length(Value);
  if len > 0 then
    for i := 1 to len do
      case Value[i] of
        '0','1','2','3','4','5','6','7','8','9': Result := Result + Value[i];
      end;
end;

function IsInt(const Value: string): Boolean;   /// цифры ли
var
  i: Integer;
begin
  Result := False;
  if Length(Value) > 0 then
    for i := 0 to 9 do
      begin
        Result := Pos(IntToStr(i), Value) > 0;
        if Result then
          Break;
      end;
end;



procedure Num_Edit_OnChange(Sender:TObject);
begin
  case TEdit(Sender).Tag of
    0: if RefrehRate > 0 then OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) > 0) and (StrToInt(TEdit(Sender).Text) <= RefrehRate) else OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) > 0) and (StrToInt(TEdit(Sender).Text) <= 250);
    1: OK_Button.Enabled := (TEdit(Sender).Text <> '')  and (StrToInt(TEdit(Sender).Text) = 0) and (StrToInt(TEdit(Sender).Text) = 1);
    2: OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) = 1) and (StrToInt(TEdit(Sender).Text) = 2) and (StrToInt(TEdit(Sender).Text) = 3);
    4: OK_Button.Enabled := (TEdit(Sender).Text <> '') and ((StrToInt(TEdit(Sender).Text) = 70) or (StrToInt(TEdit(Sender).Text) = 80) or (StrToInt(TEdit(Sender).Text) = 90));
    5: OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) <= w) and (StrToInt(TEdit(Sender).Text) >= 640);
    6: OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) <= h) and (StrToInt(TEdit(Sender).Text) >= 480);
    7: OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) >= 0) and (StrToInt(TEdit(Sender).Text) <= w-wi);
    8: OK_Button.Enabled := (TEdit(Sender).Text <> '') and (StrToInt(TEdit(Sender).Text) >= 0) and (StrToInt(TEdit(Sender).Text) <= h-hi);
    10: OK_Button.Enabled := (TEdit(Sender).Text = '') or (TEdit(Sender).Text = '1') or (TEdit(Sender).Text = '2');
    11: OK_Button.Enabled := (TEdit(Sender).Text <> '');///  not IsStringCyrillic(TEdit(Sender).Text);
  end;                                                                                                                                                               
end;


function GetMonitorResolutionInfo(MetricType:Boolean): Integer; /// True для высоты, false для ширины  /// соединить с нижней
var
  dc: DWord;
begin
  Result := 0;
  if MetricType = True then
  begin                                                                                  
    dc := GetDC(MainForm.Handle);
    Result := GetDeviceCaps(dc,10);
    ReleaseDC(MainForm.Handle,dc);
  end else
  begin
    dc := GetDC(MainForm.Handle);
    Result := GetDeviceCaps(dc,8);
    ReleaseDC(MainForm.Handle,dc);
  end;
end;


function GetRefreshRate:Integer;
var
  dc: DWord;
begin
  Result := 0;
  dc := GetDC(MainForm.Handle);
  Result := GetDeviceCaps(dc,116);
  ReleaseDC(MainForm.Handle,dc);
end;


function Param_Num(Param, Info_Text: String; Edit_Tag: Byte; Input_Text_Length: Longint): String;
var
  NumForm: TForm;
  Num_Edit: TEdit;
begin
  Result := '';

// Input_Value
// 0 - fps
// 1 - значения 0,1
// 2 - значения 1,2,3
// 4 - значения директа 80, 90, 70
// 5 - расширение по горизонтали
// 6 - расширение по вертикали

// 7 - расположение по ширине
// 8 - расположение по высоте

// 9 - частота обновления экрана
// 10 - dev параметр
// 11 - карта пользователя (НЕ фоновая)

  NumForm := TForm.Create(nil);
  with NumForm do
  begin
    ClientWidth := ScaleX(260);
    ClientHeight := ScaleY(80);
    Position := poScreenCenter;
    DeleteMenu(GetSystemMenu(NumForm.Handle,False), $F060,0); /// сделать кнопку "закрыть" неактивной
    SetClassLong(NumForm.Handle, -26, GetClassLong(NumForm.Handle, -26) or $200); /// блокировка комбинации alt + f4
    BorderIcons := [];

    with TLabel.Create(nil) do
    begin
      WordWrap := True;
      AutoSize := False;
      SetBounds(ScaleX(10), ScaleY(0), ScaleX(240), ScaleY(45));
      Caption := Info_Text;
      Parent := NumForm;
      Font.Size := 7;
    end;

    Num_Edit := TNewEdit.Create(nil);
    with Num_Edit do
    begin
      Parent := NumForm;
      SetBounds(ScaleX(10), ScaleY(50), ScaleX(160), ScaleY(21));
      Text := '';
      OnChange := @Num_Edit_OnChange;
      OnKeyPress := @Edits_OnKeyPress;
      Tag := Edit_Tag;
      MaxLength := Input_Text_Length;
    end;
    
    if Edit_Tag <> 11 then SetWindowLong( Num_Edit.Handle, GWL_STYLE, GetWindowLong( Num_Edit.Handle, GWL_STYLE ) or ES_NUMBER );

    OK_Button := TButton.Create(nil)
    with OK_Button do     // ok
    begin
      SetBounds(NumForm.ClientWidth - ScaleX(80), ScaleY(49), ScaleX(70), ScaleX(23));
      Parent := NumForm;
      Caption := ExpandConstant(SetupMessage(msgButtonOK));
      ModalResult := mrOk;
      Enabled := Edit_Tag = 10; // те параметр dev где может не быть значения
    end;

    if ShowModal = mrOk then
    begin
      case Param of
        '-dxlevel <значение>', '+fps_max <значение>': Delete(Param,Pos('<значение>',Param),Length(Param));
        '-w <широта>': Delete(Param,Pos('<широта>',Param),Length(Param));
        '-h <высота>': Delete(Param,Pos('<высота>',Param),Length(Param));
        '-x <позиция>', '-y <позиция>': Delete(Param,Pos('<позиция>',Param),Length(Param));
        '-refresh <значение>', '+cl_showfps <значение>', '+sv_cheats <значение>', '+skill <значение>', '+mat_dxlevel <значение>': Delete(Param,Pos('<значение>',Param),Length(Param));
        '+map <имя карты>', '+map_background <имя карты>': Delete(Param,Pos('<имя карты>',Param),Length(Param));
        '+exec <название конфига.cfg>': Delete(Param,Pos('<название конфига.cfg>',Param),Length(Param));
        '+playdemo <название>': Delete(Param,Pos('<название>',Param),Length(Param));
      end;
      
      case Edit_Tag of
        0: User_FPS := StrToInt(Num_Edit.Text);
        4: DX_Value := StrToInt(Num_Edit.Text);
        11: User_Map := Trim(Num_Edit.Text);
      end;

      Result := TrimRight(Param) + ' ' + Num_Edit.Text;
      
     /// зсдеь в завсимости от тега писать значения в переменные (например скорость фпс) чтоб потом их удалять
    end;

    Free;
  end;
end;


procedure wh_Edits_OnChange(Sender:TObject);
begin
  OK_Button.Enabled := (wEdit.Text <> '') and (StrToInt(wEdit.Text) <= w) and (StrToInt(wEdit.Text) >= 640) and
  (hEdit.Text <> '') and (StrToInt(hEdit.Text) <= h) and (StrToInt(hEdit.Text) >= 480);
end;

procedure Set_Window_Width_Hight(wLength,hLength:Byte);
var
  SizeForm: TForm;
begin
  SizeForm := TForm.Create(nil);
  with SizeForm do
  begin
    ClientWidth := ScaleX(260);
    ClientHeight := ScaleY(80);
    Position := poScreenCenter;
    DeleteMenu(GetSystemMenu(SizeForm.Handle,False), $F060,0); /// сделать кнопку "закрыть" неактивной
    SetClassLong(SizeForm.Handle, -26, GetClassLong(SizeForm.Handle, -26) or $200); /// блокировка комбинации alt + f4
    BorderIcons := [];

    with TLabel.Create(nil) do
    begin
      WordWrap := True;
      AutoSize := False;
      SetBounds(ScaleX(10), ScaleY(0), ScaleX(240), ScaleY(45));
      Caption := 'Введите сначала ширину и высоту';
      Parent := SizeForm;
      Font.Size := 7;
    end;

    wEdit := TNewEdit.Create(nil);
    with wEdit do
    begin
      Parent := SizeForm;
      SetBounds(ScaleX(10), ScaleY(50), ScaleX(50), ScaleY(21));
      Text := '';
      OnChange := @wh_Edits_OnChange;
      OnKeyPress := @Edits_OnKeyPress;
      MaxLength := wLength;
    end;

    hEdit := TNewEdit.Create(nil);
    with hEdit do
    begin
      Parent := SizeForm;
      SetBounds(wEdit.Left + wEdit.Width + ScaleX(10), ScaleY(50), ScaleX(50), ScaleY(21));
      Text := '';
      OnChange := @wh_Edits_OnChange;
      OnKeyPress := @Edits_OnKeyPress;
      MaxLength := hLength;
    end;
    
    SetWindowLong(wEdit.Handle, GWL_STYLE, GetWindowLong(wEdit.Handle, GWL_STYLE) or ES_NUMBER);
    SetWindowLong(hEdit.Handle, GWL_STYLE, GetWindowLong(hEdit.Handle, GWL_STYLE) or ES_NUMBER);

    OK_Button := TButton.Create(nil)
    with OK_Button do     // ok
    begin
      SetBounds(SizeForm.ClientWidth - ScaleX(80), ScaleY(49), ScaleX(70), ScaleX(23));
      Parent := SizeForm;
      Caption := ExpandConstant(SetupMessage(msgButtonOK));
      ModalResult := mrOk;
      Enabled := False;
    end;

    if ShowModal = mrOk then
    begin
      hi := StrToInt(hEdit.Text);
      wi := StrToInt(wEdit.Text);
    end;

    Free;
  end;
end;

/// добавть элемент меню "показать описание параметров" выкатывающий панель



function DeleteWord(AllText,Word_1,Word_2,Param,Value: String): String;    /// заменить на замену слова
var
  SpDeletedAllText: String;
begin
  SpDeletedAllText := DelSp(AllText);
  
  if Word_1  <> '' then while pos(Word_1,SpDeletedAllText)>0 do delete (SpDeletedAllText,pos(Word_1,SpDeletedAllText),length(Word_1));
  if Word_1  <> '' then while pos(Word_2,SpDeletedAllText)>0 do delete (SpDeletedAllText,pos(Word_2,SpDeletedAllText),length(Word_2));
  if Param  <> '' then while pos(Param,SpDeletedAllText)>0 do delete (SpDeletedAllText,pos(Param,SpDeletedAllText),length(Param)+Length(Value)+1);
  
  Result := SpDeletedAllText;
end;


function Replace(Str, X, Y: string): string; //// замена слова
{Str - строка, в которой будет производиться замена.
 X - подстрока, которая должна быть заменена.
 Y - подстрока, на которую будет произведена заменена}
var
  buf1, buf2, buffer: string;
begin
  buf1 := '';
  buf2 := Str;
  Buffer := Str;
  while Pos(X, buf2) > 0 do
  begin
    buf2 := Copy(buf2, Pos(X, buf2), (Length(buf2) - Pos(X, buf2)) + 1);
    buf1 := Copy(Buffer, 1, Length(Buffer) - Length(buf2)) + Y;
    Delete(buf2, Pos(X, buf2), Length(X));
    Buffer := buf1 + buf2;
  end;
  Result := Buffer;
end;


//procedure InitializeWizard();
//begin
//  MsgBox(Replace('-dev -console +fps_max 60','-console','-gl'), mbConfirmation, MB_OK);
//end;


procedure Paste(Sender:TObject);
var
  StrRefrehRate: String;
  StrRefrehRateLength: Integer;
begin
  case TMenuItem(Sender).Caption of
                                                                                               
    '-console':            if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-console','','','') + ' ' + TMenuItem(Sender).Caption); // готово
    '-hideconsole':        if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-hideconsole','','','') + ' ' + TMenuItem(Sender).Caption); // готово
    '-safe':               if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-safe','','','') + ' ' + TMenuItem(Sender).Caption);  // готово
    '-dev':                if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'Возможные значения: 1, 2, нет значения', 10, 1) else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'','','-dev',IntToStr(Dev_Value)) + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Возможные значения: 1, 2, нет значения', 10, 1));  // готово
    '-condebug':           if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-condebug','','','') + ' ' + TMenuItem(Sender).Caption);  // готово
    '-autoconfig':         if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-autoconfig','','','') + ' ' + TMenuItem(Sender).Caption);  // готово
    '-dxlevel <значение>': if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'Задайте версию DirectX. Например для DirectX 8.0 - значение 80 (возможные значения: 70, 80, 90)', 4, 2) else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'','','-dxlevel',IntToStr(DX_Value)) + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Задайте версию DirectX. Например для DirectX 8.0 - значение 80 (возможные значения: 70, 80, 90)', 4, 2));  // готово
    '-32bit':              if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-32bit','','','') + ' ' + TMenuItem(Sender).Caption); // готово
    '-fullscreen':         if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-fullscreen','-windowed','','') + ' ' + TMenuItem(Sender).Caption); // готово /// образец качества
    '-windowed':           if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'-fullscreen','-windowed','','') + ' ' + TMenuItem(Sender).Caption); // готово

    
    '-w <широта>':
    begin
      if (w = 0) then w := GetMonitorResolutionInfo(False);
      if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'Укажите разрешение по горизонтали. Максимальное значение - ' + IntToStr(w) + '. Минимальное - 640', 5, Length(IntToStr(w))) else
      Empty_Edit.Text := Empty_Edit.Text + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Укажите разрешение по горизонтали. Максимальное значение - ' + IntToStr(w) + '. Минимальное - 640', 5, Length(IntToStr(w)));
    end;
    
    '-h <высота>':
    begin
      if (h = 0) then h := GetMonitorResolutionInfo(True);
      if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'Укажите разрешение по вертикали. Максимальное значение - ' + IntToStr(h) + '. Минимальное - 480', 6, Length(IntToStr(h))) else
      Empty_Edit.Text := Empty_Edit.Text + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Укажите разрешение по горизонтали. Максимальное значение - ' + IntToStr(h) + '. Минимальное - 480', 6, Length(IntToStr(h)));
    end;
    
    '-x <позиция>':
    begin
      if (w = 0) then w := GetMonitorResolutionInfo(False);
      if (h = 0) then h := GetMonitorResolutionInfo(True);
      
      Set_Window_Width_Hight(Length(IntToStr(w)),Length(IntToStr(h)));
      
      /// ограничить ввод разрешения до стандартныз (сделать комбобоксы?)
      
      if not (hi = h) and not (wi = w) then
      
      if Empty_Edit.Text = '' then Empty_Edit.Text :='-w' + ' ' + IntToStr(wi) + ' ' + '-h' + ' ' + IntToStr(hi) + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Укажите расположение окна от левого края. Максимальное значение - ' + IntToStr(w-wi) + '. Минимальное - 0', 7, Length(IntToStr(w))) else
      Empty_Edit.Text := Empty_Edit.Text + ' ' + '-w' + ' ' + IntToStr(wi) + ' ' + '-h' + ' ' + IntToStr(hi) + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Укажите расположение окна от левого края. Максимальное значение - ' + IntToStr(w-wi) + '. Минимальное - 0', 7, Length(IntToStr(w)));
    end;

    '-y <позиция>':  
    begin
      if (w = 0) then w := GetMonitorResolutionInfo(False);
      if (h = 0) then h := GetMonitorResolutionInfo(True);

      Set_Window_Width_Hight(Length(IntToStr(w)),Length(IntToStr(h)));
      
      if not (hi = h) and not (wi = w) then /// если значение сдвига 0 (введённое разрешение совпадаетс с реальным) то не добавлять параметр и е создавать форму

      if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'Укажите расположение окна от верхнего края. Максимальное значение - ' + IntToStr(h-hi) + '. Минимальное - 0', 8, Length(IntToStr(h))) else
      Empty_Edit.Text := Empty_Edit.Text + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Укажите расположение окна от верхнего края. Максимальное значение - ' + IntToStr(h-hi) + '. Минимальное - 0', 8, Length(IntToStr(h)));
    end;
    
    '-nocrashdialog':                 if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-novid':                         if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-noborder':                      if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-nojoy':                         if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-noforcemspd':                   if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-noforcemparms':                 if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-noforcemaccel':                 if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    
//    '-refresh <значение>': 


    '-d3d':                           if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-gl':                            if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
    '-wavonly':                       if Empty_Edit.Text = '' then Empty_Edit.Text := TMenuItem(Sender).Caption else Empty_Edit.Text := Empty_Edit.Text + ' ' + TMenuItem(Sender).Caption;
//
    '+cl_showfps <значение>':
//    '+map <имя карты>':    if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'Введите имя карты. Расширение .bsp добавлять не нужно', 11, 60) else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'','','+map',User_Map) + ' ' + Param_Num(TMenuItem(Sender).Caption, 'Введите имя карты. Расширение .bsp добавлять не нужно', 11, 60));  // готово
//    '+map_background <имя карты>':
//    '+sv_cheats <значение>':
//    '+exec <название конфига.cfg>':
//    '+fps_max <значение>':
    begin
      if RefrehRate = 0 then
      begin
        RefrehRate := GetRefreshRate;
        if RefrehRate > 0 then
        begin
          StrRefrehRate := IntToStr(RefrehRate);
          StrRefrehRateLength := Length(StrRefrehRate);
        end else
        begin
          StrRefrehRate := '250';
          StrRefrehRateLength := 3;
        end;
      end;
      if Empty_Edit.Text = '' then Empty_Edit.Text := Param_Num(TMenuItem(Sender).Caption, 'сколько кадров в секунду?Максимальное значение - ' + StrRefrehRate, 0, StrRefrehRateLength) else Empty_Edit.Text := DelSp(DeleteWord(Empty_Edit.Text,'','','+fps_max',IntToStr(User_FPS)) + ' ' + Param_Num(TMenuItem(Sender).Caption, 'сколько кадров в секунду?Максимальное значение - ' + StrRefrehRate, 0, StrRefrehRateLength));   /// образец качества
    end;
//    '+skill <значение>':
//    '+playdemo <название>':
//    '+mat_dxlevel <значение>':

    'описание параметров': /// выкатить панель
    begin
//      RollControl(SettingPanel, 1000, $0);
//      with ConsoleSpeedButton do
//      begin
//        Enabled := False;
//        ShowHint := False;
//      end;
    end;
  end;
end;                                                                                                                             

procedure Param_Button_OnClick(Sender:TObject);
var
  pt: TPoint;
begin
  case TButton(Sender).Tag of
    71: Empty_Edit := Param_Edit;
    90: Empty_Edit := Add_Param_Edit;
  end;
  
  pt := TButton(Sender).ClientToScreen(pt);
  Param_PopMenu.Popup(pt.x, pt.y);
end;



//берет из текста участок текста, который заключен между первым словом (OpenTag) и любым другим (CloseTag). Работает блестяще.
function GetText1(OpenTag,aText,CloseTag:string):string;
begin
  Result:=Copy(aText,Pos(OpenTag,aText)+Length(OpenTag),Pos(CloseTag,aText)-Length(CloseTag)-1);
end;


procedure InitializeWizard();
var
  Temp_Value_String, Params:String;
begin
  WizardForm.OuterNotebook.Hide;
  
  /// добавть менб как в авторане те если   Pos('параметр', текст эдита) больше нуля то не добавлять ацтем меню
  Param_PopMenu := NewPopupMenu(WizardForm, 'MyPopupMenu', paLeft, True, [
    NewItem('-console', 0, False, True, @Paste, 11, ''),
    NewItem('-hideconsole', 0, False, True, @Paste, 11, ''),
    NewItem('-safe', 0, False, True, @Paste, 11, ''),
    NewItem('-dev', 0, False, True, @Paste, 11, ''), // Включает режим разработки. Для отключения загрузки стандартных фоновых карт и сообщения с подтверждением выхода из игры по причине быстродействия, используйте параметр командной строки -dev. Используйте  команды 'dev 1' и 'dev 2' для вывода служебных сообщений в консоль.
    NewItem('-condebug', 0, False, True, @Paste, 11, ''),
    NewItem('-autoconfig', 0, False, True, @Paste, 11, ''),
    NewItem('-dxlevel <значение>', 0, False, True, @Paste, 11, ''),  //  - Задает версию DirectX, используемую игровым движком. Например, для DirectX 8.0 необходимо использовать -dxlevel 80.
    NewItem('-32bit', 0, False, True, @Paste, 11, ''),
    NewItem('-fullscreen', 0, False, True, @Paste, 11, ''),
    NewItem('-windowed', 0, False, True, @Paste, 11, ''),
    NewItem('-w <широта>', 0, False, True, @Paste, 11, ''),  // <широта> или -width <ширина> - Принудительно запускает движок с установленной <шириной>. Пример: -w 1024
    NewItem('-h <высота>', 0, False, True, @Paste, 11, ''),  // <высота> или -height <высота> - Принудительно запускает движок с установленной <высотой>. Пример: -h 768
    NewItem('-x <позиция>', 0, False, True, @Paste, 11, ''), //  <позиция> - Устанавливает расположение окна по горизонтали в оконном режиме . Пример: -x 0
    NewItem('-y <позиция>', 0, False, True, @Paste, 11, ''), // <позиция> - Устанавливает расположение окна по вертикали в оконном режиме . Пример: -y 0
    NewItem('-nocrashdialog', 0, False, True, @Paste, 11, ''),
    NewItem('-novid', 0, False, True, @Paste, 11, ''),
    NewItem('-noborder', 0, False, True, @Paste, 11, ''),
    NewItem('-nojoy', 0, False, True, @Paste, 11, ''),
    NewItem('-noforcemspd', 0, False, True, @Paste, 11, ''), /// Работает только с -useforcedmparms
    NewItem('-noforcemparms', 0, False, True, @Paste, 11, ''), /// Работает только с -useforcedmparms
    NewItem('-noforcemaccel', 0, False, True, @Paste, 11, ''), /// Работает только с -useforcedmparms
    NewItem('-refresh <значение>', 0, False, True, @Paste, 11, ''), /// <периодичность> - Устанавливает особую периодичность обновления экрана. Пример: -refresh 60.
    NewItem('-d3d', 0, False, True, @Paste, 11, ''),
    NewItem('-gl', 0, False, True, @Paste, 11, ''),
    NewItem('-wavonly', 0, False, True, @Paste, 11, ''),
    NewLine,
    NewItem('+cl_showfps <значение>', 0, False, True, @Paste, 11, ''), //     отображать количество кадров в секунду
    NewItem('+map <имя карты>', 0, False, True, @Paste, 11, ''), //     -  Загружает заданную карту сразу после запуска движка. Примечание: расширение .BSP не требуется.
    NewItem('+map_background <имя карты>', 0, False, True, @Paste, 11, ''), //     - Задает необходимую фоновую карту. Полезно для тестирования собственных фоновых карт.
    NewItem('+sv_cheats <значение>', 0, False, True, @Paste, 11, ''),  //    - Когда установлено в 1, запускает игру с возможностью использования консольных читов.
    NewItem('+exec <название конфига.cfg>', 0, False, True, @Paste, 11, ''),  //     - Автоматически исполняет конфигурационный файл при запуске. Например, можно выполнить ваш специальный конфиг с настройками.
    NewItem('+fps_max <значение>', 0, False, True, @Paste, 12, ''),
    NewItem('+skill <значение>', 0, False, True, @Paste, 11, ''), //     - Устанавливает уровень сложности; 1=лёгкий, 2=средний, 3=сложный. Например +skill 3.
    NewItem('+playdemo <название>', 0, False, True, @Paste, 11, ''),

    NewItem('+mat_dxlevel <значение>', 0, False, True, @Paste, 11, ''),
    //     – установливает версию шейдера
    //    Пример:
    //    mat_dxlevel 90 - DX9 with Shader Model 2
    //    mat_dxlevel 95 - DX9 with Shader Model 3
    //    mat_dxlevel 98 - DX9 on DX10 hardware (SM 4)
    
    NewLine,
    NewItem('описание параметров', 0, False, True, @Paste, 11, '')
  ]);

  Param_Edit := TNewEdit.Create(nil);
  with Param_Edit do
  begin
    Parent := WizardForm;
    SetBounds(ScaleX(40), ScaleY(100), ScaleX(300), ScaleY(21));
    Text := '+fps_max 60 -console';
  end;
  
  Params := Param_Edit.Text;
  
  if Params <> '' then
  begin
    if Pos('+fps_max',Param_Edit.text) >0 then
    begin
      Temp_Value_String := GetText1('+fps_max',Param_Edit.Text,' ');
      if IsInt(Temp_Value_String) = True then User_FPS := StrToInt(OnlyInt(Temp_Value_String));
      MsgBox(IntToStr(User_FPS), mbConfirmation, MB_OK);
    end;
  end;

  //



  // if pos('+fps_max',Param_Edit.Text)>0 then искать слово

  Add_Param_Edit := TNewEdit.Create(nil);
  with Add_Param_Edit do
  begin
    Parent := WizardForm;
    SetBounds(ScaleX(40), ScaleY(160), ScaleX(300), ScaleY(21));
    Text := '';
  end;
  
  with TButton.Create(nil) do
  begin
    Parent := WizardForm;
    SetBounds(Param_Edit.Left + Param_Edit.Width + ScaleX(5), Param_Edit.Top, ScaleX(75), Param_Edit.Height);
    Caption := 'Push Me';
    Cursor := crHand;
    OnClick := @Param_Button_OnClick;
    Tag := 71;
  end;
  
  with TButton.Create(nil) do
  begin
    Parent := WizardForm;
    SetBounds(Add_Param_Edit.Left + Add_Param_Edit.Width + ScaleX(5), Add_Param_Edit.Top, ScaleX(75), Add_Param_Edit.Height);
    Caption := 'Push Me 2';
    Cursor := crHand;
    OnClick := @Param_Button_OnClick;
    Tag := 90;
  end;
  
    

end;


procedure CurPageChanged(CurPageID: Integer);
begin
  WizardForm.NextButton.Hide;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Confirm := False;
end;

Последний раз редактировалось Johny777, 18-09-2012 в 01:53.


Отправлено: 18:39, 17-09-2012 | #943