Archive: I would make an DropList for a custom page


I would make an DropList for a custom page
Hi
I make an installer for counter-strike and I would, that the user can choose on an custom page which netsettigs he has.

This is my netsettings.ini:

[Settings]
NumFields=1

[Field 1]
Type=Droplist
ListItems=LAN|56K Modem|ISDN|D-ISDN|S-DSL|A-DSL|Cable |Q-DSL|DSL mit FP
Left=2
Right=109
Top=1
Bottom=126


Here is an example:

http://www.cs-expert.de/netsettings.php

How can I specify what happens whith the setting LAN, 56KMODEM...

Example

This is the code for lan:

Lan:
[CODE]
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\Lan.cfg" "$INSTDIR\cstrike\userconfig.cfg"[CODE]


I hope you can understand what I mean. My english isn't very good

On the page leave function you need to read the State with ReadINIStr.

-Stu


Hy thank you for the answer but I don't now what I should do now.

Can you give me an expamle please?


Page Custom showFunc leaveFunc

Function leaveFunc
ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "LAN" 0 notLAN
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\Lan.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notLAN:
FunctionEnd


-Stu

Hy Afrow UK

thank you!

You always help me.

But it isn't work. There comes always the error


ReadINIStr $R0 [Field 1]:State from $PLUGINSDIR\ioFile.ini
StrCmp expects 3-4 parameters, got 5.
Usage: StrCmp str1 str2 label_to_goto_if_equal [label_to_goto_if_not]
Error in script "H:\Eigene Dateien\Programme & Games\Programme\Programme\NSIS\Projekte\Counter-Strike 1.6\Counter-Strike 1.6 Erweiterungs System\Counter-Strike 1.6 Erweiterungs System.nsi" on line 2062 -- aborting creation process



This is my Code:


Page custom NetsettingsPage PageLeaveNetsettings
ReserveFile "netsettings.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "netsettings.ini"


; Page Leave Netsettings
Function PageLeaveNetsettings

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "LAN" 0 notLAN
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\Lan.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notLAN:


ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "56K Modem" 0 not56K Modem
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\56K Modem.cfg" "$INSTDIR\cstrike\userconfig.cfg"
not56K Modem:


ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "ISDN" 0 notISDN
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\ISDN.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notISDN:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "D-ISDN" 0 notD-ISDN
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\D-ISDN.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notD-ISDN:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "S-DSL" 0 notS-DSL
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\S-DSL.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notS-DSL:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "A-DSL" 0 notA-DSL
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\A-DSL.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notA-DSL:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "Cable" 0 notCable
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\Cable.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notCable:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "Q-DSL" 0 notQ-DSL
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\Q-DSL.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notQ-DSL:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "DSL mit FP" 0 notDSL mit FP
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\DSL mit FP.cfg" "$INSTDIR\cstrike\userconfig.cfg"
notDSL mit FP:

FunctionEnd


This is the code for the netsetting page

Ah sorry i've forgot to write the code from the Netsettings Page



Function NetsettingsPage
!insertmacro SectionFlagIsSet ${Section2} ${SF_SELECTED} ShowPage SkipPage
ShowPage:

!insertmacro MUI_HEADER_TEXT "Konfiguration des Erweiterungs System" "Wählen Sie, mit welcher Verbindung sie spielen."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "netsettings.ini"

SkipPage:

FunctionEnd


there's a space in StrCmp $R0 "56K Modem" 0 not56K Modem, so it's being interpreted as 5 parameters. it should be "not56K-Modem" instead.

same with "notDSL mit FP".


Hy,

thank you it compiles successfully. And the custom page starts too. But the e.g. LAN.cfg does't connect with the userconfig.cfg. Is it possible that file join doesn't works with *.cfg ?

What could I do that it works?

Thank you

Marc


Hy,

thank you it compiles successfully. And the custom page starts too. But the e.g. LAN.cfg does't connect with the userconfig.cfg. Is it possible that file join doesn't works with *.cfg ?

What could I do that it works?

Thank you

Marc


Just a guess but it could be because of this:
${FileJoin} "$INSTDIR\cstrike\userconfig.cfg" "$INSTDIR\Infos\Cable.cfg" "$INSTDIR\cstrike\userconfig.cfg"

The function will probably be reading from userconfig.cfg and trying to write to userconfig.cfg at the same time which will not work.
Make the last parameter "$INSTDIR\cstrike\userconfig.cfg.x" and then do:

Delete "$INSTDIR\cstrike\userconfig.cfg"
Rename "$INSTDIR\cstrike\userconfig.cfg.x" "$INSTDIR\cstrike\userconfig.cfg"


-Stu

Hy i've tried to make it with copy files:


; Netsettings Page
Function NetsettingsPage
!insertmacro SectionFlagIsSet ${Section3} ${SF_SELECTED} ShowPage SkipPage
ShowPage:

!insertmacro MUI_HEADER_TEXT "Konfiguration des Erweiterungs System" "Wählen Sie, mit welcher Verbindung sie spielen."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "netsettings.ini"

SkipPage:

FunctionEnd

; Page Leave Netsettings
Function PageLeaveNetsettings

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "LAN" 0 notLAN
CopyFiles /silent $INSTDIR\Infos\Netsettings\LAN\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\LAN\netsettings.cfg $INSTDIR\cstrike_german
notLAN:


ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "56K Modem" 0 not56K_Modem
CopyFiles /silent $INSTDIR\Infos\Netsettings\56K_Modem\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\56K_Modem\netsettings.cfg $INSTDIR\cstrike_german
not56K_Modem:


ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "ISDN" 0 notISDN
CopyFiles /silent $INSTDIR\Infos\Netsettings\ISDN\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\ISDN\netsettings.cfg $INSTDIR\cstrike_german
notISDN:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "D-ISDN" 0 notD-ISDN
CopyFiles /silent $INSTDIR\Infos\Netsettings\D-ISDN\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\D-ISDN\netsettings.cfg $INSTDIR\cstrike_german
notD-ISDN:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "S-DSL" 0 notS-DSL
CopyFiles /silent $INSTDIR\Infos\Netsettings\S-DSL\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\S-DSL\netsettings.cfg $INSTDIR\cstrike_german
notS-DSL:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "A-DSL" 0 notA-DSL
CopyFiles /silent $INSTDIR\Infos\Netsettings\A-DSL\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\A-DSL\netsettings.cfg $INSTDIR\cstrike_german
notA-DSL:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "Cable" 0 notCable
CopyFiles /silent $INSTDIR\Infos\Netsettings\Cable\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\Cable\netsettings.cfg $INSTDIR\cstrike_german
notCable:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "Q-DSL" 0 notQ-DSL
CopyFiles /silent $INSTDIR\Infos\Netsettings\Q-DSL\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\Q-DSL\netsettings.cfg $INSTDIR\cstrike_german
notQ-DSL:

ReadINIStr $R0 "$PLUGINSDIR\ioFile.ini" "Field 1" "State"
StrCmp $R0 "DSL mit FP" 0 notDSL_mit_FP
CopyFiles /silent $INSTDIR\Infos\Netsettings\DSL_mit_FP\netsettings.cfg $INSTDIR\cstrike
CopyFiles /silent $INSTDIR\Infos\Netsettings\DSL_mit_FP\netsettings.cfg $INSTDIR\cstrike_german
notDSL_mit_FP:

FunctionEnd


But it doesn't work. It doesn't copy the netsettings.cfg.

Do anybody know why it doesn't work.

You need to create directories first for the CopyFiles target directories (example: "$INSTDIR\cstrike"). Use CreateDirectory instruction to create those directories. Or maybe the files indicated to copy don't exist. Please explain the situation more, like, put a MessageBox instruction on the start of the page leave function and verify which files or directories exist or not.


Hy all the directories exists.

And all Files, too.

But I don't know why it isn't works

I've made an short installer.

Could anybody show why it doesn't works ?

Thank you


Haven't you an idea?

Please help me


Try this.


Hy thank you it works (-: (-:

Is it possible, that the user can only click on next when he has choose an option?

In the netsettings.ini the State is :

State=

So there is an white field and when this white field is active the user shouldn't not click on next.

How can I do this ?

Thank you


In the custom page leave function, call Abort if the state is blank. Maybe also show a message box with the error to the user.


Hy isn't it possible only to make the next botton transparent and when the user has choose an option he can click on next?

Like in the Install page. There the user can't click on abort.

Can you give me an example ?


Thank you


PLS HELP ME


Search the forum- this question has been asked before.


Hy I've search but I can't find it.

My english isn't very good so it is difficult to understand.

Pls help me.

Can you write the code in the drop list.nsi which iceman_k has writes?

Pls it would be very friendly when you help me.