- NSIS Discussion
- I would make an DropList for a custom page
Archive: I would make an DropList for a custom page
Sp33dy Gonzale$
23rd July 2005 08:43 UTC
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
Afrow UK
23rd July 2005 10:58 UTC
On the page leave function you need to read the State with ReadINIStr.
-Stu
Sp33dy Gonzale$
23rd July 2005 11:45 UTC
Hy thank you for the answer but I don't now what I should do now.
Can you give me an expamle please?
Afrow UK
23rd July 2005 17:11 UTC
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
Sp33dy Gonzale$
24th July 2005 13:17 UTC
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
Sp33dy Gonzale$
24th July 2005 13:20 UTC
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
Yathosho
24th July 2005 14:27 UTC
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".
Sp33dy Gonzale$
24th July 2005 15:29 UTC
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
Sp33dy Gonzale$
24th July 2005 16:36 UTC
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
Afrow UK
24th July 2005 19:55 UTC
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
Sp33dy Gonzale$
25th July 2005 08:02 UTC
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.
deguix
25th July 2005 11:37 UTC
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.
Sp33dy Gonzale$
25th July 2005 13:05 UTC
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
Sp33dy Gonzale$
27th July 2005 19:51 UTC
Haven't you an idea?
Please help me
iceman_k
27th July 2005 21:36 UTC
Try this.
Sp33dy Gonzale$
28th July 2005 11:24 UTC
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
iceman_k
28th July 2005 16:23 UTC
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.
Sp33dy Gonzale$
29th July 2005 07:53 UTC
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
Sp33dy Gonzale$
30th July 2005 10:04 UTC
PLS HELP ME
iceman_k
30th July 2005 13:12 UTC
Search the forum- this question has been asked before.
Sp33dy Gonzale$
31st July 2005 09:25 UTC
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.