package flash
{
import flash.display.MovieClip;
import flash.utils.Dictionary;
public dynamic class Main extends MovieClip
{
private var ModSettingsLoader:Class;
public const modName:String = "dialogueTypingSpeed";
public const settingsFilename:String = "dialogueTypingSpeedSettings";
private var l;
public var typingSpeed:uint = 55;
public function initl(l) : void {
this.l = l;
// Load the settings file
ModSettingsLoader = l.eDOM.getDefinition("Modules.modSettingsLoader") as Class;
var msl = new ModSettingsLoader(settingsFilename,settingsLoaded);
msl.addEventListener("settingsNotFound",settingsNotFound);
}
public function settingsNotFound(e):void {
l.updateStatusCol(modName + " " + e.msg,"#FF0000"); //display error message
finishinit();
}
public function settingsLoaded(e) : void {
var dict:Dictionary = e.settings;
for (var key:Object in dict) {
// Skip any missing or damaged config lines
if ((!(key as String)) || (key as String).length < 1) { continue; }
// Process each apparently-valid config line. We'll either write its value to a local variable, or complain about it.
var val:Object = dict[key];
if ( this.hasOwnProperty( key ) ) { //checks if variable exists
this[key] = val; //replaces all switch statement variable assignments
} else {
l.updateStatusCol(modName + " invalid setting: " + key,"#FF0000"); //displays if there is a setting in the settings file that does not match any variables
}
}
finishinit();
}
private function finishinit():void {
this.typingSpeed = Math.max(1, Math.min(999, this.typingSpeed));
l.g.dialogueControl.typingSpeed = this.typingSpeed;
l.g.dialogueControl.DEFAULT_TYPING_SPEED = this.typingSpeed;
l.updateStatus("Dialogue typing speed has been set to " + this.typingSpeed + ".");
}
}
}