-
Notifications
You must be signed in to change notification settings - Fork 0
/
SSCommands.as
155 lines (145 loc) · 3.87 KB
/
SSCommands.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package
{
import flash.events.EventDispatcher;
/**
* Provides SWF Studio commands for all functionality listed in IShellCommands.
* @author Christopher Grigg
*/
internal class SSCommands extends EventDispatcher implements IShellCommands
{
/** @public */
public static const LINK_BACKSLASH:String = "\\";
/** @private */
private const BASE_RELATIVE:String = "relative";
/** @private */
private const BASE_GLOBAL:String = "global";
/** @private */
private const BASE_LOCAL:String = "local";
/** @private */
private var _deployablePath:String;
/**
* @private
* Substitute this for a value from config source such as an XML.
*/
private var _configValue:Object;
/**
* Establishes if the app is running in dev or RC mode.
* @return Boolean
*/
public function get shellMode():Boolean
{
return ssCore.isEXE;
}
/**
* Not applicable for SWF Studio
* @return false
*/
public function get zincMode():Boolean
{
return false;
}
/**
* Establishes if the app is running SWF Studio.
* @return Boolean
*/
public function get swfStudioMode():Boolean
{
return ssCore.isEXE;
}
/**
* Constructor.
*/
public function SSCommands()
{
trace("[SSCommandModel.SSCommands]");
this.bootShellFunctionality();
}
// implement functionality to set up shell software
private function bootShellFunctionality():void
{
// init SWF Studio
ssCore.init();
// allows synchronous syntax
ssDefaults.synchronousCommands = true;
}
/**
* Provides a path to the folder in which the Customisation Tool writes to.
* @param subFolder any subfolder to be added to the returned path
* @return the path string
*/
public function specialFolder(subFolder:String):String
{
var returnObject:Object = ssCore.FileSys.specialFolder( {folderID:subFolder} );
return returnObject.result;
}
/**
* Provides a path to the deployable folder i.e. the folder containing the editable files
* @param subFolder if a sub folder is required
* @return the path string
*/
public function deployableFolder(subFolder:String=''):String
{
trace("[SSCommandModel.deployableFolder]");
if(this.shellMode && forceSWFStudioCommand)
{
if(_configValue == this.BASE_LOCAL)
{
// identify "User/AppData/Local" folder
var return_obj:Object = ssCore.FileSys.specialFolder({folderID:"0x001c"});
_deployablePath = return_obj.result + LINK_BACKSLASH + subFolder;
}
else if(_configValue == this.BASE_GLOBAL)
{
// identify "c:/ProgramData" folder
_deployablePath = ssGlobals.ssAllUsersAppDataDir + LINK_BACKSLASH + subFolder;
}
else if(_configValue == this.BASE_RELATIVE)
{
// relative path
_deployablePath = this.startpath(subFolder);
}
else
{
// default to relative path if nothing is found in xml node
_deployablePath = subFolder;
}
}
else
{
// relative path
_deployablePath = subFolder;
}
return _deployablePath;
}
/**
* Provides a path to the folder where the executable file is located.
* @param subFolder any subfolder to be added to the returned path
* @param includeBackslash gives the option to include backslashes in the path
* @return the path string
*/
public function startpath(subFolder:String='', includeBackslash:Boolean=true):String
{
trace("[SSCommandModel.startpath]");
var path:String;
if(this.shellMode){
if(includeBackslash)
path = ssGlobals.ssStartDir + LINK_BACKSLASH + subFolder;
else
path = ssGlobals.ssStartDir + subFolder;
} else {
path = subFolder;
}
return path;
}
/**
* Sets properties on app to act like a kiosk.
*/
public function setKioskMode():void
{
if(this.shellMode) {
// kiosk mode disables specific functionality
ssCore.App.setKioskMode({flag:true, skipRegMods:true});
}
}
}
}