Files

276 lines
13 KiB
ActionScript

package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.corelib.audio.SBAudio;
import den.DenXtCommManager;
import flash.events.MouseEvent;
import localization.LocalizationManager;
import room.RoomManagerWorld;
public class ItemWindowToggle extends ItemWindowBase
{
public function ItemWindowToggle(param1:Function, param2:Object, param3:String, param4:int, param5:Function = null, param6:Function = null, param7:Function = null, param8:Function = null, param9:Object = null)
{
super("mySettingsToggle",param1,param2,param3,param4,param5,param6,param7,param8);
}
override public function loadCurrItem(param1:int = 0, param2:int = 0) : void
{
}
override protected function setChildrenAndInitialConditions() : void
{
_window.goNowBtn.visible = false;
_window.woodenCursorBtn.visible = false;
_window.defaultCursorBtn.visible = false;
_window.toggleBtn.visible = false;
_window.toggleTxt.visible = false;
switch(_currItem.type)
{
case MySettings.TOGGLE_TYPE_TOGGLE_BTN:
_window.toggleBtn.visible = true;
_window.toggleBtn.toggleKnob.gotoAndStop("up");
_window.toggleBtn.toggleBG.gotoAndStop("up");
_window.icon.gotoAndStop(_currItem.frame);
_window.toggleBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.handleMouseDown,false,0,true);
_window.toggleBtn.addEventListener(MouseEvent.ROLL_OVER,this.handleMouseOver,false,0,true);
_window.toggleBtn.addEventListener(MouseEvent.ROLL_OUT,this.handleMouseOut,false,0,true);
break;
case MySettings.TOGGLE_TYPE_TEXT:
_window.toggleTxt.visible = true;
_window.icon.gotoAndStop(_currItem.frame);
break;
case MySettings.TOGGLE_TYPE_CURSOR:
_window.woodenCursorBtn.visible = true;
_window.defaultCursorBtn.visible = true;
_window.icon.visible = false;
if(Boolean(GuiManager.sharedObj) && (GuiManager.sharedObj.data.cursor == "custom" || GuiManager.sharedObj.data.cursor == null))
{
_window.woodenCursorBtn.upToDownState();
_window.woodenCursorBtn.mouseEnabled = false;
_window.woodenCursorBtn.mouseChildren = false;
}
else
{
_window.defaultCursorBtn.upToDownState();
_window.defaultCursorBtn.mouseEnabled = false;
_window.defaultCursorBtn.mouseChildren = false;
}
_window.woodenCursorBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.handleMouseDown,false,0,true);
_window.defaultCursorBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.handleMouseDown,false,0,true);
break;
case MySettings.TOGGLE_TYPE_JOIN:
_window.goNowBtn.visible = true;
_window.goNowBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.handleMouseDown,false,0,true);
_window.icon.gotoAndStop(_currItem.frame);
}
switch(_currItem.frame)
{
case "lock":
if(gMainFrame.userInfo.isMyDenPrivate)
{
_window.toggleBtn.gotoAndStop("startingOff");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOff");
}
else
{
_window.toggleBtn.gotoAndStop("startingOn");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOn");
}
LocalizationManager.translateId(_window.toggleBtn.valueTxt.onTxt,_currItem.onTxt);
LocalizationManager.translateId(_window.toggleBtn.valueTxt.offTxt,_currItem.offTxt);
break;
case "world":
_window.toggleTxt.text = ServerSelector.getShardName(RoomManagerWorld.instance.shardId);
break;
case "music":
if(SBAudio.isMusicMuted || SBAudio.areSoundsMuted)
{
_window.toggleBtn.gotoAndStop("startingOff");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOff");
}
else
{
_window.toggleBtn.gotoAndStop("startingOn");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOn");
}
LocalizationManager.translateId(_window.toggleBtn.valueTxt.onTxt,_currItem.onTxt);
LocalizationManager.translateId(_window.toggleBtn.valueTxt.offTxt,_currItem.offTxt);
break;
case "buddyRequest":
if(this.isSettingOn(MySettings.SETTINGS_BUDDY_REQUESTS))
{
_window.toggleBtn.gotoAndStop("startingOn");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOn");
}
else
{
_window.toggleBtn.gotoAndStop("startingOff");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOff");
}
LocalizationManager.translateId(_window.toggleBtn.valueTxt.onTxt,_currItem.onTxt);
LocalizationManager.translateId(_window.toggleBtn.valueTxt.offTxt,_currItem.offTxt);
break;
case "gameInvites":
if(this.isSettingOn(MySettings.SETTINGS_GAME_INVITES))
{
_window.toggleBtn.gotoAndStop("startingOn");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOn");
}
else
{
_window.toggleBtn.gotoAndStop("startingOff");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndStop("startingOff");
}
LocalizationManager.translateId(_window.toggleBtn.valueTxt.onTxt,_currItem.onTxt);
LocalizationManager.translateId(_window.toggleBtn.valueTxt.offTxt,_currItem.offTxt);
break;
case "intro":
}
LocalizationManager.translateId(_window.labelTxt,_currItem.labelTxt);
}
private function handleMouseDown(param1:MouseEvent) : void
{
var _loc2_:int = 0;
param1.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_TOGGLE_BTN)
{
switch(_currItem.frame)
{
case "lock":
gMainFrame.userInfo.isMyDenPrivate = !gMainFrame.userInfo.isMyDenPrivate;
if(gMainFrame.userInfo.isMyDenPrivate)
{
param1.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
}
else
{
param1.currentTarget.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
}
DenXtCommManager.requestSetDenPrivacy(gMainFrame.userInfo.isMyDenPrivate);
GuiManager.refreshDenLockSettings();
break;
case "music":
SBAudio.toggleMuteAll();
GuiManager.toggleMuteVideo();
if(SBAudio.isMusicMuted || SBAudio.areSoundsMuted)
{
param1.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
GuiManager.depressSoundButton(true);
}
else
{
param1.currentTarget.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
GuiManager.depressSoundButton(false);
}
break;
case "buddyRequest":
case "gameInvites":
_loc2_ = int(gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_SETTINGS));
if(_loc2_ == -1)
{
param1.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,_currItem.frame == "buddyRequest" ? MySettings.SETTINGS_BUDDY_REQUESTS : MySettings.SETTINGS_GAME_INVITES);
}
else if(param1.currentTarget.currentFrameLabel == "on" || param1.currentTarget.currentFrameLabel == "startingOn")
{
param1.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,_currItem.frame == "buddyRequest" ? MySettings.SETTINGS_BUDDY_REQUESTS : MySettings.SETTINGS_GAME_INVITES);
}
else
{
param1.currentTarget.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,_currItem.frame == "buddyRequest" ? MySettings.SETTINGS_BUDDY_REQUESTS : MySettings.SETTINGS_GAME_INVITES,null,false);
}
}
LocalizationManager.translateId(_window.toggleBtn.valueTxt.onTxt,_currItem.onTxt);
LocalizationManager.translateId(_window.toggleBtn.valueTxt.offTxt,_currItem.offTxt);
}
else if(_currItem.type == MySettings.TOGGLE_TYPE_CURSOR)
{
if(param1.currentTarget.mouse.currentFrame == 3)
{
param1.currentTarget.mouseEnabled = false;
param1.currentTarget.mouseChildren = false;
}
if(param1.currentTarget != _window.defaultCursorBtn)
{
GuiManager.setSharedObj("cursor","custom");
CursorManager.switchToCursor(CursorManager.CUSTOM_CURSOR);
_window.defaultCursorBtn.downToUpState();
_window.defaultCursorBtn.mouseEnabled = true;
_window.defaultCursorBtn.mouseChildren = true;
}
else
{
GuiManager.setSharedObj("cursor","default");
CursorManager.switchToCursor(CursorManager.DEFAULT_CURSOR);
_window.woodenCursorBtn.downToUpState();
_window.woodenCursorBtn.mouseEnabled = true;
_window.woodenCursorBtn.mouseChildren = true;
}
}
else if(_currItem.type == MySettings.TOGGLE_TYPE_JOIN)
{
GuiManager.startFFM();
}
}
private function handleMouseOut(param1:MouseEvent) : void
{
param1.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_TOGGLE_BTN)
{
if(param1.currentTarget.toggleBG.currentFrameLabel != "up")
{
param1.currentTarget.toggleBG.gotoAndStop("up");
}
if(param1.currentTarget.toggleKnob.currentFrameLabel != "up")
{
param1.currentTarget.toggleKnob.gotoAndStop("up");
}
}
}
private function handleMouseOver(param1:MouseEvent) : void
{
param1.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_TOGGLE_BTN)
{
if(param1.currentTarget.toggleBG.currentFrameLabel != "over")
{
param1.currentTarget.toggleBG.gotoAndStop("over");
}
if(param1.currentTarget.toggleKnob.currentFrameLabel != "over")
{
param1.currentTarget.toggleKnob.gotoAndStop("over");
}
}
}
private function isSettingOn(param1:int) : Boolean
{
var _loc2_:int = int(gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_SETTINGS));
if(_loc2_ == -1)
{
return true;
}
if((_loc2_ >> param1 & 1) == 1)
{
return false;
}
return true;
}
}
}