Announcement

Collapse
No announcement yet.

How to beautify the way my code works?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to beautify the way my code works?

    Herro,

    Is there some way I can beautify the way I do this, with like buttons, themes and stuff? Instead of having it being like this (code below):


    Code:
    StatusDlg.Show(MB_ICONNONE, false);
    
    run = true
    
    while ( run == true ) do
    
    result_1 = Dialog.Input("Which Warcraft do you want to install? 1.26 or 1.27 (enter exact)", "Answer", "", MB_ICONQUESTION);
    
    if ( String.ToNumber(result_1) == 1.26 ) then
    
    HTTP.DownloadSecure("https://mydomain.com/file_1.exe", "C:\\Users\\akeno\\Desktop\\Setup Factory Output\\HookSuccess.rar", MODE_BINARY, 20, 443, nil, nil, BytesRead);
    run = false
    
    end
    
    if ( String.ToNumber(result_1) == 1.27 ) then
    
    HTTP.DownloadSecure("https://mydomain.com/file_2.exe", "C:\\Users\\akeno\\Desktop\\Setup Factory Output\\HookSuccess.rar", MODE_BINARY, 20, 443, nil, nil, BytesRead);
    run = false
    
    end
    
    if ( String.ToNumber(result_1) ~= 1.26 and String.ToNumber(result_1) ~= 1.27 ) then
    
    Dialog.Message("Error.", "Your input was not 1.26 or 1.27. The input needs to be exact matching. Try again.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    end
    
    if ( run == false ) then
    
    result_2 = Dialog.Input("Enter G if you wish to install again, else just click Cancel.", "Answer", "", MB_ICONQUESTION);
    
    end
    
    if ( result_2 == 'G' ) then
    
    run = true
    
    end
    
    end
    And while we are at it, how can I make this window more "beautiful" too? Like customize it, adding images and stuff.
    Click image for larger version

Name:	ocr (369).png
Views:	319
Size:	1.8 KB
ID:	305486

    Thanks in advanceee ~

  • #2
    Okay so I changed the code, I'll put that here first before explaining my intention and everything.

    Code:
    StatusDlg.Show(MB_ICONNONE, false);
    run = true
    result_2 = 'G'
    
    while ( run == true ) do
    
    result_1 = Dialog.Input("Which Game version do you want to install? 1.26 or 1.27 (enter exact)", "Answer", "", MB_ICONQUESTION);
    
    
    if ( String.ToNumber(result_1) == 1.26 ) then
    HTTP.DownloadSecure("https://domain.com/test.gif", "C:\\output\\HookSuccess_1.gif", MODE_BINARY, 20, 443, nil, nil, nil);
    run = false
    end
    
    if ( String.ToNumber(result_1) == 1.27 ) then
    HTTP.DownloadSecure("https://domain.com/test.gif", "C:\\output\\HookSuccess_2.gif", MODE_BINARY, 20, 443, nil, nil, nil);
    run = false
    end
    
    if ( String.ToNumber(result_1) ~= 1.26 and String.ToNumber(result_1) ~= 1.27 ) then
    Dialog.Message("Error.", "Your input was not 1.26 or 1.27. The input needs to be exact matching. Try again.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    
    if ( run == false ) then
    result_2 = Dialog.Input("Enter G if you wish to install again, else just click Cancel.", "Answer", "", MB_ICONQUESTION);
    end
    
    if ( result_2 == 'G' ) then
    run = true
    else
    Application.Exit(0);StatusDlg.Show(MB_ICONNONE, false);
    end
    
    end

    Comment


    • #3
      So I wish to make an installer where I can download several different game versions from my website. If I were to put them all in the exe, it would become really big and I would have to split them, which I don't want. I want it to be one, easy and really portable installer. I can somehow manage that by using this code, but I would love to customize the installer, adding images and so much more. Probably even using the dialogs, but I just started today and have no idea what to do. Does anyone have any kind of tips? The dialogs I have right now is kind of bland and boring to look at.

      Comment


      • #4
        You can design and add your own themes and use them in Setup Factory. You can also resize the dialogs as needed, and use custom fonts. While the standard themes are clearly conservative, if you want, you can get much more colorful.

        Click image for larger version

Name:	SCRN-2020-09-18-01.png
Views:	195
Size:	54.0 KB
ID:	305495

        Ulrich

        Comment


        • #5
          Yeah, the problem is that when I download, I get the statusdialog (which looks like this):
          Click image for larger version

Name:	ocr (372).png
Views:	196
Size:	5.6 KB
ID:	305500
          Is there I way I can use the one in themes instead? Note, I use HTTP.Download/Secure action, so it uses the StatusDialog. However, I would like to use the statusbar/dialog in themes, instead of this one. Do you have any idea how I can achieve that?

          Comment


          • #6
            For reference, I mean this one here:
            Click image for larger version

Name:	ocr (373).png
Views:	278
Size:	54.2 KB
ID:	305502

            My code looks like this (almost similar to the one in the documentation):

            Code:
            function ShowStatusWindow()
            
            StatusDlg.Show(MB_ICONINFORMATION, false);
            
            StatusDlg.ShowCancelButton(true, "Stop Download");
            end
            
            
            
            function DownloadStatus (BytesRead, FileSize, TransferRate, SecondsLeft, SecondsLeftFormat, Message)
            
            StatusDlg.SetMeterRange(0, 65534);
            
            StatusDlg.SetMeterPos((BytesRead / FileSize) * 65534);
            
            
            if StatusDlg.IsCancelled() then
            
            StatusDlg.Hide();
            return false;
            else
            
            if FileSize == 0 then
            
            StatusDlg.SetStatusText("Size Unknown (" .. Math.Floor(BytesRead/1024/1024) .. "MB downloaded so far)");
            elseif FileSize > 0 then
            
            StatusDlg.SetStatusText("Downloaded " .. Math.Floor(BytesRead/1024/1024) .. " MB of " .. Math.Floor(FileSize/1024/1024) .. " MB");
            end
            
            if (Message == "") and (BytesRead > 0) and (BytesRead == FileSize or FileSize == 0) then
            
            StatusDlg.Hide();
            
            Dialog.Message("Download Complete", Math.Floor(BytesRead/1024/1024) .. " MB have been downloaded");
            return false;
            else
            
            return true;
            end
            end
            end
            
            
            
            ShowStatusWindow();
            
            HTTP.DownloadSecure("https://download171.uploadhaven.com/1/application/x-msi/a0wNuyyZAceCrY2aPSdyTBVApbTWQWCjUz0gwJQ0.msi?key=Z Qc2TIBiv5bvHYASgBiuSQ&expire=1600500401&filename=W arcraftIIIIrinaSetup.msi", SessionVar.Expand("%AppFolder%\\Moonie.zip"), MODE_BINARY, 20, 443, nil, nil, DownloadStatus);

            Comment


            • #7
              Check the documentation how to use the Progress Bar screen. You can use it to show the progress of downloads instead of using the StatusDlg, with the aid of a custom callback function. The help file has examples.

              Ulrich

              Comment


              • #8
                Originally posted by Ulrich View Post
                Check the documentation how to use the Progress Bar screen. You can use it to show the progress of downloads instead of using the StatusDlg, with the aid of a custom callback function. The help file has examples.

                Ulrich
                Sorry for late response Ulrich, I'm still not exactly sure how to achieve what you suggested

                Comment


                • #9
                  Please show that you purchased a license for Setup Factory by associating your forum username with your customer account and I will assist.

                  Ulrich

                  Comment

                  Working...
                  X