Advertisement
Guest User

лончер колды

a guest
Apr 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 15.69 KB | None | 0 0
  1. [Setup]
  2. AppName=Call of Duty Launcher
  3. AppPublisher=Ma3xZ (c) 2019
  4. AppVersion=1.0
  5. DefaultDirName={src}
  6. Uninstallable=no
  7. AlwaysShowComponentsList=no
  8. DisableDirPage=yes
  9. DisableFinishedPage=yes
  10. DisableProgramGroupPage=yes
  11. DisableReadyMemo=yes
  12. DisableReadyPage=yes
  13. DisableWelcomePage=yes
  14. SetupIconFile=icon.ico
  15. WindowResizable=no
  16. WizardSmallImageFile=image.bmp
  17. OutputBaseFilename=launcher
  18. ShowLanguageDialog=no
  19.  
  20. [Languages]
  21. Name: ru; MessagesFile: compiler:Languages\Russian.isl
  22. Name: en; MessagesFile: compiler:Default.isl
  23.  
  24. [Files]
  25. DestName: "WizardForm.BitmapImage1.bmp"; Source: "image.bmp"; Flags: dontcopy solidbreak
  26.  
  27. [CustomMessages]
  28. ruSettingsText=Íàñòðîéêè
  29. enSettingsText=Settings
  30. ruSaveText=Ñîõðàíèòü
  31. enSaveText=Save
  32. ruJustExitText=Âûõîä
  33. enJustExitText=Exit
  34. ruLangText=EN
  35. enLangText=RU
  36. ruRatioText=Ñîîòíîøåíèå ñòîðîí ýêðàíà:
  37. enRatioText=Display Aspect Ratio:
  38. ruResolutionText=Ðàçðåøåíèå ýêðàíà:
  39. enResolutionText=Display Resolution:
  40. ruFullScreenText=Ïîëíîýêðàííûé ðåæèì
  41. enFullScreenText=Full-screen mode
  42.  
  43. [Code]
  44. var
  45.   Settings, Save, LangBtn, JustExit: TNewButton;
  46.   COD, CODUO: TNewButton;
  47.   SettingsPage: TWizardPage;
  48.   Image: TBitmapImage;
  49.   Ratio, Resolution: TNewComboBox;
  50.   RatioText, ResolutionText: TLabel;
  51.   FullScreen: TnewCheckbox;
  52.   lang: String;
  53.   FOVString, FullscreenString, WidthString, HeightString: string;
  54.   FOVValue, FullscreenValue, WidthValue, HeightValue: string;
  55.   ResolutionDefault: string;
  56.   WidthNewValue, HeightNewValue: String;
  57.  
  58. const
  59.   GWL_STYLE = -16;
  60.   WS_MINIMIZEBOX = $20000;
  61.   WS_MAXIMIZEBOX = $10000;
  62.  
  63. function ReleaseCapture: Longint; external 'ReleaseCapture@user32.dll stdcall';
  64. procedure LabelOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  65.   begin ReleaseCapture; SendMessage(WizardForm.Handle,$0112,$F012,0); end;
  66. procedure ExitProcess(uExitCode: Integer); external 'ExitProcess@kernel32.dll stdcall';
  67. function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
  68. function GetWindowLong(hWnd: HWND; nIndex: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';
  69. function TryGetFileLine(const FileName: string; Index: Integer; out Line: string): Boolean; var FileLines: TArrayOfString;
  70.   begin Result := LoadStringsFromFile(FileName, FileLines) and (GetArrayLength(FileLines) > Index); if Result then Line := FileLines[Index]; end;
  71.  
  72. procedure GetConfigValues();
  73. begin
  74.   // if the first line of the file was successfully read and could have been
  75.   // converted to integer, then...
  76.   if TryGetFileLine(ExpandConstant('{src}\Main\config.cfg'), 47, FOVString) and TryGetFileLine(ExpandConstant('{src}\Main\config.cfg'), 142, FullscreenString) and
  77.      TryGetFileLine(ExpandConstant('{src}\Main\config.cfg'), 129, WidthString) and TryGetFileLine(ExpandConstant('{src}\Main\config.cfg'), 128, HeightString) then
  78.   begin
  79.     FOVValue:=FOVString;
  80.     FullscreenValue:=FullscreenString;
  81.     WidthValue:=WidthString;
  82.     HeightValue:=HeightString;
  83.     StringChangeEx(FOVValue, 'seta cg_fov "', '', True);
  84.     StringChangeEx(FOVValue, '"', '', True);
  85.     StringChangeEx(FullscreenValue, 'seta r_fullscreen "', '', True);
  86.     StringChangeEx(FullscreenValue, '"', '', True);
  87.     StringChangeEx(WidthValue, 'seta r_customwidth "', '', True);
  88.     StringChangeEx(WidthValue, '"', '', True);
  89.     StringChangeEx(HeightValue, 'seta r_customheight "', '', True);
  90.     StringChangeEx(HeightValue, '"', '', True);
  91.   end;
  92. end;
  93.  
  94. procedure WriteNewValue();
  95. var
  96.   i, t:integer;
  97.   UnicodeStr: string;
  98.   ANSIStr: AnsiString;
  99. begin
  100.   WidthNewValue:= Resolution.Text;
  101.   i:=Pos('x', WidthNewValue);
  102.   Delete (WidthNewValue, i, i+1);
  103.   HeightNewValue:= Resolution.Text;
  104.   t:=Pos('x', HeightNewValue);
  105.   Delete (HeightNewValue, 1, t);
  106.   if LoadStringFromFile(ExpandConstant('{src}\Main\config.cfg'), AnsiStr) then
  107.   begin
  108.     UnicodeStr:=AnsiStr;
  109.     StringChangeEx(UnicodeStr, FOVString, 'seta cg_fov "' + FOVValue + '"', False);
  110.     SaveStringtoFile(ExpandConstant('{src}\Main\config.cfg'), AnsiString(UnicodeStr), False);
  111.   end;
  112.   if LoadStringFromFile(ExpandConstant('{src}\Main\config.cfg'), AnsiStr) then
  113.   begin
  114.     if Fullscreen.Checked then FullscreenValue:= '1' else FullscreenValue:='0';
  115.     UnicodeStr:=AnsiStr;
  116.     StringChangeEx(UnicodeStr, FullscreenString, 'seta r_fullscreen "' + FullscreenValue + '"', False);
  117.     SaveStringtoFile(ExpandConstant('{src}\Main\config.cfg'), AnsiString(UnicodeStr), False);
  118.   end;
  119.   if LoadStringFromFile(ExpandConstant('{src}\Main\config.cfg'), AnsiStr) then
  120.   begin
  121.     UnicodeStr:=AnsiStr;
  122.     StringChangeEx(UnicodeStr, WidthString, 'seta r_customwidth "' + WidthNewValue + '"', False);
  123.     SaveStringtoFile(ExpandConstant('{src}\Main\config.cfg'), AnsiString(UnicodeStr), False);
  124.   end;
  125.   if LoadStringFromFile(ExpandConstant('{src}\Main\config.cfg'), AnsiStr) then
  126.   begin
  127.     UnicodeStr:=AnsiStr;
  128.     StringChangeEx(UnicodeStr, HeightString, 'seta r_customheight "' + HeightNewValue + '"', False);
  129.     SaveStringtoFile(ExpandConstant('{src}\Main\config.cfg'), AnsiString(UnicodeStr), False);
  130.   end;
  131. end;
  132.  
  133. procedure SetCfgRatio();
  134. begin
  135.   GetConfigValues;
  136.   ResolutionDefault:= (WidthValue + 'x' + HeightValue);
  137.   case ResolutionDefault of
  138.   '1920x1080', '1600x900', '1366x768', '1280x720', '1024x600', '960x540', '854x480', '640x360':
  139.     begin
  140.       Ratio.ItemIndex:=0;
  141.       FOVValue:='95';
  142.     end;
  143.   '1920x1020', '1680x1050', '1440x900', '1280x800', '1152x720', '1024x640':
  144.     begin
  145.       Ratio.ItemIndex:=1;
  146.       FOVValue:='90';
  147.     end;
  148.   '1600x1200', '1400x1050', '1280x960', '1152x864', '1024x768', '960x720', '800x600', '720x540', '640x480':
  149.     begin
  150.       Ratio.ItemIndex:=2;
  151.       FOVValue:='80';
  152.     end;
  153.   '1920x1536', '1280x1024':
  154.     begin
  155.       Ratio.ItemIndex:=3;
  156.       FOVValue:='80';
  157.     end;
  158.   end;
  159. end;
  160.  
  161. procedure SetCfgResolution();
  162. var
  163.   i: integer;
  164. begin
  165.   i:=Resolution.Items.IndexOf(ResolutionDefault);
  166.   Resolution.ItemIndex:=i;
  167. end;
  168.  
  169. procedure SetCfgFullscreen();
  170. begin
  171.   if FullscreenValue = '1' then Fullscreen.Checked:=True else Fullscreen.Checked:=False;
  172. end;
  173.  
  174. procedure ChangeAspectRatio(Sender: TObject);
  175. begin
  176.   case Ratio.ItemIndex of
  177.     0:
  178.     begin
  179.       Resolution.Clear;
  180.       Resolution.Items.Add('1920x1080');
  181.       Resolution.Items.Add('1600x900');
  182.       Resolution.Items.Add('1366x768');
  183.       Resolution.Items.Add('1280x720');
  184.       Resolution.Items.Add('1024x600');
  185.       Resolution.Items.Add('960x540');
  186.       Resolution.Items.Add('854x480');
  187.       Resolution.Items.Add('640x360');
  188.       Resolution.ItemIndex:=0;
  189.     end;
  190.     1:
  191.     begin
  192.       Resolution.Clear;
  193.       Resolution.Items.Add('1920x1020');
  194.       Resolution.Items.Add('1680x1050');
  195.       Resolution.Items.Add('1440x900');
  196.       Resolution.Items.Add('1280x800');
  197.       Resolution.Items.Add('1152x720');
  198.       Resolution.Items.Add('1024x640');
  199.       Resolution.ItemIndex:=0;
  200.     end;
  201.     2:
  202.     begin
  203.       Resolution.Clear;
  204.       Resolution.Items.Add('1600x1200');
  205.       Resolution.Items.Add('1400x1050');
  206.       Resolution.Items.Add('1280x960');
  207.       Resolution.Items.Add('1152x864');
  208.       Resolution.Items.Add('1024x768');
  209.       Resolution.Items.Add('960x720');
  210.       Resolution.Items.Add('800x600');
  211.       Resolution.Items.Add('720x540');
  212.       Resolution.Items.Add('640x480');
  213.       Resolution.ItemIndex:=0;
  214.     end;
  215.     3:
  216.     begin
  217.       Resolution.Clear;
  218.       Resolution.Items.Add('1920x1536');
  219.       Resolution.Items.Add('1280x1024');
  220.       Resolution.ItemIndex:=0;
  221.     end;
  222.   end;
  223. end;
  224.  
  225. procedure WriteCustomSettings();
  226. begin
  227.   case Ratio.ItemIndex of
  228.   0:
  229.     StringChangeEx(FOVValue, FOVValue, '95', True);
  230.   1:
  231.     StringChangeEx(FOVValue, FOVValue, '90', True);
  232.   2,3:
  233.     StringChangeEx(FOVValue, FOVValue, '80', True);
  234.   end;
  235. end;
  236.  
  237. procedure Click(Sender: TObject);
  238. var
  239.   ResultCode: Integer;
  240. begin
  241.   case Sender of
  242.   COD:
  243.   begin
  244.   ExecAsOriginalUser(ExpandConstant('{src}\CODSP.exe'), '', ExpandConstant('{src}'), SW_SHOW, ewNoWait, ResultCode);
  245.   WizardForm.Close;
  246.   ExitProcess(1);
  247.   end;
  248.   CODUO:
  249.     begin
  250.   ExecAsOriginalUser(ExpandConstant('{src}\CODSP.exe'), '', ExpandConstant('{src}'), SW_SHOW, ewNoWait, ResultCode);
  251.   WizardForm.Close;
  252.   ExitProcess(1);
  253.   end;
  254.   Settings:
  255.   begin
  256.     SetCfgRatio;
  257.     ChangeAspectRatio(Settings);
  258.     SetCfgResolution;
  259.     SetCfgFullscreen;
  260.     COD.Hide;
  261.     CODUO.Hide;
  262.     Settings.Hide;
  263.     Save.Show;
  264.     RatioText.Show;
  265.     Ratio.Show;
  266.     ResolutionText.Show;
  267.     Resolution.Show;
  268.     FullScreen.Show;
  269.   end;
  270.   Save:
  271.   begin
  272.     WriteCustomSettings;
  273.     COD.Show;
  274.     CODUO.Show;
  275.     Save.Hide;
  276.     Settings.Show;
  277.     RatioText.Hide;
  278.     Ratio.Hide;
  279.     ResolutionText.Hide;
  280.     Resolution.Hide;
  281.     FullScreen.Hide;
  282.     WriteNewValue;
  283.   end;
  284.   LangBtn:
  285.   begin
  286.   if lang='ru' then
  287.     begin
  288.       lang:= 'en';
  289.       LangBtn.Caption:= CustomMessage(lang+'LangText');
  290.       Settings.Caption:= CustomMessage(lang+'SettingsText');
  291.       Save.Caption:= CustomMessage(lang+'SaveText');
  292.       JustExit.Caption:= CustomMessage(lang+'JustExitText');
  293.       RatioText.Caption:= CustomMessage(lang+'RatioText');
  294.       ResolutionText.Caption:= CustomMessage(lang+'ResolutionText');
  295.       FullScreen.Caption:= CustomMessage(lang+'FullScreenText');
  296.     end else begin
  297.       lang:= 'ru';
  298.       LangBtn.Caption:= CustomMessage(lang+'LangText');
  299.       Settings.Caption:= CustomMessage(lang+'SettingsText');
  300.       Save.Caption:= CustomMessage(lang+'SaveText');
  301.       JustExit.Caption:= CustomMessage(lang+'JustExitText');
  302.       RatioText.Caption:= CustomMessage(lang+'RatioText');
  303.       ResolutionText.Caption:= CustomMessage(lang+'ResolutionText');
  304.       FullScreen.Caption:= CustomMessage(lang+'FullScreenText');
  305.     end;
  306.   end;
  307.   JustExit:
  308.     begin
  309.       WizardForm.Close;
  310.       ExitProcess(1);
  311.     end;
  312.   end;
  313. end;
  314.  
  315. procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
  316. begin
  317.   if CurPageID=wpReady then
  318.   Confirm := False;
  319. end;
  320.  
  321. procedure HideDefaultElements();
  322. begin
  323.   SetWindowLong(WizardForm.handle, GWL_STYLE, GetWindowLong(WizardForm.handle, GWL_STYLE)and(not WS_MINIMIZEBOX)and(not WS_MAXIMIZEBOX));
  324.   with WizardForm do begin
  325.   PageNameLabel.Hide;
  326.   PageDescriptionLabel.Hide;
  327.   ReadyLabel.Hide;
  328.   ReadyMemo.Hide;
  329.   ReadyPage.Hide;
  330.   MainPanel.Hide;
  331.   Bevel.Hide;
  332.   Bevel1.Hide;
  333.   InnerNotebook.Hide;
  334.   end;
  335. end;
  336.  
  337. procedure MakeImage();
  338. begin
  339.   ExtractTemporaryFile('WizardForm.BitmapImage1.bmp');
  340.   Image := TBitmapImage.Create(WizardForm);
  341.   with Image do
  342.   begin
  343.     Bitmap.LoadFromFile(ExpandConstant('{tmp}\WizardForm.BitmapImage1.bmp'));
  344.     Parent := WizardForm.InnerPage;
  345.     Left := ScaleX(0);
  346.     Top := ScaleY(0);
  347.     Width := ScaleX(400);
  348.     Height := ScaleY(200);
  349.     Stretch:=True;
  350.     OnMouseDown:=@LabelOnMouseDown;
  351.     BringtoFront;
  352.   end;
  353. end;
  354.  
  355. procedure MakeCustomButtons();
  356. begin
  357.  COD := TNewButton.Create(WizardForm);
  358.   with COD do
  359.   begin
  360.     Parent := WizardForm;
  361.     Left := ScaleX(5);
  362.     Top := ScaleY(200+5);
  363.     Width := ScaleX((400-15)/2);
  364.     Height := ScaleY(300-205-5-25-5);
  365.     Caption := 'Call of Duty';
  366.     OnClick:=@Click;
  367.     BringToFront;
  368.   end;
  369.   COD.TabOrder := 0;
  370.  
  371.  CODUO := TNewButton.Create(WizardForm);
  372.   with CODUO do
  373.   begin
  374.     Parent := WizardForm;
  375.     Left := ScaleX(400-400/2+5);
  376.     Top := ScaleY(200+5);
  377.     Width := ScaleX((400-15)/2);
  378.     Height := ScaleY(300-205-5-25-5);
  379.     Caption := 'Call of Duty: United Offensive';
  380.     OnClick:=@Click;
  381.     BringToFront;
  382.   end;
  383.   CODUO.TabOrder := 1;
  384.  
  385.  Settings := TNewButton.Create(WizardForm);
  386.   with Settings do
  387.   begin
  388.     Parent := WizardForm;
  389.     Left := ScaleX(5);
  390.     Top := ScaleY(300-30);
  391.     Width := ScaleX(130);
  392.     Height := ScaleY(25);
  393.     Caption := 'Íàñòðîéêè';
  394.     BringToFront;
  395.     OnClick:=@Click;
  396.   end;
  397.   Settings.TabOrder := 2;
  398.  
  399.  Save := TNewButton.Create(WizardForm);
  400.   with Save do
  401.   begin
  402.     Parent := WizardForm;
  403.     Left := ScaleX(5);
  404.     Top := ScaleY(300-30);
  405.     Width := ScaleX(130);
  406.     Height := ScaleY(25);
  407.     Caption := 'Ñîõðàíèòü';
  408.     BringToFront;
  409.     Hide;
  410.     OnClick:=@Click;
  411.   end;
  412.   Save.TabOrder := 2;
  413.  
  414.   LangBtn := TNewButton.Create(WizardForm);
  415.   with LangBtn do
  416.   begin
  417.     Parent := WizardForm;
  418.     Left := ScaleX(400/2-15);
  419.     Top := ScaleY(300-30);
  420.     Width := ScaleX(30);
  421.     Height := ScaleY(25);
  422.     Caption := 'EN';
  423.     BringToFront;
  424.     OnClick:=@Click;
  425.   end;
  426.   LangBtn.TabOrder := 3;
  427.  
  428.  
  429.  JustExit := TNewButton.Create(WizardForm);
  430.   with JustExit do
  431.   begin
  432.     Parent := WizardForm;
  433.     Left := ScaleX(400-5-130);
  434.     Top := ScaleY(300-30);
  435.     Width := ScaleX(130);
  436.     Height := ScaleY(25);
  437.     Caption := 'Âûéòè';
  438.     OnClick:=@Click;
  439.   end;
  440.   JustExit.TabOrder := 4;
  441. end;
  442.  
  443. procedure MakeComboBox();
  444. begin
  445.   RatioText := TLabel.Create(WizardForm);
  446.   with RatioText do
  447.   begin
  448.     Parent := WizardForm.InnerPage;
  449.     Caption := 'Ñîîòíîøåíèå ñòîðîí ýêðàíà:';
  450.     Font.Style:=[fsBold];
  451.     Transparent := False;
  452.     Left := ScaleX(5);
  453.     Top := ScaleY(205);
  454.     Width := ScaleX(200);
  455.     Height := ScaleY(20);
  456.     Hide;
  457.   end;
  458.   Ratio := TNewComboBox.Create(WizardForm);
  459.   with Ratio do
  460.   begin
  461.     Parent := WizardForm.InnerPage;
  462.     SetBounds(ScaleX(5), ScaleY(205+20), ScaleX(400/2-15), ScaleX(15));
  463.     Style := csDropDownList;
  464.     Items.Add('16:9');
  465.     Items.Add('16:10');
  466.     Items.Add('4:3');
  467.     Items.Add('5:4');
  468.     ItemIndex := 0;
  469.     OnChange:= @ChangeAspectRatio;
  470.     Hide;
  471.   end;
  472.   Ratio.TabOrder := 0;
  473.  
  474.   ResolutionText := TLabel.Create(WizardForm);
  475.   with ResolutionText do
  476.   begin
  477.     Parent := WizardForm.InnerPage;
  478.     Caption := 'Ðàçðåøåíèå ýêðàíà:';
  479.     Font.Style:=[fsBold];
  480.     Transparent := False;
  481.     Left := ScaleX(400/2+5);
  482.     Top := ScaleY(205);
  483.     Width := ScaleX(200);
  484.     Height := ScaleY(20);
  485.     Hide;
  486.   end;
  487.  
  488.   Resolution := TNewComboBox.Create(WizardForm);
  489.   with Resolution do
  490.   begin
  491.     Parent := WizardForm.InnerPage;
  492.     SetBounds(ScaleX(400/2+5), ScaleY(205+20), ScaleX(400/2-10), ScaleX(15));
  493.     Style := csDropDownList;
  494.     Items.Add('1920x1080');
  495.     Items.Add('1600x900');
  496.     Items.Add('1366x768');
  497.     Items.Add('1280x720');
  498.     Items.Add('1024x576');
  499.     Items.Add('960x540');
  500.     Items.Add('854x480');
  501.     Items.Add('640x360');
  502.     ItemIndex := 0;
  503. //    Resolution.OnChange:= @InterfaceLangComboBoxChanged;
  504.     Hide;
  505.   end;
  506.   Resolution.TabOrder := 1;
  507.  
  508.   FullScreen := TNewCheckBox.Create(WizardForm);
  509.   with FullScreen do
  510.   begin
  511.     Parent := WizardForm.InnerPage;
  512.     Left := ScaleX(5);
  513.     Top := ScaleY(205+20+15+10);
  514.     Width := ScaleX(400-10);
  515.     Height := ScaleY(17);
  516.     Caption := 'Çàïóñê èãðû â ïîëíîýêðàííîì ðåæèìå';
  517.     Hide;
  518.   end;
  519.   FullScreen.TabOrder := 2;
  520.  
  521. end;
  522.  
  523. procedure InitializeWizard();
  524. begin
  525.   with WizardForm do begin
  526.     BorderStyle:=bsNone;
  527.     ClientWidth:=ScaleX(400);
  528.     ClientHeight:=ScaleY(300);
  529.     Caption:='Call of Duty Launcher';
  530.     SettingsPage := CreateCustomPage(wpReady, 'ISCustomPage1_Caption', 'ISCustomPage1_Description');
  531.   end;
  532.   HideDefaultElements;
  533.   MakeCustomButtons;
  534.   MakeImage;
  535.   MakeComboBox;
  536.   if ActiveLanguage='ru' then begin
  537.     lang:= 'ru';
  538.     langBtn.Caption:= CustomMessage(lang+'LangText');
  539.   end else begin
  540.     lang:= 'en';
  541.     langBtn.Caption:= CustomMessage(lang+'LangText');
  542.   end;
  543.   if FileExists(ExpandConstant('{src}\CODSP.exe')) then COD.Enabled else COD.Enabled:=False;
  544.   if FileExists(ExpandConstant('{src}\CODUOSP.exe')) then CODUO.Enabled else CODUO.Enabled:=False;
  545. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement