View Full Version : Select file to install setup??
redpanama
12-31-2009, 07:16 AM
I need users to locate file (hl.exe), to install my setup. So i changed this:
Screen: Select Install Folder (On Ctrl Message)
-- from _SUF70_Global_Functions.lua:
-- display a folder browse dialog to change the path in the install folder field
g_EditFieldFolderBrowse(CTRL_EDIT_FOLDER, strPrompt);
to this:
-- from _SUF70_Global_Functions.lua:
-- display a folder browse dialog to change the path in the install folder field
Dialog.FileBrowse(true, "Select hl.exe", _DesktopFolder, "Half-Life (*hl.exe*)|*hl.exe*|", "hl", "exe", false, false, CTRL_EDIT_FOLDER, strPrompt);
But it doesn't work right, and it can't retrieve folder path. Can anyone help me to make it work.
Thanks in advance!
PS. I'm scripting noob :D
redpanama
12-31-2009, 09:33 AM
lil' progress here :P
-- These actions are triggered by the controls on the screen.
if ((e_CtrlID == CTRL_BUTTON_BROWSE)
and (e_MsgID == MSGID_CLICKED)) then
--The first edit ctrl's button was clicked.
local tbEditProps = DlgEditField.GetProperties(CTRL_EDIT_FOLDER);
if(not tbEditProps) then
-- The edit field is not accessible or does not exist
return;
end
-- browse for the file loc
result = Dialog.FileBrowse(true, "Locate hl.exe", _DesktopFolder, "Half-Life Executable (*hl.exe)|*hl.exe|", "hl.exe", "exe", false, true);
-- if the result if valid then update the edit field
if((result ~= nil) and (result[1] ~= "CANCEL")) then
--get the first selected file
tbEditProps.Text = result[1];
--update the edit field
DlgEditField.SetProperties(CTRL_EDIT_FOLDER, tbEditProps)
end
end
if(e_CtrlID == CTRL_EDIT_FOLDER) then
-- the control message is from the install folder field...
-- if it's an OnChanged message (i.e. the installation path has changed)
-- recalculate the space available on the selected drive
if (e_MsgID == MSGID_ONCHANGED) then
strInstallFolderPath = e_Details.Text;
-- from _SUF70_Global_Functions.lua:
-- calculate the amount of disk space available on the selected drive
_SpaceAvailable = g_GetFreeSpaceInBytes(strInstallFolderPath);
-- set %SpaceAvailable% to a string with an appropriate unit of measurement (e.g. "0 bytes")
SessionVar.Set("%SpaceAvailable%", String.GetFormattedSize(_SpaceAvailable) );
-- from _SUF70_Global_Functions.lua:
-- update the 'Space available on selected drive:' message (expands any session variables in it)
g_UpdateStaticTextCtrl(CTRL_STATICTEXT_SPACEAVAILA BLE, "IDS_CTRL_STATICTEXT_SPACEAVAILABLE");
end
end
but now it shows "D:\GAMES\HL\hl.exe in edit field instead of "D:\GAMES\HL"
:S
jassing
12-31-2009, 04:20 PM
After your user locates the file use
local tFileParts = String.SplitPath( cFileThatUserSelected );
local cPathOnly = tFileParts.Drive..tFileParts.Folder;
Now "cPathOnly" holds just the path, no file name portion.
redpanama
12-31-2009, 05:25 PM
Can you please update code for me. It seems i can't get it to work.
Thanks for help! :yes
jassing
12-31-2009, 06:36 PM
update it how?
what did you try?
post your .sf8 file.
redpanama
12-31-2009, 06:55 PM
I tried to merge your code with:
if ((e_CtrlID == CTRL_BUTTON_BROWSE)
and (e_MsgID == MSGID_CLICKED)) then
--The first edit ctrl's button was clicked.
local tbEditProps = DlgEditField.GetProperties(CTRL_EDIT_FOLDER);
if(not tbEditProps) then
-- The edit field is not accessible or does not exist
return;
end
-- browse for the file loc
result = Dialog.FileBrowse(true, "Locate hl.exe", _DesktopFolder, "Half-Life Executable (*hl.exe)|*hl.exe|", "hl.exe", "exe", false, true);
-- if the result if valid then update the edit field
if((result ~= nil) and (result[1] ~= "CANCEL")) then
--get the first selected file
tbEditProps.Text = result[1];
--update the edit field
DlgEditField.SetProperties(CTRL_EDIT_FOLDER, tbEditProps)
end
end
but without success :S
jassing
12-31-2009, 07:53 PM
wow; that is so, um, not effecient...
The best i can do to 'fix' your code that you want,is this:
In the OnCtrl change this line:
tbEditProps.Text = result[1];
to
local tFileParts = String.SplitPath(result[1] )
tbEditProps.Text = tFileParts.Drive..tFileParts.Folder;
redpanama
12-31-2009, 08:08 PM
i needed to change just that...haha im such a noob :P
thank you so much, you probably saved my life here :D
:yes:yes:yes
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.