Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 112 additions & 86 deletions source/actionscript/ModConfigPanel/ColorDialog.as
Original file line number Diff line number Diff line change
@@ -1,89 +1,115 @@
class ColorDialog extends OptionDialog
{
var _defaultControls;
var colorSwatch;
var currentColor;
var defaultColor;
var leftButtonPanel;
var platform;
var rightButtonPanel;
function ColorDialog()
{
super();
}
function initButtons()
{
var _loc2_;
var _loc3_;
if(this.platform == 0)
{
_loc2_ = skyui.defines.Input.Enter;
this._defaultControls = skyui.defines.Input.ReadyWeapon;
_loc3_ = skyui.defines.Input.Tab;
}
else
{
_loc2_ = skyui.defines.Input.Accept;
this._defaultControls = skyui.defines.Input.YButton;
_loc3_ = skyui.defines.Input.Cancel;
}
this.leftButtonPanel.clearButtons();
var _loc6_ = this.leftButtonPanel.addButton({text:"$Default",controls:this._defaultControls});
_loc6_.addEventListener("press",this,"onDefaultPress");
this.leftButtonPanel.updateButtons();
this.rightButtonPanel.clearButtons();
var _loc5_ = this.rightButtonPanel.addButton({text:"$Cancel",controls:_loc3_});
_loc5_.addEventListener("press",this,"onCancelPress");
var _loc4_ = this.rightButtonPanel.addButton({text:"$Accept",controls:_loc2_});
_loc4_.addEventListener("press",this,"onAcceptPress");
this.rightButtonPanel.updateButtons();
}
function initContent()
{
this.colorSwatch._x = (- this.colorSwatch._width) / 2;
this.colorSwatch._y = (- this.colorSwatch._height) / 2;
this.colorSwatch.selectedColor = this.currentColor;
gfx.managers.FocusHandler.instance.setFocus(this.colorSwatch,0);
}
function handleInput(details, pathToFocus)
{
var _loc3_ = pathToFocus.shift();
if(_loc3_.handleInput(details,pathToFocus))
{
return true;
}
if(Shared.GlobalFunc.IsKeyPressed(details,false))
{
if(details.navEquivalent == gfx.ui.NavigationCode.TAB)
{
this.onCancelPress();
{
/* PRIVATE VARIABLES */

private var _acceptButton: MovieClip;
private var _defaultButton: MovieClip;
private var _cancelButton: MovieClip;

private var _defaultControls: Object;


/* STAGE ELEMENTS */

public var colorSwatch: ColorSwatch;


/* PROPERTIES */

public var currentColor: Number;
public var defaultColor: Number;


/* INITIALIZATION */

public function ColorDialog()
{
super();
}


/* PUBLIC FUNCTIONS */

// @override OptionDialog
private function initButtons()
{
var acceptControls: Object;
var cancelControls: Object;

if (this.platform == 0) {
acceptControls = skyui.defines.Input.Enter;
this._defaultControls = skyui.defines.Input.ReadyWeapon;
cancelControls = skyui.defines.Input.Tab;
} else {
acceptControls = skyui.defines.Input.Accept;
this._defaultControls = skyui.defines.Input.YButton;
cancelControls = skyui.defines.Input.Cancel;
}

this.leftButtonPanel.clearButtons();
var defaultButton = this.leftButtonPanel.addButton({text: "$Default", controls: this._defaultControls});
defaultButton.addEventListener("press", this, "onDefaultPress");
this.leftButtonPanel.updateButtons();

this.rightButtonPanel.clearButtons();
var cancelButton = this.rightButtonPanel.addButton({text: "$Cancel", controls: cancelControls});
cancelButton.addEventListener("press", this, "onCancelPress");
var acceptButton = this.rightButtonPanel.addButton({text: "$Accept", controls: acceptControls});
acceptButton.addEventListener("press", this, "onAcceptPress");
this.rightButtonPanel.updateButtons();
}

// @override OptionDialog
public function initContent()
{
this.colorSwatch._x = -this.colorSwatch._width / 2;
this.colorSwatch._y = -this.colorSwatch._height / 2;
this.colorSwatch.selectedColor = this.currentColor;

gfx.managers.FocusHandler.instance.setFocus(this.colorSwatch, 0);
}

// @GFx
public function handleInput(details, pathToFocus)
{
var nextClip = pathToFocus.shift();
if (nextClip.handleInput(details, pathToFocus))
return true;
}
if(details.navEquivalent == gfx.ui.NavigationCode.ENTER)
{
this.onAcceptPress();
return true;
}
if(details.control == this._defaultControls.name)
{
this.onDefaultPress();
return true;
}
}
return true;
}
function onAcceptPress()
{
skse.SendModEvent("SKICP_colorAccepted",null,this.colorSwatch.selectedColor);
skyui.util.DialogManager.close();
}
function onDefaultPress()
{
this.colorSwatch.selectedColor = this.defaultColor;
}
function onCancelPress()
{
skse.SendModEvent("SKICP_dialogCanceled");
skyui.util.DialogManager.close();
}

if (Shared.GlobalFunc.IsKeyPressed(details, false)) {
if (details.navEquivalent == gfx.ui.NavigationCode.TAB) {
this.onCancelPress();
return true;
} else if (details.navEquivalent == gfx.ui.NavigationCode.ENTER) {
this.onAcceptPress();
return true;
} else if (details.control == this._defaultControls.name) {
this.onDefaultPress();
return true;
}
}

// Don't forward to higher level
return true;
}


/* PRIVATE FUNCTIONS */

private function onAcceptPress()
{
skse.SendModEvent("SKICP_colorAccepted", null, this.colorSwatch.selectedColor);
skyui.util.DialogManager.close();
}

private function onDefaultPress()
{
this.colorSwatch.selectedColor = this.defaultColor;
}

private function onCancelPress()
{
skse.SendModEvent("SKICP_dialogCanceled");
skyui.util.DialogManager.close();
}
}
Loading