Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 20-02-2020, 22:51
Gupta Gupta is offline
Banned
 
Join Date: Aug 2016
Location: https://t.me/pump_upp
Posts: 399
Thanks: 139
Thanked 716 Times in 231 Posts
Gupta is on a distinguished road
Send a message via ICQ to Gupta Send a message via AIM to Gupta Send a message via Yahoo to Gupta
current GetFlayByLine function is pretty hard to understand, reading the description can't we do it in this way;
and please whoever is developing current CIU please try to use meaningful variable names. L1 LN S1 doesn't make any sense
Code:
function GetFlagByLine: TArrayOfInteger;
var
  FlagDist, CurrFlagCount: String;
  I, LangCount, LangUsed, LastLineCount: Integer;
begin
  LangCount := LangNumber;
  LangUsed  := 0;
  LastLineCount := 0;
  SetArrayLength(Result, 0);
  FlagDist := GetValStr('LangBox', 'FlagByLine', '0') + ',';
  while (Length(FlagDist) > 0) and (LangUsed < LangCount) do begin
    CurrFlagCount := Trim(Copy(FlagDist, 0, Pos(',', FlagDist) - 1));
    FlagDist := Copy(FlagDist, Pos(',', FlagDist) + 1, Length(FlagDist));
    SetArrayLength(Result, GetArrayLength(Result) + 1);
    I := GetArrayLength(Result) - 1;
    Result[I] := StrToInt(CurrFlagCount);
    if Result[I] > LangCount - LangUsed then
        Result[I] := LangCount - LangUsed;
    LangUsed := LangUsed + Result[I];
    LastLineCount := Result[I];
  end;
  if LangUsed <> LangCount then
  begin
      if LastLineCount = 0 then
      begin
        SetArrayLength(Result, GetArrayLength(Result) + 1);
        Result[GetArrayLength(Result) - 1] := LangCount - LangUsed;
      end else begin
        while LangUsed <> LangCount do
        begin
            SetArrayLength(Result, GetArrayLength(Result) + 1);
            I := GetArrayLength(Result) - 1;
            Result[I] := LangCount - LangUsed;
            if Result[I] > LastLineCount then
                Result[I] := LastLineCount;
            LangUsed := LangUsed + Result[I];
        end;
      end;
  end;
end;

Last edited by Gupta; 20-02-2020 at 23:01.
Reply With Quote
Sponsored Links
  #2  
Old 21-02-2020, 07:38
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,081
Thanks: 1,844
Thanked 2,316 Times in 791 Posts
Cesar82 is on a distinguished road
Quote:
Originally Posted by Gupta View Post
current GetFlayByLine function is pretty hard to understand, reading the description can't we do it in this way;
and please whoever is developing current CIU please try to use meaningful variable names. L1 LN S1 doesn't make any sense
I am currently developing on the CIU script.
At the time KaktoR didn't know much about programming and I helped him to solve some problems in the script and then he gave me the opportunity to continue editing the script.
KaktoR tests and takes care of the compressors and shares the versions I send to him.
I use variables S1, L1, etc so that the code is smaller and better visualization of most of the code in the Inno Setup interface. But each variable has its meaning in relation to what it does.
S1, S2, S3 = Temporary Strings.
FL = Flags per line.
FC = Flags count.
LN = Language Number.

In this GetFlagByLine function, if the number of parameters in FlagsByLine= key (setup.ini) does not cover all flags, the next lines will have the same amount as the previous one. The same is true in the GetFlagBoxAlign function.
Example containing 17 flags.
FlagsByLine=3,2,5
Results:
line 1 with 3 flags
line 2 with 2 flags
line 3 with 5 flags
line 4 with 5 flags
line 5 with 2 flags (3 + 2 + 5 + 5 + 2 = 17)

Look the test with my code in the attached file.
It avoids several errors due to lack of information that can happen if the user does not configure Setup.ini correctly.
It also only makes it possible to activate the BOX mode and no other keys are needed to create a square with the flags.
In my code it is also possible to insert empty lines between the lines with flags, as for example for 16 languages in 4 lines of flags and 3 empty lines.
FlagsByLine=4,0,4,0,4,0,4
Attached Files
File Type: 7z FlagByLine_Test.7z (1.4 KB, 12 views)

Last edited by Cesar82; 21-02-2020 at 09:26.
Reply With Quote
  #3  
Old 21-02-2020, 09:19
Gupta Gupta is offline
Banned
 
Join Date: Aug 2016
Location: https://t.me/pump_upp
Posts: 399
Thanks: 139
Thanked 716 Times in 231 Posts
Gupta is on a distinguished road
Send a message via ICQ to Gupta Send a message via AIM to Gupta Send a message via Yahoo to Gupta
Quote:
Originally Posted by Cesar82 View Post
I am currently developing on the CIU script.
At the time KaktoR didn't know much about programming and I helped him to solve some problems in the script and then he gave me the opportunity to continue editing the script.
KaktoR tests and takes care of the compressors and shares the versions I send to him.
I use variables S1, L1, etc so that the code is smaller and better visualization of most of the code in the Inno Setup interface. But each variable has its meaning in relation to what it does.
S1, S2, S3 = Temporary Strings.
FL = Flags per line.
FC = Flags count.
LN = Language Number.

In this GetFlagByLine function, if the number of parameters in FlagsByLine= key (setup.ini) does not cover all flags, the next lines will have the same amount as the previous one. The same is true in the GetFlagBoxAlign function.
Example containing 17 flags.
FlagsByLine=3,2,5
Results:
line 1 with 3 flags
line 2 with 2 flags
line 3 with 5 flags
line 4 with 5 flags
line 5 with 2 flags (3 + 2 + 5 + 5 + 2 = 17)

Look the test with my code in the attached file.
It avoids several errors due to lack of information that can happen if the user does not configure Setup.ini correctly.
It also only makes it possible to activate the BOX mode and no other keys are needed to create a square with the flags.
You should write some comments, the code I shared above do the same but imho its more concise and understandable I'm not good with naming variable but it still imho it does the job pretty well
I still didn't get why you used sqrt and other function
Will come back to you on tomorrow
Reply With Quote
  #4  
Old 21-02-2020, 20:05
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,081
Thanks: 1,844
Thanked 2,316 Times in 791 Posts
Cesar82 is on a distinguished road
Quote:
Originally Posted by Gupta View Post
I still didn't get why you used sqrt and other function
It is used to calculate and create a square Box with the flags if FlagByLine key (in setup.ini) is empty or does not exist.
Code:
  if GetArrayLength(Result) = 0 then begin {If no results were obtained, it calculates the quantity to creates a square with the number of flags in the project.}
    FL := Trunc(Sqrt(LN)) + (Trunc(Sqrt(LN)) mod 2);
    SetArrayLength(Result, Trunc(Sqrt(LN)) + 1);
    for I := 0 to GetArrayLength(Result) - 1 do begin
      if FC + FL > LN then
        FL := LN - FC;
      Result[I] := FL;
      FC := FC + FL
    end;
  end;
This part adds only the numeral characters from temporary variable S2 to S3.
Code:
    S3 := '';
    for I := 1 to Length(S2) do
      if StrToIntDef(S2[I], 10) < 10 then
        S3 := S3 + S2[I];
This part avoids including a line with zero flags at the top (LangBox Top).
Code:
    if (S3 <> '') and (LN > FC)
    and ((StrToIntDef(S3, 0) > 0) or (GetArrayLength(Result) > 0)) then
    begin
If the flags of the lines informed in FlagsByLine remain, this part creates new lines with the same number of flags as the previous line.
Code:
  while (LN - FC > 0) and (FL > 0) do begin
    if FC + FL > LN then
      FL := LN - FC;
    SetArrayLength(Result, GetArrayLength(Result) + 1);
    Result[GetArrayLength(Result) - 1] := FL;
    FC := FC + FL
  end;
This part creates a new line with the remaining flags at the end.
It also removes an empty line of flags from the end of the box for the correct CENTER alignment.
Code:
  if GetArrayLength(Result) > 0 then begin
    if LN - FC > 0 then
      Result[GetArrayLength(Result) - 1] := FL + LN - FC;
    if Result[GetArrayLength(Result) - 1] = 0 then
      SetArrayLength(Result, GetArrayLength(Result) - 1);
  end;
See the example script I attached in the previous post.
Just change the values within GetValStr and SetArrayLength(Languages, 16).
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Game Installer Designer by altef_4 altef_4 Conversion Tutorials 236 28-05-2021 02:54
PREVIEW | Transparent Installer + T_Installer Designer (FMX) STB13 Conversion Tutorials 9 08-12-2018 14:49
CIUv2 Designer Alpha 2 jamel2013 Conversion Tutorials 8 21-02-2016 03:42



All times are GMT -7. The time now is 00:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com