Let take a look at several simple dialog windows, which you may create with a script. For more complex examples of windows with parameters click here.
Simple example of dialog window:
int t;
void main() {
t = 0;
SculptRoom room;
room.clear().toSurface();
SetModalDialogCallback( "dialogCallback" );
ModalDialog( "Some message", "Title" );
}
void dialogCallback() {
if (t++ > 400) {
UI ui;
ui( "$DialogButton#1" );
}
}
Here comes the text in the window, which will disappear in several seconds.
More complex example. Print all files from the folder.
int n;
string files;
void main() {
n = 0;
files = "";
bool ok = ModalDialogOkCancel( "Start processing files?", "" );
if ( !ok ) {
return;
}
string mask = "*.png;*.jpg";
ForEachFileInFolder( "", mask, "fileProcessing" );
ModalDialog( "Files processed:\n" + files, "" );
}
void fileProcessing( string &in fileName ) {
++n;
files += n + ". " + fileName + "\n";
}
Here is a list of all methods you may use in scripts for dialog windows:
void ModalDialog(string &in ID,string &in Caption);
bool ModalDialogOkCancel(string &in ID,string &in Caption);
bool ModalDialogYesNo(string &in ID,string &in Caption);
void AddTranslation(string& ID, string& Text);
void AddFloatSlider(string &in VariableName,float Min,float Max);
void AddIntSlider(string &in VariableName,int Min,int Max);
void AddFloatInput(string &in VariableName,bool EmptyName);
void AddIntInput(string &in VariableName,bool EmptyName);
void AddStringInput(string &in VariableName,bool EmptyName);
void AddTextField(string &in TextID,int Align);
void AddDelimiter();
void AddButton(string &in FuncName);
void Columns(int nc);
Columns(2);
AddButton("Function1");
AddButton("Function2");
void AddCheckBox(string &in BoolVarRef);
void AddDroplist(string &in IntVarRef,string &in CaseList);
Int Case=0;
...
AddDroplist("Case","Case1,Case2,Case3");
void UICondition(string& fn);
void StopUICondition();
bool ShowSlider1and2;
float Slider1;
float Slider2;
float Slider3;
bool CheckUI(){
return ShowSlider1and2;
}
void main(){
AddCheckBox("ShowSlider1and2");
UICondition("CheckUI");
AddFloatSlider("Slider1",0,123);
AddFloatSlider("Slider2",0,123);
StopUICondition();
AddFloatSlider("Slider3",0,123);
ModalDialogOkCancel("","");
}
void PressInNextModalDialogs(int ButtonIndex);
void SetModalDialogCallback(string &in name);
void RemoveModalDialogCallbacks();
void ShowFloatingMessage(string &in ID,float Time);
bool GetCurrentDialog(string &out ID,string &out Caption);
int GetLastButtonIndex();
Use these functions for file selecting dialog:
DEPRECATED bool OpenDialog(string &in extensions,string &out result);
DEPRECATED bool SaveDialog(string &in extensions,string &out result);
DEPRECATED bool FolderDialog(string &out result);
DEPRECATED void SetFileForFileDialogs(string &in name);
DEPRECATED bool FileDialogCancelPressed();
- See Also
- π Creating custom dialog windows