Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,295 @@
package gui
{
import achievement.Achievement;
import achievement.AchievementXtCommManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
public class AchievementViewer
{
private var _achievementMediaHelper:MediaHelper;
private var _achievementPopupContent:MovieClip;
private var _itemWindows:WindowGenerator;
private var _scrollButtons:MovieClip;
private var _achievements:Array;
private var _xPos:int;
private var _yPos:int;
private var _numAchievementsLastDrawn:int;
private var _hasBeenInited:Boolean;
private var _loadingSpiral:LoadingSpiral;
public function AchievementViewer()
{
super();
}
public function init(initXPos:int, initYPos:int, initMediaId:int = -1, rebuild:Boolean = false) : void
{
this._achievements = new Array();
this._xPos = initXPos;
this._yPos = initYPos;
if(!gMainFrame.userInfo.playerUserInfo.achievements)
{
AchievementXtCommManager.requestAchievements(gMainFrame.userInfo.playerUserInfo.userName,this.achievementListCallback);
if(Boolean(this._loadingSpiral))
{
this._loadingSpiral.visible = true;
}
}
else
{
this._achievements = gMainFrame.userInfo.playerUserInfo.achievements;
}
if(initMediaId != -1 && this._achievementPopupContent == null)
{
this._achievementMediaHelper = new MediaHelper();
this._achievementMediaHelper.init(initMediaId,this.mediaHelperCallback,rebuild);
}
else
{
this._achievementPopupContent.x = this._xPos;
this._achievementPopupContent.y = this._yPos + this._achievementPopupContent.height * 0.5;
}
if(Boolean(this._achievementPopupContent))
{
this._achievementPopupContent.visible = true;
this._achievementPopupContent.counterTxt.text = this._achievements.length;
this.createWindows();
this._hasBeenInited = true;
}
}
public function destroy() : void
{
if(Boolean(this._achievementMediaHelper))
{
this._achievementMediaHelper.destroy();
}
if(Boolean(this._scrollButtons))
{
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
if(Boolean(this._achievements))
{
this._achievements = null;
}
if(Boolean(this._achievementPopupContent))
{
this.removeEventListeners();
GuiManager.guiLayer.removeChild(this._achievementPopupContent);
this._achievementPopupContent.visible = false;
this._achievementPopupContent = null;
}
this._hasBeenInited = false;
GuiManager.mainHud.awardsBtn.downToUpState();
}
public function loadMedia(id:int = -1) : void
{
if(id != -1)
{
this._achievementMediaHelper = new MediaHelper();
this._achievementMediaHelper.init(id,this.initMediaCallback);
}
}
public function open() : void
{
if(this._numAchievementsLastDrawn < this._achievements.length)
{
this.createWindows();
this._achievementPopupContent.counterTxt.text = this._achievements.length;
}
this._achievementPopupContent.visible = true;
}
public function close() : void
{
GuiManager.mainHud.awardsBtn.downToUpState();
this._achievementPopupContent.visible = false;
}
public function get visible() : Boolean
{
if(Boolean(this._achievementPopupContent))
{
return this._achievementPopupContent.visible;
}
return false;
}
public function get hasBeenInited() : Boolean
{
return this._hasBeenInited;
}
private function addAchievementCallback(aList:Array) : void
{
for(var i:int = 0; i < aList.length; i++)
{
this._achievements[i] = aList[i].image;
}
}
private function initMediaCallback(img:MovieClip) : void
{
if(Boolean(img))
{
this._achievementPopupContent = MovieClip(img.getChildAt(0));
this._achievementPopupContent.counterTxt.text = "";
GuiManager.guiLayer.addChild(this._achievementPopupContent);
this.addEventListeners();
this._achievementPopupContent.visible = false;
this._loadingSpiral = new LoadingSpiral(this._achievementPopupContent.itemBlock,this._achievementPopupContent.itemBlock.width * 0.5,this._achievementPopupContent.itemBlock.height * 0.5);
this._loadingSpiral.visible = false;
this._achievementMediaHelper.destroy();
this._achievementMediaHelper = null;
}
}
private function mediaHelperCallback(img:MovieClip) : void
{
if(Boolean(img))
{
this._achievementPopupContent = MovieClip(img.getChildAt(0));
this._achievementPopupContent.x = this._xPos;
this._achievementPopupContent.y = this._yPos + this._achievementPopupContent.height * 0.5;
this._achievementPopupContent.counterTxt.text = "";
GuiManager.guiLayer.addChild(this._achievementPopupContent);
this.addEventListeners();
this._loadingSpiral = new LoadingSpiral(this._achievementPopupContent.itemBlock,this._achievementPopupContent.itemBlock.width * 0.5,this._achievementPopupContent.itemBlock.height * 0.5);
this._loadingSpiral.visible = false;
if(Boolean(img.passback))
{
this._achievementPopupContent.visible = false;
}
else
{
this._achievementPopupContent.counterTxt.text = this._achievements.length;
this.createWindows();
this._hasBeenInited = true;
}
}
}
private function achievementListCallback(aList:Array) : void
{
if(Boolean(aList))
{
this._achievements = aList;
if(Boolean(this._achievementPopupContent))
{
this._achievementPopupContent.counterTxt.text = this._achievements.length;
this.createWindows(true);
}
}
}
private function createWindows(isFromCallback:Boolean = false) : void
{
if(Boolean(this._scrollButtons))
{
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows) && this._itemWindows.numChildren > 0)
{
this._itemWindows.destroy();
this._itemWindows = null;
}
var numItemsInCurrentArray:int = this._numAchievementsLastDrawn = this._achievements.length;
var xCount:int = Math.min(numItemsInCurrentArray,5);
var yCount:int = Math.ceil(xCount / 5);
this._itemWindows = new WindowGenerator();
this._itemWindows.init(xCount,yCount,Math.ceil(numItemsInCurrentArray / xCount) * xCount,0,0,0,ItemWindowBase,this._achievements,"image",{
"mouseOver":this.winMouseOver,
"mouseOut":this.winMouseOut
},{"itemClassName":"awardCont"});
this._achievementPopupContent.itemBlock.addChild(this._itemWindows);
if(isFromCallback)
{
this._loadingSpiral.visible = false;
}
this._scrollButtons = new SBScrollbar();
this._scrollButtons.init(this._itemWindows,328,213,0,"scrollbar2",71);
if(Boolean(this._loadingSpiral))
{
this._loadingSpiral.visible = false;
}
}
private function onPopupDownHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
this.close();
}
private function winMouseOver(evt:MouseEvent) : void
{
var id:int = int(evt.currentTarget.index);
var a:Achievement = this._achievements[id];
GuiManager.toolTip.init(this._achievementPopupContent.itemBlock,a.name,0,0);
GuiManager.toolTip.startTimer(evt);
var yPos:int = evt.currentTarget.y + this._itemWindows.y;
if(a.baseImageMediaId == Achievement.BASE_RIBBON_ID)
{
yPos += 42;
}
else if(a.baseImageMediaId == Achievement.BASE_MEDAL_ID)
{
yPos += 56;
}
else
{
yPos += 57;
}
var xPos:int = evt.currentTarget.x + evt.currentTarget.width * 0.5;
var diff:Number = GuiManager.toolTip.width * 0.5 - xPos;
if(diff > 15)
{
xPos += diff - 15;
}
GuiManager.toolTip.setPos(xPos,yPos);
}
private function winMouseOut(evt:MouseEvent) : void
{
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private function addEventListeners() : void
{
this._achievementPopupContent.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDownHandler,false,0,true);
this._achievementPopupContent.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
private function removeEventListeners() : void
{
this._achievementPopupContent.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDownHandler);
this._achievementPopupContent.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
}
}
@@ -0,0 +1,621 @@
package gui
{
import avatar.AvatarManager;
import avatar.UserCommXtCommManager;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
import game.MinigameManager;
import gskinner.motion.GTween;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.WorldPet;
public class ActionManager
{
private const ACTIONWINDOW_DIM_ALPHA:Number = 0.5;
private const ACTIONWINDOW_BRIGHT_ALPHA:Number = 1;
public var actionBtn:MovieClip;
public var actionWindow:MovieClip;
public var emoteBtn:MovieClip;
public var emoteWindow:Sprite;
public var safeChatBtn:MovieClip;
public var safeChatTree:MovieClip;
public var setActionCallback:Function;
public var actionSprites:Array = ["sit1BtnCont","sit2BtnCont","sit3BtnCont","sit4BtnCont","danceAnim_btnCont","sleepAnim_btnCont","hopAnim_btnCont","playAnim_btnCont","pose1BtnCont","pose2BtnCont","diveAnim_btnCont","swirlAnim_btnCont"];
public var actionStrings:Object;
private var _actions:MovieClip;
private var _petActions:MovieClip;
private var _gameTab:MovieClip;
private var _isGameTabOpen:Boolean;
private var _sideMenuTweenFinished:Boolean;
private var _pvpScrollBar:SBScrollbar;
private var _pvpItemWindows:WindowGenerator;
private var _pvpGameList:Array;
private var _views:Array;
public function ActionManager(actionCallbackRef:Function, actBtn:MovieClip, actWindow:MovieClip, emoticonBtn:MovieClip, emoticonWindow:Sprite, safeChatButton:MovieClip, safeChatTreeGui:MovieClip)
{
super();
if(this.setActionCallback != null)
{
throw new Error("ERROR: Singleton ActionManager did not expect to be created twice!");
}
this.setActionCallback = actionCallbackRef;
this.actionBtn = actBtn;
this.actionBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.actionBtnDownHandler,false,0,true);
this.actionWindow = actWindow;
this._gameTab = actWindow.hudGameTab;
this._gameTab.gameCancelTabBtn.visible = false;
if(Utility.canPVP())
{
this._gameTab.gameTabBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onGameTab,false,0,true);
this._gameTab.gameCancelTabBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onCancelGameTab,false,0,true);
}
else
{
this._gameTab.gameTabBtn.activateGrayState(true);
}
LocalizationManager.translateId(this._gameTab.buddyGamesTxt,6285);
this.addAllActions();
this.actionWindow.addChild(this._actions);
this.actionWindow.addChild(this._petActions);
this._petActions.visible = false;
this.actionWindow.poseBtns = this._actions.poseBtns;
this.actionWindow.diveBtn = this._actions.diveBtn;
this.actionWindow.swirlBtn = this._actions.swirlBtn;
this.actionWindow.sitBtns = this._actions.sitBtns;
this.actionWindow.visible = false;
this.emoteBtn = emoticonBtn;
this.emoteWindow = emoticonWindow;
this.safeChatBtn = safeChatButton;
this.safeChatTree = safeChatTreeGui;
this.setupTitleBanner();
}
public function turnOnOceanActions(b:Boolean) : void
{
this.actionWindow.poseBtns.visible = b;
this.actionWindow.diveBtn.visible = b;
this.actionWindow.swirlBtn.visible = b;
this.actionWindow.sitBtns.visible = !b;
}
public function turnOnPetActions(b:Boolean) : void
{
if(b)
{
this._petActions.visible = true;
this._actions.visible = false;
}
else
{
this._petActions.visible = false;
this._actions.visible = true;
}
}
public function grayGameTab(gray:Boolean) : void
{
this._gameTab.gameTabBtn.activateGrayState(gray);
}
public function reload(actBtn:MovieClip, actWindow:MovieClip, emoticonBtn:MovieClip, emoticonWindow:Sprite, safeChatButton:MovieClip, safeChatTreeGui:MovieClip) : void
{
if(Boolean(this.actionBtn))
{
this.actionBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.actionBtnDownHandler);
}
this.actionBtn = actBtn;
this.actionBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.actionBtnDownHandler,false,0,true);
while(this.actionWindow.numChildren > 2)
{
this.actionWindow.removeChildAt(this.actionWindow.numChildren - 1);
}
this.actionWindow = actWindow;
this._gameTab = actWindow.hudGameTab;
if(Boolean(this._gameTab))
{
this._gameTab.gameCancelTabBtn.visible = false;
if(Utility.canPVP())
{
this._gameTab.gameTabBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onGameTab,false,0,true);
this._gameTab.gameCancelTabBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onCancelGameTab,false,0,true);
}
else
{
this._gameTab.gameTabBtn.activateGrayState(true);
}
LocalizationManager.translateId(this._gameTab.buddyGamesTxt,6285);
this.setupTitleBanner();
}
this.addAllActions();
this.actionWindow.addChild(this._actions);
this.actionWindow.addChild(this._petActions);
this._petActions.visible = false;
this.actionWindow.poseBtns = this._actions.poseBtns;
this.actionWindow.diveBtn = this._actions.diveBtn;
this.actionWindow.swirlBtn = this._actions.swirlBtn;
this.actionWindow.sitBtns = this._actions.sitBtns;
this.actionWindow.visible = false;
this.emoteBtn = emoticonBtn;
this.emoteWindow = emoticonWindow;
this.actionWindow = actWindow;
this.safeChatBtn = safeChatButton;
this.safeChatTree = safeChatTreeGui;
this.actionBtn.downToUpState();
}
private function addAllActions() : void
{
var b:Sprite = null;
var s:Sprite = null;
var j:int = 0;
var k:int = 0;
var ACTIONS_MARGIN_TOP:uint = 10;
var ACTIONS_MARGIN_LEFT:uint = 25;
var ACTIONS_STEP_V:uint = 40;
var ACTIONS_STEP_H:uint = 91;
var ACTIONS_ROW_MAX:uint = 2;
var ACTIONS_WINDOW_OFFSET_X:Number = -72;
var ACTIONS_WINDOW_OFFSET_Y:Number = -50;
var ACTIONS_WINDOW_OFFSET_Y_SIT:Number = -88;
var ACTIONS_NUM_SIT_BTNS:int = 4;
var ACTIONS_NUM_POSE_BTNS:int = 2;
var ACTIONS_NUM_LAND_BTNS:int = 8;
this._actions = new MovieClip();
this._petActions = new MovieClip();
for(var i:uint = 0; i < this.actionSprites.length; i++)
{
if(i < ACTIONS_NUM_LAND_BTNS)
{
b = GETDEFINITIONBYNAME(i < ACTIONS_NUM_SIT_BTNS ? "sitBtns" : this.actionSprites[i]);
if(i == 0)
{
b.x = this.actionWindow.ba.width * 0.5 + ACTIONS_WINDOW_OFFSET_X - ACTIONS_MARGIN_LEFT - 5;
b.y = ACTIONS_MARGIN_TOP + Math.floor(i / ACTIONS_ROW_MAX) * ACTIONS_STEP_V + ACTIONS_WINDOW_OFFSET_Y;
this._actions.addChild(b);
this._actions.sitBtns = b;
for(j = 1; j <= 4; j++)
{
s = b["sit" + j + "Btn"];
s.buttonMode = true;
s.useHandCursor = true;
s.mouseChildren = false;
s.tabEnabled = true;
s.tabChildren = false;
s.addEventListener(MouseEvent.MOUSE_DOWN,this.actionClickHandler,false,0,true);
}
}
else if(i >= ACTIONS_NUM_SIT_BTNS)
{
b.x = ACTIONS_MARGIN_LEFT + (i % ACTIONS_ROW_MAX * ACTIONS_STEP_H + ACTIONS_WINDOW_OFFSET_X);
b.y = ACTIONS_MARGIN_TOP + Math.floor(i / ACTIONS_ROW_MAX) * ACTIONS_STEP_V + ACTIONS_WINDOW_OFFSET_Y_SIT;
this._actions.addChild(b);
b.buttonMode = true;
b.useHandCursor = true;
b.mouseChildren = false;
b.tabEnabled = true;
b.tabChildren = false;
b.addEventListener(MouseEvent.MOUSE_DOWN,this.actionClickHandler,false,0,true);
}
}
else
{
b = GETDEFINITIONBYNAME(i == ACTIONS_NUM_LAND_BTNS ? "poseBtns" : this.actionSprites[i]);
if(i == ACTIONS_NUM_LAND_BTNS)
{
b.visible = false;
this._actions.poseBtns = b;
b.x = this.actionWindow.ba.width * 0.5 + ACTIONS_WINDOW_OFFSET_X - ACTIONS_MARGIN_LEFT - 5;
b.y = ACTIONS_MARGIN_TOP + Math.floor((i - ACTIONS_NUM_LAND_BTNS) / ACTIONS_ROW_MAX) * ACTIONS_STEP_V + ACTIONS_WINDOW_OFFSET_Y;
this._actions.addChild(b);
for(k = 1; k <= 2; k++)
{
s = b["pose" + k + "Btn"];
s.buttonMode = true;
s.useHandCursor = true;
s.mouseChildren = false;
s.tabEnabled = true;
s.tabChildren = false;
s.addEventListener(MouseEvent.MOUSE_DOWN,this.actionClickHandler,false,0,true);
}
}
else if(i >= ACTIONS_NUM_LAND_BTNS + ACTIONS_NUM_POSE_BTNS)
{
b.visible = false;
if(i == this.actionSprites.length - 1)
{
this._actions.diveBtn = b;
}
else
{
this._actions.swirlBtn = b;
}
b.x = ACTIONS_MARGIN_LEFT + ((i - 5) % ACTIONS_ROW_MAX * ACTIONS_STEP_H + ACTIONS_WINDOW_OFFSET_X);
b.y = ACTIONS_MARGIN_TOP + Math.floor((i - 5) / ACTIONS_ROW_MAX) * ACTIONS_STEP_V + ACTIONS_WINDOW_OFFSET_Y_SIT;
this._actions.addChild(b);
b.buttonMode = true;
b.useHandCursor = true;
b.mouseChildren = false;
b.tabEnabled = true;
b.tabChildren = false;
b.addEventListener(MouseEvent.MOUSE_DOWN,this.actionClickHandler,false,0,true);
}
}
}
b = GETDEFINITIONBYNAME("playPetAnim_btnCont");
b.y = -31;
b.buttonMode = true;
b.useHandCursor = true;
b.mouseChildren = false;
b.tabEnabled = true;
b.tabChildren = false;
b.addEventListener(MouseEvent.MOUSE_DOWN,this.onPetPlayBtn,false,0,true);
this._petActions.addChild(b);
b = GETDEFINITIONBYNAME("dancePetAnim_btnCont");
this._petActions.danceBtn = b;
b.y = 31;
b.buttonMode = true;
b.useHandCursor = true;
b.mouseChildren = false;
b.tabEnabled = true;
b.tabChildren = false;
b.addEventListener(MouseEvent.MOUSE_DOWN,this.actionClickHandler,false,0,true);
this._petActions.addChild(b);
this.actionStrings = new Object();
this.actionStrings["sit1BtnCont"] = this.actionStrings["pose1BtnCont"] = [":sitNW:",":poseLeft:"];
this.actionStrings["sit2BtnCont"] = [":sitNE:"];
this.actionStrings["sit3BtnCont"] = [":sitSE:"];
this.actionStrings["sit4BtnCont"] = this.actionStrings["pose2BtnCont"] = [":sitSW:",":poseRight:"];
this.actionStrings["danceAnim_btnCont"] = this.actionStrings["dancePetAnim_btnCont"] = [":dance:"];
this.actionStrings["sleepAnim_btnCont"] = this.actionStrings["diveAnim_btnCont"] = [":sleep:",":dive:"];
this.actionStrings["hopAnim_btnCont"] = this.actionStrings["swirlAnim_btnCont"] = [":hop:",":swirl:"];
this.actionStrings["playAnim_btnCont"] = [":play:"];
}
private function setupTitleBanner() : void
{
var titleBanner:Sprite = GETDEFINITIONBYNAME("AnimsTitleBanner");
titleBanner.x = -91.75;
titleBanner.y = -91.25;
this.actionWindow.addChild(titleBanner);
}
public function destroy() : void
{
this.setActionCallback = null;
this.actionBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.actionBtnDownHandler);
this.actionBtn = null;
this.actionWindow.visible = false;
this.actionWindow = null;
this.emoteBtn = null;
this.emoteWindow = null;
this.safeChatBtn = null;
this.safeChatTree = null;
}
public function getActionString(action:Sprite) : String
{
var actionString:String = action["constructor"].toString();
var index:String = actionString.slice(7,actionString.length - 1);
if(Boolean(this.actionStrings[index]))
{
if(this.actionStrings[index].length > 1)
{
return this.actionStrings[actionString.slice(7,actionString.length - 1)][AvatarManager.roomEnviroType == Utility.ENVIRO_LAND ? 0 : 1];
}
return this.actionStrings[actionString.slice(7,actionString.length - 1)][0];
}
return null;
}
public function matchActionString(actionStr:String) : Sprite
{
var asprs:String = null;
var index:int = 0;
for each(asprs in this.actionSprites)
{
index = int(this.actionStrings[asprs].indexOf(actionStr));
if(index != -1)
{
if(this.actionStrings[asprs].length <= 1)
{
return GETDEFINITIONBYNAME(asprs);
}
if(AvatarManager.roomEnviroType == Utility.ENVIRO_LAND ? index == 0 : index == 1)
{
return GETDEFINITIONBYNAME(asprs);
}
}
}
return null;
}
public function openActions() : void
{
if(!this.actionWindow.visible)
{
this.actionWindow.visible = true;
this.brightenActions();
}
}
public function dimActions() : void
{
if(this.actionWindow.visible && this.actionWindow.alpha != this.ACTIONWINDOW_DIM_ALPHA)
{
this.actionWindow.alpha = this.ACTIONWINDOW_DIM_ALPHA;
}
}
public function brightenActions() : void
{
if(this.actionWindow.alpha != this.ACTIONWINDOW_BRIGHT_ALPHA)
{
this.actionWindow.alpha = this.ACTIONWINDOW_BRIGHT_ALPHA;
}
}
public function closeActions() : void
{
if(this.actionWindow.visible)
{
this.actionWindow.visible = false;
this.brightenActions();
this.actionBtn.downToUpState();
this.closeSideMenu(this._gameTab);
}
}
public function hideCancelBtn() : void
{
if(Boolean(this._gameTab))
{
this._gameTab.gameCancelTabBtn.visible = false;
}
}
public function grayOutPetDanceBtn(b:Boolean) : void
{
if(Boolean(this._petActions))
{
this._petActions.danceBtn.activateGrayState(b);
}
}
private function actionBtnDownHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(!m.currentTarget.isGray)
{
if(this.actionWindow.visible)
{
this.closeActions();
}
else
{
if(this.safeChatTree.visible)
{
this.safeChatBtn.dispatchEvent(m);
}
if(this.emoteWindow.visible)
{
this.emoteBtn.dispatchEvent(m);
}
this.openActions();
}
}
}
private function onGameTab(evt:MouseEvent) : void
{
evt.stopPropagation();
if(!evt.currentTarget.isGray)
{
if(!this._isGameTabOpen)
{
if(this._pvpItemWindows == null)
{
this._pvpGameList = MinigameManager.minigameInfoCache.getAllReadyForPvpGameDefs();
this.createPVPWindows();
this.getPVPIcons();
}
else
{
this._gameTab.itemWindow.addChild(this._pvpItemWindows);
if(Boolean(this._pvpScrollBar))
{
this._pvpScrollBar.destroy();
}
this._pvpScrollBar = new SBScrollbar();
this._pvpScrollBar.init(this._pvpItemWindows,155,156,10,"scrollbar2",78);
}
this.openSideMenu(this._gameTab);
}
else
{
this.closeSideMenu(this._gameTab);
}
}
}
private function onCancelGameTab(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.visible = false;
UserCommXtCommManager.sendCustomPVPMessage(false,MinigameManager.minigameInfoCache.currMinigameId);
MinigameManager.readySelfForCustomPVPGame(-1,"");
}
private function openSideMenu(sideMenu:MovieClip) : void
{
if(!this._isGameTabOpen)
{
new GTween(sideMenu,0.5,{"x":sideMenu.x + 175},{
"ease":TweenManager.quadratic,
"onComplete":this.sideMenuComplete
});
this._sideMenuTweenFinished = false;
this._isGameTabOpen = true;
AJAudio.playBuddyCardOpen();
}
}
private function closeSideMenu(sideMenu:MovieClip) : void
{
if(this._isGameTabOpen && this._sideMenuTweenFinished)
{
new GTween(sideMenu,0.5,{"x":sideMenu.x - 175},{
"ease":TweenManager.quadratic,
"onComplete":this.sideMenuComplete
});
this._sideMenuTweenFinished = false;
this._isGameTabOpen = false;
AJAudio.playBuddyCardClose();
}
}
private function createPVPWindows() : void
{
if(Boolean(this._pvpScrollBar))
{
this._pvpScrollBar.destroy();
this._pvpScrollBar = null;
}
if(Boolean(this._pvpItemWindows) && this._pvpItemWindows.numChildren > 0)
{
this._pvpItemWindows.destroy();
this._pvpItemWindows = null;
}
var numItemsInCurrentArray:int = int(this._pvpGameList.length);
var xCount:int = Math.min(numItemsInCurrentArray,2);
this._pvpItemWindows = new WindowGenerator();
this._pvpItemWindows.init(xCount,xCount,numItemsInCurrentArray,2,2,0,ItemWindowGame,null,"",{
"mouseDown":this.sideMenuMouseDown,
"mouseOver":this.sideMenuMouseOver,
"mouseOut":this.winMouseOut
},null,null,false,false);
this._gameTab.itemWindow.addChild(this._pvpItemWindows);
this._pvpScrollBar = new SBScrollbar();
this._pvpScrollBar.init(this._pvpItemWindows,155,156,10,"scrollbar2",78,0,Math.ceil(numItemsInCurrentArray / xCount) * 78);
}
private function getPVPIcons() : void
{
var pvpGameHelper:MediaHelper = null;
this._views = new Array();
for(var i:int = 0; i < this._pvpGameList.length; i++)
{
pvpGameHelper = new MediaHelper();
pvpGameHelper.init(this._pvpGameList[i].gameCardMediaId,this.mediaHelperCallback,true);
this._views[i] = pvpGameHelper;
}
}
private function mediaHelperCallback(img:MovieClip) : void
{
var mc:MovieClip = null;
for(var i:int = 0; i < this._views.length; i++)
{
if(this._views[i] == img.mediaHelper)
{
mc = MovieClip(this._pvpItemWindows.bg.getChildAt(i));
mc.itemLayer.addChild(img);
}
}
}
private function sideMenuComplete(tween:GTween) : void
{
this._sideMenuTweenFinished = true;
}
private function sideMenuMouseDown(evt:MouseEvent) : void
{
evt.stopPropagation();
if(MinigameManager.minigameInfoCache.currMinigameId == this._pvpGameList[evt.currentTarget.index].gameDefId)
{
UserCommXtCommManager.sendCustomPVPMessage(false,this._pvpGameList[evt.currentTarget.index].gameDefId);
MinigameManager.readySelfForCustomPVPGame(-1,"");
this._gameTab.gameCancelTabBtn.visible = false;
}
else
{
UserCommXtCommManager.sendCustomPVPMessage(true,this._pvpGameList[evt.currentTarget.index].gameDefId);
MinigameManager.readySelfForCustomPVPGame(this._pvpGameList[evt.currentTarget.index].gameDefId,"");
this._gameTab.gameCancelTabBtn.visible = true;
}
this.closeActions();
}
private function sideMenuMouseOver(evt:MouseEvent) : void
{
var globalPoint:Point = null;
evt.stopPropagation();
if(this._sideMenuTweenFinished)
{
globalPoint = evt.currentTarget.localToGlobal(new Point(0,0));
GuiManager.toolTip.init(this.actionWindow,LocalizationManager.translateIdOnly(this._pvpGameList[evt.currentTarget.index].titleStrId),globalPoint.x - this.actionWindow.x + this.actionWindow.hudGameTab.x + this.actionWindow.hudGameTab.itemWindow.x - evt.currentTarget.width,globalPoint.y - this.actionWindow.y + evt.currentTarget.height + this._gameTab.y);
GuiManager.toolTip.startTimer(evt);
AJAudio.playSubMenuBtnRollover();
}
}
private function winMouseOut(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private function actionClickHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(!this.actionBtn.isGray && !m.currentTarget.isGray)
{
this.setActionCallback(new m.target.constructor());
this.actionBtn.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
m.currentTarget.downToUpState();
}
}
private function onPetPlayBtn(m:MouseEvent) : void
{
var myPet:WorldPet = null;
m.stopPropagation();
if(Boolean(AvatarManager.playerAvatarWorldView))
{
myPet = AvatarManager.playerAvatarWorldView.getActivePet();
if(Boolean(myPet))
{
AvatarManager.playerAvatarWorldView.faceAnim(0,0,false);
myPet.onClick(m);
}
}
this.actionBtn.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
m.currentTarget.downToUpState();
}
}
}
@@ -0,0 +1,181 @@
package gui
{
import avatar.AvatarInfo;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import localization.LocalizationManager;
import quest.QuestXtCommManager;
public class AdventureExpertPopup
{
private static var _difficultyPopup:MovieClip;
private static var _mediaHelper:MediaHelper;
private static var _guiLayer:DisplayLayer;
private static var _autoStart:Boolean;
private static var _scriptDef:Object;
private static const ADVENTURE_EXPERT_ID:int = 2288;
public function AdventureExpertPopup()
{
super();
}
public static function init(initScriptDefId:int, autoStart:Boolean = false) : void
{
_scriptDef = QuestXtCommManager.getScriptDef(initScriptDefId);
_guiLayer = GuiManager.guiLayer;
_autoStart = autoStart;
DarkenManager.showLoadingSpiral(true);
_mediaHelper = new MediaHelper();
_mediaHelper.init(ADVENTURE_EXPERT_ID,onExpertLoaded);
}
public static function destroy() : void
{
removeEventListeners();
_mediaHelper.destroy();
_mediaHelper = null;
if(Boolean(_difficultyPopup))
{
DarkenManager.unDarken(_difficultyPopup);
_guiLayer.removeChild(_difficultyPopup);
_difficultyPopup = null;
}
}
private static function onExpertLoaded(img:MovieClip) : void
{
DarkenManager.showLoadingSpiral(false);
_difficultyPopup = MovieClip(img.getChildAt(0));
_difficultyPopup.x = MainFrame.VIEW_WIDTH * 0.5;
_difficultyPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
_difficultyPopup.nonMemLock.visible = !gMainFrame.userInfo.isMember;
_difficultyPopup.dModeCont.visible = false;
_difficultyPopup.scrim.visible = false;
addEventListeners();
_guiLayer.addChild(_difficultyPopup);
DarkenManager.darken(_difficultyPopup);
}
private static function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private static function onCloseBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
destroy();
}
private static function onDifficulty(evt:MouseEvent) : void
{
var ai:AvatarInfo = null;
evt.stopPropagation();
var difficulty:int = 0;
if(evt.currentTarget.name == _difficultyPopup.dModeCont.hardBtn.name)
{
ai = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,gMainFrame.userInfo.myPerUserAvId);
if(Boolean(ai) && ai.questLevel < _scriptDef.levelMin + 1)
{
new SBOkPopup(_guiLayer,LocalizationManager.translateIdAndInsertOnly(14696,_scriptDef.levelMin + 1));
return;
}
difficulty = 1;
}
if(_difficultyPopup.joinName == _difficultyPopup.joinBtn.name)
{
QuestXtCommManager.sendQuestCreateJoinPublic(_scriptDef.defId,difficulty,_autoStart);
destroy();
DarkenManager.showLoadingSpiral(true);
return;
}
if(!gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.DIAMONDS,"customAdventure/");
destroy();
return;
}
QuestXtCommManager.sendQuestCreatePrivate(_scriptDef.defId,difficulty,false);
destroy();
DarkenManager.showLoadingSpiral(true);
}
private static function onJoinTypeBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
var ai:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,gMainFrame.userInfo.myPerUserAvId);
if(Boolean(ai) && ai.questLevel < _scriptDef.levelMin)
{
new SBOkPopup(_guiLayer,LocalizationManager.translateIdAndInsertOnly(14697,_scriptDef.levelMin));
return;
}
if(!gMainFrame.userInfo.isMember && evt.currentTarget.name == _difficultyPopup.hostBtn.name)
{
UpsellManager.displayPopup(UpsellManager.DIAMONDS,"customAdventure/");
}
else if(_scriptDef.difficulty != 0)
{
_difficultyPopup.dModeCont.visible = true;
_difficultyPopup.scrim.visible = true;
_difficultyPopup.joinName = evt.currentTarget.name;
}
else
{
if(evt.currentTarget.name == _difficultyPopup.joinBtn.name)
{
QuestXtCommManager.sendQuestCreateJoinPublic(_scriptDef.defId,0,_autoStart);
}
else
{
QuestXtCommManager.sendQuestCreatePrivate(_scriptDef.defId,0,false);
}
destroy();
}
}
private static function onCloseModeCont(evt:MouseEvent) : void
{
evt.stopPropagation();
_difficultyPopup.dModeCont.visible = false;
_difficultyPopup.scrim.visible = false;
}
private static function addEventListeners() : void
{
if(Boolean(_difficultyPopup))
{
_difficultyPopup.addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
_difficultyPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn,false,0,true);
_difficultyPopup.dModeCont.normalBtn.addEventListener(MouseEvent.MOUSE_DOWN,onDifficulty,false,0,true);
_difficultyPopup.dModeCont.hardBtn.addEventListener(MouseEvent.MOUSE_DOWN,onDifficulty,false,0,true);
_difficultyPopup.dModeCont.bx.addEventListener(MouseEvent.MOUSE_DOWN,onCloseModeCont,false,0,true);
_difficultyPopup.joinBtn.addEventListener(MouseEvent.MOUSE_DOWN,onJoinTypeBtn,false,0,true);
_difficultyPopup.hostBtn.addEventListener(MouseEvent.MOUSE_DOWN,onJoinTypeBtn,false,0,true);
}
}
private static function removeEventListeners() : void
{
if(Boolean(_difficultyPopup))
{
_difficultyPopup.removeEventListener(MouseEvent.MOUSE_DOWN,onPopup);
_difficultyPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn);
_difficultyPopup.dModeCont.normalBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onDifficulty);
_difficultyPopup.dModeCont.hardBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onDifficulty);
_difficultyPopup.dModeCont.bx.removeEventListener(MouseEvent.MOUSE_DOWN,onCloseModeCont);
_difficultyPopup.joinBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onJoinTypeBtn);
_difficultyPopup.hostBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onJoinTypeBtn);
}
}
}
}
@@ -0,0 +1,501 @@
package gui
{
import avatar.Avatar;
import avatar.AvatarInfo;
import avatar.AvatarManager;
import avatar.AvatarUtility;
import avatar.AvatarView;
import avatar.AvatarXtCommManager;
import com.sbi.graphics.LayerAnim;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBPopupManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Point;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.GuiPet;
import quest.QuestXtCommManager;
public class AdventureJoin
{
public static const NORMAL_TYPE:String = "normal";
public static const CUSTOM_WAITING_TYPE:String = "custParty";
public static const CUSTOM_SETTINGS_TYPE:String = "custSettings";
public static const NO_LOBBY:String = "noPlayers";
private const MEDIA_ID:int = 2249;
private var _scriptDef:Object;
private var _mediaHelper:MediaHelper;
private var _popup:MovieClip;
private var _numPlayersMC:MovieClip;
private var _guiLayer:DisplayLayer;
private var _inParamsWaiting:Object;
private var _artLoadingSpiral:LoadingSpiral;
private var _closeCallback:Function;
private var _savedParams:Array;
private var _type:String;
private var _modeDropDown:GuiDropdown;
private var _difficulty:int;
private var _numPlayersText:String;
private var _bigPet:GuiPet;
public function AdventureJoin()
{
super();
}
public function init(initScriptDefId:int, type:String, difficulty:int, initCloseCallback:Function) : void
{
this._savedParams = [];
this._scriptDef = QuestXtCommManager.getScriptDef(initScriptDefId);
this._type = type;
this._difficulty = difficulty;
this._guiLayer = GuiManager.guiLayer;
this._closeCallback = initCloseCallback;
DarkenManager.showLoadingSpiral(true);
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(this.MEDIA_ID,this.onMediaLoaded);
}
public function destroy() : void
{
SBPopupManager.closeAll();
TradeManager.closeAllTradingRelatedPopups();
this.removeEventListeners();
if(Boolean(this._bigPet))
{
this._bigPet.destroy();
this._bigPet = null;
}
this._mediaHelper.destroy();
this._mediaHelper = null;
if(Boolean(this._popup))
{
DarkenManager.unDarken(this._popup);
this._guiLayer.removeChild(this._popup);
this._popup = null;
}
}
public function handleWaitResponse(params:Object) : void
{
var maxAllowedPlayers:int = 0;
var minReqPlayers:int = 0;
var c:int = 0;
var w:int = 0;
var wid:int = 0;
var joinedAvatarRef:Avatar = null;
var joinedAvatarInfo:AvatarInfo = null;
if(Boolean(this._popup) && (this._type == NORMAL_TYPE || this._type == CUSTOM_WAITING_TYPE))
{
maxAllowedPlayers = int(this._scriptDef.avatarLimit);
minReqPlayers = 1;
for(c = 1; c < maxAllowedPlayers + 1; c++)
{
while(this._numPlayersMC["p" + c].char.charLayer.numChildren > 0)
{
this._numPlayersMC["p" + c].char.charLayer.removeChildAt(0);
}
this._numPlayersMC["p" + c].char.gotoAndPlay("waiting");
this._numPlayersMC["p" + c].char.nameBar.lastName_txt.text = "";
}
for(w = 2; w < maxAllowedPlayers + 2; w++)
{
if(w < params.length)
{
wid = int(params[w]);
this._numPlayersMC["p" + (w - 1)].char.gotoAndPlay("up");
joinedAvatarRef = AvatarManager.getAvatarBySfsUserId(wid);
if(Boolean(joinedAvatarRef))
{
joinedAvatarInfo = gMainFrame.userInfo.getAvatarInfoByUserName(joinedAvatarRef.userName);
}
if(joinedAvatarRef == null || joinedAvatarInfo == null)
{
this._savedParams[wid] = this._numPlayersMC["p" + (w - 1)];
AvatarXtCommManager.requestAvatarGetBySfsId(wid,this.onAvatarGetReceived);
continue;
}
this.setupAvatar(this._numPlayersMC["p" + (w - 1)],joinedAvatarRef,joinedAvatarInfo.currPet);
}
else
{
this._numPlayersMC["p" + (w - 1)].char.gotoAndPlay("waiting");
LocalizationManager.translateId(this._numPlayersMC["p" + (w - 1)].char.nameBar.firstName_txt,11101);
this._numPlayersMC["p" + (w - 1)].char.nameBar.lastName_txt.text = "";
}
this._numPlayersMC["p" + (w - 1)].char.nameBar.visible = false;
}
}
else
{
this._inParamsWaiting = params;
}
}
private function setupAvatar(positionMC:MovieClip, avt:Avatar, currPet:Object) : void
{
var bigPet:GuiPet = null;
var avtView:AvatarView = null;
var offset:Point = null;
var avName:String = null;
var space:int = 0;
var firstName:String = null;
var lastName:String = null;
if(Boolean(this._scriptDef.playAsPet))
{
bigPet = new GuiPet(0,currPet.lBits,currPet.uBits,currPet.eBits,currPet.type,currPet.name,this.onBigPetLoaded);
positionMC.char.charLayer.addChild(bigPet);
positionMC.char.nameBar.firstName_txt.text = bigPet.petName;
}
else
{
avtView = new AvatarView();
avtView.init(avt);
avtView.playAnim(LayerAnim.AN_HUD_AVT);
avtView.scaleX = 0.7;
avtView.scaleY = 0.7;
offset = AvatarUtility.getAvatarMinigameLobbyOffset(avtView.avTypeId);
avtView.x = offset.x;
avtView.y = offset.y + 5;
positionMC.char.charLayer.addChild(avtView);
avName = avt.avName;
space = avName.indexOf(" ");
if(space != -1)
{
firstName = avName.substr(0,space);
lastName = avName.substr(space + 1,avName.length);
}
else
{
firstName = avName;
}
positionMC.char.nameBar.firstName_txt.text = firstName;
if(Boolean(lastName))
{
positionMC.char.nameBar.lastName_txt.text = lastName;
}
}
positionMC.char.nameBar.visible = false;
}
private function onBigPetLoaded(content:MovieClip, guiPet:GuiPet) : void
{
guiPet.y += 30;
}
private function onAvatarGetReceived(userName:String, status:Boolean, onlineStatus:int, sfsUserId:int) : void
{
var avInfo:AvatarInfo = null;
var perUserAvId:int = 0;
var avt:Avatar = null;
if(Boolean(this._popup))
{
avInfo = gMainFrame.userInfo.getAvatarInfoByUserName(userName);
if(!avInfo)
{
throw new Error("onAvatarSFSGetReceived and avInfo is null");
}
perUserAvId = avInfo.perUserAvId;
avt = AvatarManager.getAvatarByUserName(userName);
if(avt == null)
{
avt = AvatarUtility.generateNew(perUserAvId,null,userName,-1,0);
}
this.setupAvatar(this._savedParams[sfsUserId],avt,avInfo.currPet);
delete this._savedParams[sfsUserId];
}
}
private function onMediaLoaded(img:MovieClip) : void
{
var avtView:AvatarView = null;
var avName:String = null;
var space:int = 0;
var firstName:String = null;
var lastName:String = null;
var w:int = 0;
DarkenManager.showLoadingSpiral(false);
this._popup = MovieClip(img.getChildAt(0));
if(this._type == NO_LOBBY)
{
this._popup.gotoAndStop(NO_LOBBY);
LocalizationManager.translateId(this._popup.contTxt,this._scriptDef.descStrId);
this._artLoadingSpiral = new LoadingSpiral(this._popup.artWindow,this._popup.artWindow.width * 0.5,this._popup.artWindow.height * 0.5);
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(this._scriptDef.mediaRefId,this.onArtLoaded);
}
else
{
this._popup.gotoAndStop(NORMAL_TYPE);
switch(this._scriptDef.avatarLimit)
{
case 4:
this._numPlayersMC = this._popup.fourPlayers;
this._popup.sixPlayers.visible = false;
this._popup.eightPlayers.visible = false;
this._popup.twelvePlayers.visible = false;
break;
case 6:
this._numPlayersMC = this._popup.sixPlayers;
this._popup.fourPlayers.visible = false;
this._popup.eightPlayers.visible = false;
this._popup.twelvePlayers.visible = false;
break;
case 8:
this._numPlayersMC = this._popup.eightPlayers;
this._popup.sixPlayers.visible = false;
this._popup.fourPlayers.visible = false;
this._popup.twelvePlayers.visible = false;
break;
case 12:
this._numPlayersMC = this._popup.twelvePlayers;
this._popup.sixPlayers.visible = false;
this._popup.fourPlayers.visible = false;
this._popup.eightPlayers.visible = false;
}
LocalizationManager.translateId(this._numPlayersMC.contTxt,this._scriptDef.descStrId);
this._artLoadingSpiral = new LoadingSpiral(this._popup.artWindow,this._popup.artWindow.width * 0.5,this._popup.artWindow.height * 0.5);
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(this._scriptDef.mediaRefId,this.onArtLoaded);
if(this._type == NORMAL_TYPE || this._type == CUSTOM_WAITING_TYPE)
{
avtView = new AvatarView();
avtView.init(AvatarManager.playerAvatar);
avtView.playAnim(LayerAnim.AN_HUD_AVT);
this._numPlayersMC.p1.char.charLayer.addChild(avtView);
if(this._type == CUSTOM_WAITING_TYPE)
{
this._popup.playBtn.visible = false;
this._popup.playBg.visible = false;
}
avName = AvatarManager.playerAvatar.avName;
space = avName.indexOf(" ");
if(space != -1)
{
firstName = avName.substr(0,space);
lastName = avName.substr(space + 1,avName.length);
}
else
{
firstName = avName;
}
this._numPlayersMC.p1.char.nameBar.firstName_txt.text = firstName;
if(Boolean(lastName))
{
this._numPlayersMC.p1.char.nameBar.lastName_txt.text = lastName;
}
this._numPlayersMC.p1.char.nameBar.visible = false;
for(w = 2; w < this._scriptDef.avatarLimit + 1; w++)
{
this._numPlayersMC["p" + w].char.gotoAndPlay("waiting");
LocalizationManager.translateId(this._numPlayersMC["p" + w].char.nameBar.firstName_txt,11101);
this._numPlayersMC["p" + w].char.nameBar.lastName_txt.text = "";
}
}
else if(this._type == CUSTOM_SETTINGS_TYPE)
{
this._modeDropDown = new GuiDropdown(this._popup.mode.dropdown);
this._modeDropDown.init(0,0);
}
}
if(this._difficulty == 0)
{
this._popup.hardMode.visible = false;
}
LocalizationManager.translateId(this._popup.titleTxt,this._scriptDef.titleStrId);
this.addEventListeners();
this._popup.x = MainFrame.VIEW_WIDTH * 0.5;
this._popup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._guiLayer.addChild(this._popup);
DarkenManager.darken(this._popup);
if(this._inParamsWaiting != null)
{
this.handleWaitResponse(this._inParamsWaiting);
this._inParamsWaiting = null;
}
}
private function onArtLoaded(img:MovieClip) : void
{
while(this._popup.artWindow.numChildren > 0)
{
this._popup.artWindow.removeChildAt(0);
}
this._popup.artWindow.addChild(img);
if(this._artLoadingSpiral != null)
{
this._artLoadingSpiral.destroy();
this._artLoadingSpiral = null;
}
}
private function onBuddyToggle(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.currentLabel == "on" || evt.currentTarget.currentLabel == "startingOn")
{
evt.currentTarget.gotoAndPlay("off");
}
else
{
evt.currentTarget.gotoAndPlay("on");
}
}
private function onDropDown(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function addEventListeners() : void
{
var i:int = 0;
if(Boolean(this._popup))
{
this._popup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._popup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtn,false,0,true);
if(this._type == NO_LOBBY)
{
this._popup.playBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn,false,0,true);
}
else
{
for(i = 1; i < this._scriptDef.avatarLimit + 1; i++)
{
this._numPlayersMC["p" + i].char.addEventListener(MouseEvent.ROLL_OVER,this.onCharRollOver,false,0,true);
this._numPlayersMC["p" + i].char.addEventListener(MouseEvent.ROLL_OUT,this.onCharRollOut,false,0,true);
}
if(this._type == NORMAL_TYPE)
{
this._popup.playBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn,false,0,true);
}
else if(this._type == CUSTOM_SETTINGS_TYPE)
{
this._popup.buddiesOnly.toggleBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBuddyToggle,false,0,true);
this._modeDropDown.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.onDropDown,false,0,true);
this._popup.inviteBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onInviteBtn,false,0,true);
}
}
}
}
private function removeEventListeners() : void
{
var i:int = 0;
if(Boolean(this._popup))
{
this._popup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._popup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtn);
if(this._type == NO_LOBBY)
{
this._popup.playBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn);
}
else
{
for(i = 1; i < this._scriptDef.avatarLimit + 1; i++)
{
this._numPlayersMC["p" + i].char.removeEventListener(MouseEvent.ROLL_OVER,this.onCharRollOver);
this._numPlayersMC["p" + i].char.removeEventListener(MouseEvent.ROLL_OUT,this.onCharRollOut);
}
if(this._type == NORMAL_TYPE)
{
this._popup.playBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn);
}
else if(this._type == CUSTOM_SETTINGS_TYPE)
{
this._popup.buddiesOnly.toggleBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBuddyToggle);
this._modeDropDown.currDropDown.removeEventListener(MouseEvent.MOUSE_DOWN,this.onDropDown);
this._popup.inviteBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onInviteBtn);
}
}
}
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onCloseBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
QuestXtCommManager.sendQuestJoinCancel();
if(this._closeCallback != null)
{
this._closeCallback();
this._closeCallback = null;
}
else
{
this.destroy();
}
}
private function onPlayBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(evt.currentTarget.isGray))
{
return;
}
var ai:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,gMainFrame.userInfo.myPerUserAvId);
if(Boolean(ai) && ai.questLevel < this._scriptDef.levelMin)
{
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdAndInsertOnly(14697,this._scriptDef.levelMin));
return;
}
if(this._type == CUSTOM_SETTINGS_TYPE)
{
QuestXtCommManager.sendQuestCreatePrivate(this._scriptDef.defId,this._modeDropDown.selectedIdx,false);
}
else if(this._type == NORMAL_TYPE)
{
QuestXtCommManager.sendQuestStartRequest();
}
else if(this._type == NO_LOBBY)
{
QuestXtCommManager.sendQuestCreateJoinPublic(this._scriptDef.defId,0);
}
}
private function onInviteBtn(evt:MouseEvent) : void
{
this.onPlayBtn(evt);
}
private function onCharRollOver(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.gotoAndStop("over");
evt.currentTarget.nameBar.visible = true;
}
private function onCharRollOut(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.gotoAndStop("up");
evt.currentTarget.nameBar.visible = false;
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,618 @@
package gui
{
import avatar.AvatarInfo;
import buddy.Buddy;
import buddy.BuddyEvent;
import buddy.BuddyXtCommManager;
import com.sbi.client.SFClient;
import com.sbi.popup.SBPopup;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.geom.Point;
import flash.utils.Dictionary;
import flash.utils.Timer;
import localization.LocalizationManager;
import room.RoomManagerWorld;
public class BuddyList
{
private static var _playerSearch:PlayerSearch;
private static var _buddyListPopup:SBPopup;
private static var _buddyListContent:MovieClip;
private static var _buddyListWindow:MovieClip;
private static var _buddyListWindow2:MovieClip;
private static var _buddyListBtn:MovieClip;
private static var _scrollbar:SBScrollbar;
private static var _buddyListWorldPopup:MovieClip;
private static var _buddyListWorldWindow:MovieClip;
private static var _scrollbarInWorld:SBScrollbar;
private static var _requestingForWorldBuddyList:Boolean;
private static var _worldSelectCallback:Function;
private static var _currentSelectedUsername:String;
private static var _currentSelectedItem:Object;
private static var _glowTimer:Timer;
private static var _buddyListScrollOffset:int;
private static var _popupLayer:DisplayLayer;
private static var _loadingSpiral:LoadingSpiral;
private static var _worldPopupLoadingSpiral:LoadingSpiral;
public static var listRequested:Boolean;
private static const BUDDY_LIST_X_OFFSET:int = 5;
private static const BUDDY_LIST_Y_OFFSET:int = 49;
public function BuddyList()
{
super();
}
public static function init(init_popupLayer:DisplayLayer, init_buddyListBtn:MovieClip, rebuild:Boolean = false) : void
{
_popupLayer = init_popupLayer;
_buddyListBtn = init_buddyListBtn;
if(!Utility.canBuddy())
{
_buddyListBtn.activateGrayState(true);
}
_buddyListContent = GETDEFINITIONBYNAME("BuddyListContent");
LocalizationManager.translateId(_buddyListContent.buddyListTitleTxt,11250);
_buddyListContent.counterTxt.text = String(BuddyManager.buddyCount) + "/" + String(BuddyManager.MAX_BUDDY_COUNT);
_buddyListPopup = new SBPopup(_popupLayer,GETDEFINITIONBYNAME("BuddyListPopup"),_buddyListContent,false,true,false,false);
_buddyListPopup.closeCallback = buddyListClosedCallback;
_buddyListPopup.x = _buddyListPopup.width * 0.5 + BUDDY_LIST_X_OFFSET;
_buddyListPopup.y = _buddyListPopup.skin.s.ba.height * 0.5 + BUDDY_LIST_Y_OFFSET;
_loadingSpiral = new LoadingSpiral(DisplayObjectContainer(_buddyListPopup.content),-15);
_glowTimer = new Timer(5000);
addListeners();
if(rebuild)
{
onBuddyListChange(null);
}
}
public static function rebuildBtn(init_buddyListBtn:MovieClip) : void
{
if(Boolean(_buddyListBtn))
{
_buddyListBtn.removeEventListener(MouseEvent.MOUSE_DOWN,buddyListBtnHandler);
}
_buddyListBtn = init_buddyListBtn;
if(Utility.canBuddy())
{
_buddyListBtn.addEventListener(MouseEvent.MOUSE_DOWN,buddyListBtnHandler,false,0,true);
}
else
{
_buddyListBtn.activateGrayState(true);
}
_buddyListBtn.glow.visible = false;
LocalizationManager.translateId(_buddyListContent.buddyListTitleTxt,11250);
}
public static function destroy() : void
{
var i:int = 0;
if(Boolean(_buddyListWindow))
{
for(i = 0; i < _buddyListWindow.numChildren; i++)
{
_buddyListWindow.getChildAt(0).removeEventListener(MouseEvent.MOUSE_DOWN,buddyListClickOnBuddyHandler);
_buddyListWindow.removeChildAt(0);
}
}
removeListeners();
if(Boolean(_buddyListWindow2))
{
for(i = 0; i < _buddyListWindow2.numChildren; i++)
{
_buddyListWindow2.removeChildAt(0);
}
}
_buddyListContent = null;
if(Boolean(_buddyListPopup))
{
_buddyListPopup.destroy();
_buddyListPopup = null;
}
}
public static function get visible() : Boolean
{
return _buddyListPopup.visible;
}
public static function closeBuddyList() : void
{
if(Boolean(_buddyListPopup) && _buddyListPopup.visible)
{
_buddyListPopup.close();
GuiManager.toolTip.resetTimerAndSetVisibility();
_buddyListBtn.downToUpState();
}
}
private static function onBuddyListChange(evt:Event) : void
{
var mc:DisplayObject = null;
if(Boolean(_buddyListWorldPopup))
{
buildInWorldBuddyList(null,_currentSelectedItem,null,_currentSelectedUsername);
}
_loadingSpiral.visible = false;
_buddyListContent.counterTxt.text = String(BuddyManager.buddyCount) + "/" + String(BuddyManager.MAX_BUDDY_COUNT);
var scrollYValue:Number = -1;
if(Boolean(_scrollbar))
{
scrollYValue = _scrollbar.scrollYPercentage;
_scrollbar.destroy();
_scrollbar = null;
}
if(_buddyListWindow != null)
{
while(_buddyListWindow.numChildren > 0)
{
mc = _buddyListWindow.getChildAt(0);
mc.removeEventListener(MouseEvent.MOUSE_DOWN,buddyListClickOnBuddyHandler);
_buddyListWindow.removeChild(mc);
mc = null;
}
if(Boolean(_buddyListWindow.parent))
{
_buddyListWindow.parent.removeChild(_buddyListWindow);
}
}
_buddyListWindow = new MovieClip();
MovieClip(_buddyListPopup.content).itemBlock.addChild(_buddyListWindow);
buildBuddyListWindow(_buddyListWindow,true);
if(_buddyListWindow.height >= 19.59 * 10)
{
scrollYValue *= _buddyListWindow.height - 19.59 * 10;
}
_scrollbar = new SBScrollbar();
_scrollbar.init(_buddyListWindow,MovieClip(_buddyListPopup.content).itemBlock.width,19.59 * 10,5,"scrollbar2",19.59,scrollYValue);
}
public static function buildBuddyListWindow(buddyListMC:MovieClip, isForMainHud:Boolean = false) : void
{
var bud:Buddy = null;
var yOffset:Number = NaN;
var i:int = 0;
var bw:MovieClip = null;
var userName:String = null;
var avName:String = null;
var avInfo:AvatarInfo = null;
var dp:Array = [];
var buddyList:Dictionary = BuddyManager.buddyList;
var numBuddies:int = BuddyManager.buddyCount;
_buddyListContent.counterTxt.text = String(BuddyManager.buddyCount) + "/" + String(BuddyManager.MAX_BUDDY_COUNT);
if(Boolean(buddyList) && numBuddies > 0)
{
for each(bud in buddyList)
{
dp.push({
"userName":bud.userName,
"moderatedUserName":bud.userNameModerated,
"onlineStatus":bud.onlineStatus,
"numDaysSinceLastLogin":bud.numDaysSinceLastLogin,
"accountType":bud.accountType
});
}
dp.sortOn(["onlineStatus","userName"],[Array.DESCENDING,Array.CASEINSENSITIVE]);
yOffset = 0;
for(i = 0; i < numBuddies; i++)
{
userName = dp[i].userName;
if(dp[i].onlineStatus == SFClient.STATUS_ONLINE)
{
bw = GETDEFINITIONBYNAME("OnlineBuddyListWindow");
avName = "Avatar Name";
avInfo = gMainFrame.userInfo.getAvatarInfoByUserName(userName);
if(Boolean(avInfo))
{
avName = avInfo.avName;
}
LocalizationManager.updateToFit(bw.avNameTxt,avName);
if(BuddyManager.isBlocked(userName))
{
bw.onOffBlocked.gotoAndStop("blocked");
}
else
{
bw.onOffBlocked.gotoAndStop("online");
}
}
else
{
bw = GETDEFINITIONBYNAME("OfflineBuddyListWindow");
bw.onOffBlocked.gotoAndStop("offline");
}
buddyListMC.addChild(bw);
bw.x = 0;
bw.y = yOffset;
yOffset += bw.height;
bw.userName = userName;
bw.moderatedUserName = dp[i].moderatedUserName;
LocalizationManager.updateToFit(bw.userNameTxt,dp[i].moderatedUserName);
bw.onlineStatus = dp[i].onlineStatus;
bw.daysSinceLastLogin = dp[i].numDaysSinceLastLogin;
bw.accountType = dp[i].accountType;
if(isForMainHud)
{
bw.addEventListener(MouseEvent.MOUSE_DOWN,buddyListClickOnBuddyHandler,false,0,true);
bw.addEventListener(MouseEvent.MOUSE_OVER,buddyListOverBuddyHandler,false,0,true);
bw.addEventListener(MouseEvent.MOUSE_OUT,buddyListOutBuddyHandler,false,0,true);
}
}
}
}
private static function buildInWorldBuddyListWindow(buddyListMC:MovieClip, currentSelectedBuddyUserName:String) : void
{
var bud:Buddy = null;
var yOffset:Number = NaN;
var i:int = 0;
var bw:MovieClip = null;
var userName:String = null;
var dp:Array = [];
var buddyList:Dictionary = BuddyManager.buddyList;
var numBuddies:int = BuddyManager.buddyCount;
if(Boolean(buddyList) && numBuddies > 0)
{
for each(bud in buddyList)
{
dp.push({
"userName":bud.userName,
"moderatedUserName":bud.userNameModerated,
"onlineStatus":bud.onlineStatus
});
}
dp.sortOn(["userName"],[Array.DESCENDING,Array.CASEINSENSITIVE]);
yOffset = 0;
buddyListMC.selectedIndex = -1;
for(i = 0; i < numBuddies; i++)
{
userName = dp[i].userName;
bw = GETDEFINITIONBYNAME("portalBuddyListWindowCont");
buddyListMC.addChild(bw);
bw.x = 0;
bw.y = yOffset;
yOffset += bw.height;
bw.userName = userName;
bw.moderatedUserName = dp[i].moderatedUserName;
LocalizationManager.updateToFit(bw.userNameTxt,dp[i].moderatedUserName);
bw.selectPortalBuddyBox = new GuiRadioButtonSingle(bw.radioBtn,bw.userNameTxt);
if(dp[i].onlineStatus == SFClient.STATUS_OFFLINE_ARCHIVED)
{
bw.selectPortalBuddyBox.gray = true;
}
else
{
if(userName == currentSelectedBuddyUserName)
{
bw.selectPortalBuddyBox.selected = true;
buddyListMC.selectedIndex = i;
_currentSelectedUsername = currentSelectedBuddyUserName;
}
else
{
bw.selectPortalBuddyBox.selected = false;
}
bw.index = i;
bw.addEventListener(MouseEvent.MOUSE_DOWN,worldBuddyListClickOnBuddyHandler,false,0,true);
}
}
}
}
public static function buildInWorldBuddyList(linkBtn:MovieClip, selectedItem:Object, selectCallback:Function, currentSelectedUsername:String) : void
{
if(Boolean(!linkBtn) || Boolean(linkBtn && !closeWorldBuddyList()) || !listRequested)
{
if(Boolean(linkBtn))
{
_worldSelectCallback = selectCallback;
if(_buddyListWorldPopup == null)
{
_buddyListWorldPopup = GETDEFINITIONBYNAME("portalLinkBuddyListPopup");
}
if(_worldPopupLoadingSpiral == null)
{
_worldPopupLoadingSpiral = new LoadingSpiral(_buddyListWorldPopup,_buddyListWorldPopup.width * 0.5,_buddyListWorldPopup.height * 0.5);
}
RoomManagerWorld.instance.layerManager.room_chat.addChild(_buddyListWorldPopup);
_buddyListWorldPopup.x = linkBtn.x - _buddyListWorldPopup.width * 0.5;
_buddyListWorldPopup.y = linkBtn.y + 30;
}
if(!listRequested)
{
_worldPopupLoadingSpiral.visible = true;
BuddyXtCommManager.sendBuddyListRequest();
listRequested = true;
_requestingForWorldBuddyList = true;
_currentSelectedUsername = currentSelectedUsername;
_currentSelectedItem = selectedItem;
}
else
{
if(!linkBtn || !_buddyListWorldWindow || _buddyListWorldWindow.selectedItem != selectedItem)
{
_currentSelectedUsername = currentSelectedUsername;
_currentSelectedItem = selectedItem;
if(Boolean(_scrollbarInWorld))
{
_scrollbarInWorld.destroy();
_scrollbarInWorld = null;
}
_buddyListWorldWindow = new MovieClip();
while(_buddyListWorldPopup.numChildren > 2)
{
_buddyListWorldPopup.removeChildAt(_buddyListWorldPopup.numChildren - 1);
}
_buddyListWorldPopup.itemBlock.addChild(_buddyListWorldWindow);
buildInWorldBuddyListWindow(_buddyListWorldWindow,currentSelectedUsername);
_scrollbarInWorld = new SBScrollbar();
_scrollbarInWorld.init(_buddyListWorldWindow,_buddyListWorldPopup.itemBlock.width,22 * 6,0,"scrollbar2",22);
_buddyListWorldWindow.selectedItem = selectedItem;
}
_worldPopupLoadingSpiral.visible = false;
}
}
}
public static function updateWorldBuddyListPosition(linkBtn:MovieClip) : void
{
if(Boolean(_buddyListWorldPopup) && Boolean(_buddyListWorldPopup.parent))
{
_buddyListWorldPopup.x = linkBtn.x - _buddyListWorldPopup.width * 0.5;
_buddyListWorldPopup.y = linkBtn.y + 30;
}
}
public static function closeWorldBuddyList() : Boolean
{
if(Boolean(_buddyListWorldPopup) && Boolean(_buddyListWorldPopup.parent))
{
_buddyListWorldPopup.parent.removeChild(_buddyListWorldPopup);
_worldSelectCallback = null;
_currentSelectedItem = null;
return true;
}
return false;
}
public static function isOverWorldBuddyList(x:int, y:int) : Boolean
{
var worldPoint:Point = null;
if(Boolean(_buddyListWorldPopup) && Boolean(_buddyListWorldPopup.parent))
{
worldPoint = RoomManagerWorld.instance.convertWorldToScreen(x,y);
return _buddyListWorldPopup.hitTestPoint(worldPoint.x,worldPoint.y,true);
}
return false;
}
public static function destroyInWorldBuddyList() : void
{
closeWorldBuddyList();
_buddyListWorldPopup = null;
_buddyListWorldWindow = null;
if(Boolean(_scrollbarInWorld))
{
_scrollbarInWorld.destroy();
_scrollbarInWorld = null;
}
_worldSelectCallback = null;
_currentSelectedUsername = "";
_currentSelectedItem = null;
}
private static function worldBuddyListClickOnBuddyHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
if(_worldSelectCallback != null)
{
if(_currentSelectedUsername == evt.currentTarget.userName)
{
_buddyListWorldWindow.selectedIndex = -1;
_currentSelectedUsername = "";
}
else
{
if(_buddyListWorldWindow.selectedIndex != -1)
{
MovieClip(_buddyListWorldWindow.getChildAt(_buddyListWorldWindow.selectedIndex)).selectPortalBuddyBox.selected = false;
}
_buddyListWorldWindow.selectedIndex = evt.currentTarget.index;
_currentSelectedUsername = evt.currentTarget.userName;
}
_worldSelectCallback(_currentSelectedUsername);
}
}
private static function buddyListClickOnBuddyHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
var buddyWindow:MovieClip = MovieClip(evt.currentTarget);
if(buddyWindow.userName.indexOf("Liza") < 0)
{
BuddyCard.showBuddyCard({
"userName":buddyWindow.userName,
"onlineStatus":buddyWindow.onlineStatus
});
}
GuiManager.toolTip.resetTimerAndSetVisibility();
AJAudio.playSubMenuBtnClick();
}
private static function buddyListOverBuddyHandler(evt:MouseEvent) : void
{
var displayText:String = null;
var offsetX:int = _buddyListPopup.x - _buddyListWindow.width * 0.5 + 5;
var offsetY:int = _buddyListPopup.y - 19.6 * 4.5 - _scrollbar.scrollYValue;
var MC:MovieClip = MovieClip(evt.currentTarget.getChildAt(0));
var daysSinceLastLogin:int = int(evt.currentTarget.daysSinceLastLogin);
if(Boolean(evt.currentTarget.avNameTxt))
{
displayText = LocalizationManager.translateIdOnly(11251);
}
else if(daysSinceLastLogin == 0)
{
displayText = LocalizationManager.translateIdOnly(11252);
}
else if(daysSinceLastLogin == 1)
{
displayText = LocalizationManager.translateIdOnly(11253);
}
else if(daysSinceLastLogin > 1 && daysSinceLastLogin < 31)
{
displayText = LocalizationManager.translateIdAndInsertOnly(11254,daysSinceLastLogin);
}
else if(daysSinceLastLogin > 30 || daysSinceLastLogin == -1)
{
displayText = LocalizationManager.translateIdOnly(11255);
}
else
{
displayText = LocalizationManager.translateIdOnly(11256);
}
GuiManager.toolTip.init(GuiManager.guiLayer,displayText,0,0);
GuiManager.toolTip.setPos(offsetX + MC.x + GuiManager.toolTip.width * 0.5,offsetY + evt.currentTarget.y);
GuiManager.toolTip.startTimer(evt);
}
private static function buddyListOutBuddyHandler(evt:MouseEvent) : void
{
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private static function buddyListBtnHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(!m.currentTarget.isGray)
{
if(!listRequested)
{
BuddyXtCommManager.sendBuddyListRequest();
listRequested = true;
}
GuiManager.onExitRoom(true);
if(_buddyListPopup.visible)
{
_buddyListPopup.close();
}
else
{
glowTimerHandler(null);
_buddyListPopup.open();
}
}
}
private static function buddyListClosedCallback() : void
{
_buddyListBtn.downToUpState();
_buddyListScrollOffset = 0;
}
public static function startBuddyListBtnGlow() : void
{
if(Boolean(_buddyListBtn))
{
_buddyListBtn.glow.visible = true;
}
AJAudio.playBuddyOnlineOfflineSound();
if(_glowTimer.running)
{
_glowTimer.stop();
}
_glowTimer.start();
}
private static function glowTimerHandler(te:TimerEvent) : void
{
_glowTimer.stop();
if(Boolean(_buddyListBtn))
{
_buddyListBtn.glow.visible = false;
}
}
private static function onSearchBtn(e:MouseEvent) : void
{
e.stopPropagation();
_playerSearch = new PlayerSearch();
_playerSearch.init();
DarkenManager.showLoadingSpiral(true);
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private static function onSearchBtnOver(e:MouseEvent) : void
{
e.stopPropagation();
GuiManager.toolTip.init(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14638),180,305);
GuiManager.toolTip.startTimer(e);
}
private static function onSearchBtnOut(e:MouseEvent) : void
{
e.stopPropagation();
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private static function addListeners() : void
{
_glowTimer.addEventListener(TimerEvent.TIMER,glowTimerHandler,false,0,true);
BuddyManager.eventDispatcher.addEventListener(BuddyEvent.BUDDY_LIST,onBuddyListChange,false,0,true);
BuddyManager.eventDispatcher.addEventListener(BuddyEvent.BUDDY_CHANGED,onBuddyListChange,false,0,true);
if(Utility.canBuddy())
{
_buddyListBtn.addEventListener(MouseEvent.MOUSE_DOWN,buddyListBtnHandler,false,0,true);
}
_buddyListContent.searchBtn.addEventListener(MouseEvent.MOUSE_DOWN,onSearchBtn,false,0,true);
_buddyListContent.searchBtn.addEventListener(MouseEvent.MOUSE_OVER,onSearchBtnOver,false,0,true);
_buddyListContent.searchBtn.addEventListener(MouseEvent.MOUSE_OUT,onSearchBtnOut,false,0,true);
}
private static function removeListeners() : void
{
if(Utility.canBuddy())
{
_buddyListBtn.removeEventListener(MouseEvent.MOUSE_DOWN,buddyListBtnHandler);
}
_glowTimer.removeEventListener(TimerEvent.TIMER,glowTimerHandler);
BuddyManager.eventDispatcher.removeEventListener(BuddyEvent.BUDDY_LIST,onBuddyListChange);
BuddyManager.eventDispatcher.removeEventListener(BuddyEvent.BUDDY_CHANGED,onBuddyListChange);
if(Boolean(_buddyListContent))
{
_buddyListContent.searchBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onSearchBtn);
_buddyListContent.searchBtn.removeEventListener(MouseEvent.MOUSE_OVER,onSearchBtnOver);
_buddyListContent.searchBtn.removeEventListener(MouseEvent.MOUSE_OUT,onSearchBtnOut);
}
}
}
}
@@ -0,0 +1,532 @@
package gui
{
import avatar.AvatarInfo;
import avatar.UserInfo;
import buddy.Buddy;
import buddy.BuddyEvent;
import buddy.BuddyTimer;
import buddy.BuddyXtCommManager;
import com.sbi.client.SFClient;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBPopupManager;
import flash.display.MovieClip;
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
import flash.utils.Dictionary;
import flash.utils.Timer;
import localization.LocalizationManager;
public class BuddyManager
{
private static var _numOnlineBuddies:int;
private static var _buddyList:Dictionary;
private static var _blockedList:Dictionary;
private static var _buddyRequestList:Dictionary;
private static var _buddyRequestCleanupTimer:Timer;
private static var _buddyRequestPopups:Dictionary;
private static var _confirmBuddyRequestPopups:Dictionary;
private static var _eventDispatcher:EventDispatcher;
private static var _mainHud:MovieClip;
private static var _popupLayer:DisplayLayer;
public static const MAX_BUDDY_COUNT:int = 100;
public static const WARNING_BUDDY_COUNT:int = 95;
private static const PERMISSION_TIMEOUT:int = 20000;
private static const BUDDY_REQUEST_TIMEOUT:int = 30000;
public function BuddyManager()
{
super();
}
public static function init(init_popupLayer:DisplayLayer, init_buddyListBtn:MovieClip) : void
{
_buddyList = new Dictionary(false);
_blockedList = new Dictionary(false);
_buddyRequestList = new Dictionary(false);
_buddyRequestPopups = new Dictionary(false);
_confirmBuddyRequestPopups = new Dictionary(false);
_popupLayer = init_popupLayer;
_eventDispatcher = new EventDispatcher();
BuddyCard.init(_popupLayer);
BuddyList.init(_popupLayer,init_buddyListBtn);
_buddyRequestCleanupTimer = new Timer(BUDDY_REQUEST_TIMEOUT);
_buddyRequestCleanupTimer.addEventListener(TimerEvent.TIMER,buddyRequestCleanupTimerHandler,false,0,true);
_buddyRequestCleanupTimer.start();
}
public static function destroy() : void
{
var bud:Buddy = null;
var b:Object = null;
var br:Object = null;
var brp:Object = null;
var cbrp:Object = null;
for each(bud in _buddyList)
{
bud = null;
}
for each(b in _blockedList)
{
b = null;
}
for each(br in _buddyRequestList)
{
br = null;
}
for each(brp in _buddyRequestPopups)
{
brp = null;
}
for each(cbrp in _confirmBuddyRequestPopups)
{
cbrp = null;
}
_eventDispatcher = null;
_buddyList = null;
_blockedList = null;
BuddyCard.destroy();
BuddyList.destroy();
}
public static function get eventDispatcher() : EventDispatcher
{
return _eventDispatcher;
}
public static function isBuddy(userName:String) : Boolean
{
return _buddyList[userName.toLowerCase()] != null;
}
public static function isBlocked(userName:String) : Boolean
{
return _blockedList[userName.toLowerCase()] != null;
}
public static function getBuddyByUserName(userName:String) : Buddy
{
return _buddyList[userName.toLowerCase()];
}
public static function get buddyCount() : int
{
var key:Object = null;
var i:int = 0;
for(key in _buddyList)
{
i++;
}
return i;
}
public static function addRemoveBuddy(userName:String, userNameModerated:String, add:Boolean) : void
{
var lcUserName:String = null;
var msg:String = null;
var br:Object = null;
if(add)
{
lcUserName = userName.toLowerCase();
if(buddyCount < MAX_BUDDY_COUNT)
{
br = _buddyRequestList[lcUserName];
if(br == null || br.expires < new Date().getTime())
{
BuddyXtCommManager.sendBuddyAddRequest(userName);
_buddyRequestList[lcUserName] = {
"userName":userName,
"expires":new Date().getTime() + 30000,
"isAccepting":true
};
}
else
{
if(_buddyRequestList[lcUserName] != null)
{
if(!_buddyRequestList[lcUserName].isAccepting)
{
_buddyRequestPopups[lcUserName] = new SBOkPopup(_popupLayer,LocalizationManager.translateIdAndInsertOnly(14706,userNameModerated));
return;
}
}
_buddyRequestPopups[lcUserName] = new SBOkPopup(_popupLayer,LocalizationManager.translateIdAndInsertOnly(14707,userNameModerated));
}
}
else
{
new SBOkPopup(_popupLayer,LocalizationManager.translateIdOnly(14708));
}
}
else
{
BuddyXtCommManager.sendBuddyDeleteRequest(userName);
}
}
private static function buddyAddRequestCallback(o:Object) : void
{
var timer:Timer = _confirmBuddyRequestPopups[o.passback.toLowerCase()].timer;
if(Boolean(timer))
{
timer.reset();
timer = null;
}
var popup:BuddyRequest = _confirmBuddyRequestPopups[o.passback.toLowerCase()].popup;
if(Boolean(popup))
{
popup.destroy();
popup = null;
}
delete _confirmBuddyRequestPopups[o.passback.toLowerCase()];
if(buddyCount < MAX_BUDDY_COUNT)
{
BuddyXtCommManager.sendBuddyConfirmRequest(o.passback,o.status);
}
else
{
new SBOkPopup(_popupLayer,LocalizationManager.translateIdOnly(14708));
}
}
public static function buddyListResponseHandler(data:Object) : void
{
var bud:Buddy = null;
var userName:String = null;
var userNameModerationFlag:int = 0;
var avName:String = null;
var perUserAvId:int = 0;
var accountTypeId:int = 0;
var budUserInfo:UserInfo = null;
var avInfo:AvatarInfo = null;
var offBud:Buddy = null;
var offUserName:String = null;
var offUserNameModerationFlag:int = 0;
var offNumDaysSinceLastLogin:int = 0;
var offAccountType:int = 0;
var offOnlineStatus:int = 0;
_buddyList = new Dictionary(true);
var i:int = 3;
var numOnlineBuddies:int = int(data[i++]);
for(var j:int = 0; j < numOnlineBuddies; j++)
{
bud = new Buddy();
userName = data[i++];
userNameModerationFlag = int(data[i++]);
avName = data[i++];
perUserAvId = int(data[i++]);
accountTypeId = int(data[i++]);
bud.init(userName,userNameModerationFlag,SFClient.STATUS_ONLINE,accountTypeId);
_buddyList[userName.toLowerCase()] = bud;
budUserInfo = gMainFrame.userInfo.getUserInfoByUserName(userName);
if(!budUserInfo)
{
avInfo = new AvatarInfo();
avInfo.init(perUserAvId,avName,userName);
budUserInfo = new UserInfo();
budUserInfo.init(userName,null,perUserAvId);
budUserInfo.addAvatarToList(avInfo);
budUserInfo.accountType = accountTypeId;
budUserInfo.userNameModeratedFlag = userNameModerationFlag;
gMainFrame.userInfo.setUserInfoByUserName(userName,budUserInfo);
}
else
{
if(!budUserInfo.getAvatarInfoByPerUserAvId(perUserAvId))
{
avInfo = new AvatarInfo();
avInfo.init(perUserAvId,avName,userName);
budUserInfo.addAvatarToList(avInfo);
}
budUserInfo.userNameModeratedFlag = userNameModerationFlag;
budUserInfo.accountType = accountTypeId;
budUserInfo.currPerUserAvId = perUserAvId;
}
}
var numOfflineBuddies:int = int(data[i++]);
for(j = 0; j < numOfflineBuddies; j++)
{
offBud = new Buddy();
offUserName = data[i++];
offUserNameModerationFlag = int(data[i++]);
offNumDaysSinceLastLogin = int(data[i++]);
offAccountType = int(data[i++]);
offOnlineStatus = offNumDaysSinceLastLogin > -1 ? SFClient.STATUS_OFFLINE_ACTIVE : SFClient.STATUS_OFFLINE_ARCHIVED;
if(offOnlineStatus == SFClient.STATUS_OFFLINE_ARCHIVED)
{
offUserNameModerationFlag = 1;
}
offBud.init(offUserName,offUserNameModerationFlag,offOnlineStatus,offAccountType,offNumDaysSinceLastLogin);
_buddyList[offUserName.toLowerCase()] = offBud;
}
BuddyList.listRequested = true;
var ble:BuddyEvent = new BuddyEvent(BuddyEvent.BUDDY_LIST);
_eventDispatcher.dispatchEvent(ble);
}
public static function blockedListResponseHandler(data:Object) : void
{
var i:int = 3;
var blockedCount:int = int(data[i++]);
_blockedList = new Dictionary(true);
for(var j:int = 0; j < blockedCount; j++)
{
_blockedList[data[i++].toLowerCase()] = "1";
}
}
public static function buddyAddRequestResponseHandler(flag:int, userName:String, userNameModerationFlag:int) : void
{
var avInfo:AvatarInfo = null;
var confirmTimer:BuddyTimer = null;
var moderatedUserName:String = userNameModerationFlag > 0 ? userName : LocalizationManager.translateIdOnly(LocalizationManager.NEW_JAMMER_USERNAME);
if(flag == 0)
{
if(!_buddyList[userName.toLowerCase()])
{
avInfo = gMainFrame.userInfo.getAvatarInfoByUserName(userName);
confirmTimer = new BuddyTimer(BUDDY_REQUEST_TIMEOUT);
confirmTimer.userName = userName.toLowerCase();
confirmTimer.addEventListener(TimerEvent.TIMER,confirmPopupTimerHandler,false,0,true);
_confirmBuddyRequestPopups[userName.toLowerCase()] = {
"popup":new BuddyRequest(userName,buddyAddRequestCallback,BuddyRequest.ACCEPT_REJECT),
"timer":confirmTimer
};
confirmTimer.start();
}
}
else if(flag == 1)
{
_buddyRequestPopups[userName.toLowerCase()] = new SBOkPopup(_popupLayer,LocalizationManager.translateIdAndInsertOnly(14707,moderatedUserName));
}
else if(flag == 2)
{
new SBOkPopup(_popupLayer,LocalizationManager.translateIdAndInsertOnly(14710,userName));
}
else if(flag == 3)
{
if(_buddyRequestList[userName.toLowerCase()] != null)
{
_buddyRequestList[userName.toLowerCase()].isAccepting = false;
}
new SBOkPopup(_popupLayer,LocalizationManager.translateIdAndInsertOnly(14706,moderatedUserName));
}
}
public static function buddyStatusResponseHandler(userName:String, userNameModerationFlag:int, isOnline:Boolean, accountTypeId:int, buddyFlag:int, newUserName:String = null, avName:String = null, perUserAvId:int = -1) : void
{
var avInfo:AvatarInfo = null;
var moderatedUserName:String = null;
var lcUserName:String = userName.toLowerCase();
var bud:Buddy = _buddyList[lcUserName];
var userInfo:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(userName);
if(!userInfo)
{
userInfo = new UserInfo();
userInfo.init(userName);
userInfo.userNameModeratedFlag = userNameModerationFlag;
gMainFrame.userInfo.setUserInfoByUserName(userName,userInfo);
}
userInfo.accountType = accountTypeId;
if(Boolean(avName))
{
avInfo = userInfo.getAvatarInfoByPerUserAvId(perUserAvId);
if(!avInfo)
{
avInfo = new AvatarInfo();
avInfo.init(perUserAvId,avName,userName);
userInfo.addAvatarToList(avInfo);
}
if(perUserAvId > 0)
{
userInfo.currPerUserAvId = perUserAvId;
}
}
if(buddyFlag != 3 && buddyFlag != 4)
{
if(Boolean(bud))
{
bud.userName = userName;
bud.userNameModeratedFlag = userNameModerationFlag;
if(bud.isOnline && !isOnline)
{
--_numOnlineBuddies;
bud.numDaysSinceLastLogin = 0;
}
else if(!bud.isOnline && isOnline)
{
if(Utility.canBuddy())
{
BuddyList.startBuddyListBtnGlow();
}
++_numOnlineBuddies;
}
bud.onlineStatus = isOnline ? SFClient.STATUS_ONLINE : SFClient.STATUS_OFFLINE_ACTIVE;
}
else
{
bud = new Buddy();
bud.init(userName,userNameModerationFlag,isOnline ? SFClient.STATUS_ONLINE : SFClient.STATUS_OFFLINE_ACTIVE,accountTypeId);
_buddyList[lcUserName] = bud;
if(buddyFlag == 1)
{
if(_buddyRequestPopups[lcUserName] != null)
{
_buddyRequestPopups[lcUserName].destroy();
delete _buddyRequestPopups[lcUserName];
}
SBPopupManager.nonSBPopups.push(new BuddyRequest(userName,null,BuddyRequest.CONFIRMATION));
}
else if(buddyFlag == 2)
{
SBPopupManager.nonSBPopups.push(new BuddyRequest(userName,null,BuddyRequest.CONFIRMATION));
}
}
}
else
{
if(Boolean(bud))
{
bud.userName = newUserName;
bud.userNameModeratedFlag = userNameModerationFlag;
if(bud.isOnline && !isOnline)
{
--_numOnlineBuddies;
}
else if(!bud.isOnline && isOnline)
{
BuddyList.startBuddyListBtnGlow();
++_numOnlineBuddies;
}
bud.onlineStatus = isOnline ? SFClient.STATUS_ONLINE : SFClient.STATUS_OFFLINE_ACTIVE;
delete _buddyList[lcUserName];
_buddyList[newUserName.toLowerCase()] = bud;
BuddyCard.userNameChange(userName,newUserName,bud.userNameModerated);
gMainFrame.userInfo.changeUserName(userName,newUserName,userNameModerationFlag);
userName = newUserName;
}
if(isBlocked(lcUserName))
{
moderatedUserName = userNameModerationFlag > 0 ? newUserName : LocalizationManager.translateIdOnly(LocalizationManager.NEW_JAMMER_USERNAME);
BuddyCard.userNameChange(userName,newUserName,moderatedUserName);
gMainFrame.userInfo.changeUserName(userName,newUserName,userNameModerationFlag);
userName = newUserName;
delete _blockedList[lcUserName];
_blockedList[newUserName.toLowerCase()] = "1";
}
}
var ble:BuddyEvent = new BuddyEvent(BuddyEvent.BUDDY_CHANGED);
ble.userName = userName;
_eventDispatcher.dispatchEvent(ble);
}
public static function buddyDeleteResponseHandler(userName:String) : void
{
var ble:BuddyEvent = null;
var lcUserName:String = userName.toLowerCase();
if(Boolean(_buddyList[lcUserName]))
{
delete _buddyList[lcUserName];
delete _buddyRequestList[lcUserName];
ble = new BuddyEvent(BuddyEvent.BUDDY_CHANGED);
ble.userName = userName;
_eventDispatcher.dispatchEvent(ble);
}
}
public static function buddyBlockResponseHandler(userName:String, didBlockSucceed:Boolean) : void
{
var ble:BuddyEvent = null;
if(didBlockSucceed)
{
_blockedList[userName.toLowerCase()] = "1";
ble = new BuddyEvent(BuddyEvent.BUDDY_CHANGED);
ble.userName = userName;
_eventDispatcher.dispatchEvent(ble);
}
}
public static function buddyUnblockResponseHandler(userName:String, didUnblockSucceed:Boolean) : void
{
var ble:BuddyEvent = null;
if(didUnblockSucceed)
{
delete _blockedList[userName.toLowerCase()];
ble = new BuddyEvent(BuddyEvent.BUDDY_CHANGED);
ble.userName = userName;
_eventDispatcher.dispatchEvent(ble);
}
}
public static function get buddyList() : Dictionary
{
return _buddyList;
}
public static function get blockedList() : Dictionary
{
return _blockedList;
}
public static function avatarListResponse() : void
{
var ble:BuddyEvent = new BuddyEvent(BuddyEvent.BUDDY_LIST);
BuddyManager.eventDispatcher.dispatchEvent(ble);
}
private static function buddyRequestCleanupTimerHandler(evt:TimerEvent) : void
{
var br:Object = null;
var userName:String = null;
for each(br in _buddyRequestList)
{
userName = br.userName.toLowerCase();
if(br == null || br.expires < new Date().getTime())
{
delete _buddyRequestList[userName];
if(_buddyRequestPopups[userName] != null)
{
delete _buddyRequestPopups[userName];
}
}
}
}
private static function confirmPopupTimerHandler(evt:TimerEvent) : void
{
var userName:String = null;
var o:Object = null;
var confirmTimer:BuddyTimer = BuddyTimer(evt.currentTarget);
if(Boolean(confirmTimer))
{
userName = confirmTimer.userName;
confirmTimer.stop();
confirmTimer = null;
o = _confirmBuddyRequestPopups[userName];
if(o != null)
{
if(Boolean(o.popup))
{
o.popup.destroy();
o.popup = null;
}
delete _confirmBuddyRequestPopups[userName];
}
}
}
}
}
@@ -0,0 +1,244 @@
package gui
{
import avatar.Avatar;
import avatar.AvatarInfo;
import avatar.AvatarManager;
import avatar.AvatarUtility;
import avatar.AvatarView;
import avatar.AvatarXtCommManager;
import avatar.UserInfo;
import com.sbi.graphics.LayerAnim;
import com.sbi.popup.SBPopupManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Point;
import loader.MediaHelper;
import localization.LocalizationManager;
public class BuddyRequest
{
public static const ACCEPT_REJECT:int = 1;
public static const CONFIRMATION:int = 2;
private var _mediaHelper:MediaHelper;
private var _requestPopup:MovieClip;
private var _playerUserName:String;
private var _mainAvatarView:AvatarView;
private var _loadingSpiralAvatar:LoadingSpiral;
private var _mainAvatar:Avatar;
private var _requestCallback:Function;
private var _popupType:int;
public function BuddyRequest(playerUserName:String, requestCallback:Function, popupType:int)
{
super();
DarkenManager.showLoadingSpiral(true);
this._playerUserName = playerUserName;
this._requestCallback = requestCallback;
this._popupType = popupType;
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(2778,this.onMediaLoaded);
}
public function destroy() : void
{
SBPopupManager.destroySpecificNonSBPopup(this);
if(Boolean(this._mediaHelper))
{
this._mediaHelper.destroy();
this._mediaHelper = null;
}
if(Boolean(this._mainAvatarView))
{
this._mainAvatarView.destroy();
this._mainAvatarView = null;
}
this._mainAvatar = null;
this.removeEventListeners();
DarkenManager.unDarken(this._requestPopup);
GuiManager.guiLayer.removeChild(this._requestPopup);
this._requestPopup = null;
}
private function onMediaLoaded(img:MovieClip) : void
{
DarkenManager.showLoadingSpiral(false);
if(Boolean(img))
{
this._requestPopup = MovieClip(img.getChildAt(0));
this._requestPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._requestPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
GuiManager.guiLayer.addChild(this._requestPopup);
DarkenManager.darken(this._requestPopup);
this.setupRequestPopup();
this.addEventListeners();
}
}
private function setupRequestPopup() : void
{
this._requestPopup.gotoAndStop(this._popupType);
this._loadingSpiralAvatar = new LoadingSpiral(this._requestPopup.charBox);
var avInfo:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUserName(this._playerUserName);
if(!avInfo)
{
AvatarXtCommManager.requestAvatarGet(this._playerUserName,this.onAvatarGetReceived);
}
else
{
this.onAvatarGetReceived(this._playerUserName,true,0,avInfo);
}
}
private function onAvatarGetReceived(userName:String, status:Boolean, onlineStatus:int, avInfo:AvatarInfo = null) : void
{
var ui:UserInfo = null;
var numBuddies:int = 0;
if(status && userName == this._playerUserName)
{
if(!avInfo)
{
avInfo = gMainFrame.userInfo.getAvatarInfoByUserName(userName);
if(!avInfo)
{
throw new Error("onAvatarGetReceived and avInfo is null");
}
}
ui = gMainFrame.userInfo.getUserInfoByUserName(this._playerUserName);
if(avInfo.isMember)
{
this._requestPopup.nonmember.visible = false;
this._requestPopup.userName_txt.visible = false;
this._requestPopup.member.setNubType("buddy",false);
this._requestPopup.member.setColorAndBadge(ui.nameBarData);
this._requestPopup.member.isBlocked = false;
this._requestPopup.member.setAvName(ui.getModeratedUserName(),false);
this._requestPopup.member.mouseEnabled = false;
this._requestPopup.member.mouseChildren = false;
}
else
{
this._requestPopup.member.visible = false;
this._requestPopup.userName_txt.visible = true;
this._requestPopup.userName_txt.text = ui.getModeratedUserName();
}
if(this._popupType == CONFIRMATION)
{
numBuddies = BuddyManager.buddyCount;
if(numBuddies >= BuddyManager.WARNING_BUDDY_COUNT)
{
LocalizationManager.translateIdAndInsert(this._requestPopup.txt,18509,BuddyManager.MAX_BUDDY_COUNT - numBuddies);
}
else
{
LocalizationManager.translateId(this._requestPopup.txt,9491);
}
}
this._mainAvatar = AvatarManager.getAvatarByUserName(this._playerUserName);
if(this._mainAvatar == null)
{
this._mainAvatar = AvatarUtility.generateNew(avInfo.perUserAvId,null,this._playerUserName,-1,0,this.onAvatarItemData);
}
this.drawMainAvatar(this._mainAvatar);
}
}
public function onAvatarItemData() : void
{
if(this._mainAvatar != null)
{
this.drawMainAvatar(this._mainAvatar);
}
}
private function drawMainAvatar(avt:Avatar) : void
{
if(Utility.isOcean(avt.enviroTypeFlag))
{
if(Utility.isLand(avt.enviroTypeFlag))
{
this._requestPopup.charBox.gotoAndStop(3);
}
else
{
this._requestPopup.charBox.gotoAndStop(2);
}
}
else
{
this._requestPopup.charBox.gotoAndStop(1);
}
this._mainAvatarView = new AvatarView();
this._mainAvatarView.init(avt);
if(avt.avTypeId >= 0)
{
this._mainAvatarView.playAnim(LayerAnim.AN_BBCARD,false,LayerAnim.PLAY_ONE_SHOT,this.positionAndAddMainAvatarView);
}
}
private function positionAndAddMainAvatarView(layerAnim:LayerAnim, animId:int) : void
{
var offset:Point = BuddyCard.getAvOffsetByDefId(this._mainAvatarView.avTypeId);
this._mainAvatarView.x = offset.x;
this._mainAvatarView.y = offset.y;
if(Boolean(this._requestPopup))
{
this._requestPopup.charBox.addChild(this._mainAvatarView);
}
this._loadingSpiralAvatar.visible = false;
}
private function addEventListeners() : void
{
if(this._requestPopup.currentFrame == 1)
{
this._requestPopup.cancelBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onCancelBtn,false,0,true);
}
this._requestPopup.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onOkBtn,false,0,true);
}
private function removeEventListeners() : void
{
if(this._requestPopup.currentFrame == 1)
{
this._requestPopup.cancelBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCancelBtn);
}
this._requestPopup.okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onOkBtn);
}
private function onOkBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
if(this._requestPopup.currentFrame == 1)
{
this._requestCallback({
"status":true,
"passback":this._playerUserName
});
}
else
{
this.destroy();
}
}
private function onCancelBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this._requestCallback({
"status":false,
"passback":this._playerUserName
});
}
}
}
@@ -0,0 +1,782 @@
package gui
{
import com.sbi.analytics.SBTracker;
import com.sbi.client.KeepAlive;
import com.sbi.corelib.audio.SBAudio;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.display.StageQuality;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.geom.Rectangle;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;
import game.MinigameManager;
import loader.JCDefHelper;
import loader.MediaHelper;
import localization.LocalizationManager;
import movie.MovieManager;
public class BulletinBoard
{
private static const BBOARD_MEDIA_ID:int = 563;
private static const CAL_MEDIA_ID:int = 564;
private static const GALLERY_MEDIA_ID:int = 565;
private static const COSTUME_MEDIA_ID:int = 1634;
private static const TUT_STREAM_GL_ID:int = 8;
private static const ART_MEDIA_GL_ID:int = 23;
private static const EVT_LOC_ID:int = 670;
private static const DESC_TXT_Y_POS:Number = 201.35;
private var _bulletinBoardPopup:MovieClip;
private var _calendarPopup:MovieClip;
private var _costumePopup:MovieClip;
private var _tutorialMediaId:int;
private var _tutorialStreamId:int;
private var _tutorialText:String;
private var _tutorialSubtitleId:int;
private var _artGalleryPopup:MovieClip;
private var _artMediaIds:Array;
private var _artObjects:Object;
private var _artPageNum:int;
private var _jcLoader:JCDefHelper;
private var _howlTextField:TextField;
private var _howlsTextArray:Array;
private var _howlTimer:Timer;
private var _scrollRect:Rectangle;
private var _howlIndex:int;
private var _guiLayer:DisplayLayer;
private var _loadingMediaHelper:MediaHelper;
private var _mediaHelpers:Array;
private var _tutorialSpiral:LoadingSpiral;
private var _artSpiral:LoadingSpiral;
private var _closeCallback:Function;
private var _gameLaunchObj:Object;
private var _introMediaHelper:MediaHelper;
private var _introCloseId:int;
private var _intro:MovieClip;
private var _introCloseBtn:MovieClip;
private var _musicMutedByPlayer:Boolean;
public function BulletinBoard()
{
super();
}
public function init(guiLayer:DisplayLayer, initCloseCallback:Function) : void
{
DarkenManager.showLoadingSpiral(true);
this._guiLayer = guiLayer;
this._closeCallback = initCloseCallback;
this._mediaHelpers = [];
this._artObjects = new Object();
this._tutorialSpiral = new LoadingSpiral();
this._artSpiral = new LoadingSpiral();
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(BBOARD_MEDIA_ID,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
public function destroy() : void
{
if(Boolean(this._bulletinBoardPopup))
{
this.removeBoardListeners();
this._guiLayer.removeChild(this._bulletinBoardPopup);
DarkenManager.unDarken(this._bulletinBoardPopup);
KeepAlive.stopKATimer(this._bulletinBoardPopup);
this._bulletinBoardPopup = null;
}
if(Boolean(this._artGalleryPopup))
{
this.removeGalleryListeners();
if(Boolean(this._artGalleryPopup.parent) && this._artGalleryPopup.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._artGalleryPopup);
}
DarkenManager.unDarken(this._artGalleryPopup);
this._artGalleryPopup = null;
}
if(Boolean(this._calendarPopup))
{
if(Boolean(this._calendarPopup.parent) && this._calendarPopup.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._calendarPopup);
}
this._calendarPopup = null;
}
if(Boolean(this._costumePopup))
{
if(Boolean(this._costumePopup.parent) && this._costumePopup.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._costumePopup);
}
this._costumePopup = null;
}
if(Boolean(this._loadingMediaHelper))
{
this._loadingMediaHelper.destroy();
this._loadingMediaHelper = null;
}
if(Boolean(this._tutorialSpiral))
{
this._tutorialSpiral.destroy();
this._tutorialSpiral = null;
}
if(Boolean(this._artSpiral))
{
this._artSpiral.destroy();
this._artSpiral = null;
}
if(Boolean(this._intro))
{
this._intro.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown);
this._intro = null;
}
if(Boolean(this._introCloseBtn))
{
this._introCloseBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onIntroClose);
this._introCloseBtn = null;
}
if(Boolean(this._howlTimer))
{
this._howlTimer.reset();
this._howlTimer = null;
}
this._artObjects = null;
this._artMediaIds = null;
this._mediaHelpers = null;
}
public function refresh() : void
{
if(Boolean(this._bulletinBoardPopup))
{
if(Boolean(this._artGalleryPopup) && this._artGalleryPopup.visible)
{
this.removeGalleryListeners();
if(Boolean(this._artGalleryPopup.parent) && this._artGalleryPopup.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._artGalleryPopup);
}
DarkenManager.unDarken(this._artGalleryPopup);
this._artGalleryPopup = null;
}
this._artSpiral.setNewParent(this._bulletinBoardPopup.artItemWindow,this._bulletinBoardPopup.artItemWindow.width * 0.5,this._bulletinBoardPopup.artItemWindow.height * 0.5);
this._artSpiral.visible = true;
this._jcLoader = new JCDefHelper();
this._jcLoader.init(1,this.onArtGLReceived);
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdOnly(14712));
}
}
private function onMediaItemLoaded(img:MovieClip) : void
{
var i:int = 0;
var scale:Number = NaN;
if(Boolean(img))
{
for(i = 0; i < this._mediaHelpers.length; i++)
{
if(this._mediaHelpers[i] == img.mediaHelper)
{
switch(img.mediaHelper.id)
{
case BBOARD_MEDIA_ID:
DarkenManager.showLoadingSpiral(false);
this._bulletinBoardPopup = MovieClip(img.getChildAt(0));
this._howlTextField = this._bulletinBoardPopup.howlTxt;
this._bulletinBoardPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._bulletinBoardPopup.y = MainFrame.VIEW_HEIGHT;
this._artSpiral.setNewParent(this._bulletinBoardPopup.artItemWindow,this._bulletinBoardPopup.artItemWindow.width * 0.5,this._bulletinBoardPopup.artItemWindow.height * 0.5);
this._tutorialSpiral.setNewParent(this._bulletinBoardPopup.videoItemWindow);
this._bulletinBoardPopup.playMovBtn.visible = false;
this._guiLayer.addChild(this._bulletinBoardPopup);
DarkenManager.darken(this._bulletinBoardPopup);
KeepAlive.startKATimer(this._bulletinBoardPopup);
this.addBoardListeners();
if(this._tutorialMediaId > 0)
{
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this._tutorialMediaId,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
this._jcLoader = new JCDefHelper();
this._jcLoader.init(LocalizationManager.currentLanguage,this.onArtGLReceived);
GenericListXtCommManager.requestStreamList(TUT_STREAM_GL_ID,this.onTutorialGLReceived);
LocalizationManager.translateId(this._bulletinBoardPopup.eventsTxt,EVT_LOC_ID);
break;
case this._tutorialMediaId:
scale = this._bulletinBoardPopup.videoItemWindow.width / img.width;
img.scaleX = scale;
img.scaleY = scale;
this._bulletinBoardPopup.videoItemWindow.addChild(img);
this._bulletinBoardPopup.playMovBtn.visible = true;
this._tutorialSpiral.destroy();
break;
case this._introCloseId:
this._introCloseBtn = MovieClip(img.getChildAt(0));
this._guiLayer.addChild(this._introCloseBtn);
this._introCloseBtn.x = 855;
this._introCloseBtn.y = 10;
this._introCloseBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onIntroClose,false,0,true);
break;
case GALLERY_MEDIA_ID:
DarkenManager.showLoadingSpiral(false);
this._artGalleryPopup = MovieClip(img.getChildAt(0));
this.onGalleryLeftRightDown(null);
this.addGalleryListeners();
this._guiLayer.addChild(this._artGalleryPopup);
this._artGalleryPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._artGalleryPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.darken(this._artGalleryPopup);
break;
case CAL_MEDIA_ID:
DarkenManager.showLoadingSpiral(false);
this._calendarPopup = MovieClip(img.getChildAt(0));
this._calendarPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
this._calendarPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupClose,false,0,true);
this._guiLayer.addChild(this._calendarPopup);
this._calendarPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._calendarPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.darken(this._calendarPopup);
break;
case COSTUME_MEDIA_ID:
DarkenManager.showLoadingSpiral(false);
this._costumePopup = MovieClip(img.getChildAt(0));
this._costumePopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
this._costumePopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupClose,false,0,true);
this._guiLayer.addChild(this._costumePopup);
this._costumePopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._costumePopup.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.darken(this._costumePopup);
}
img.mediaHelper.destroy();
delete img.mediaHelper;
this._mediaHelpers.splice(i,1);
break;
}
}
}
}
private function displayText(imageId:int) : void
{
if(Boolean(this._artGalleryPopup))
{
this._artGalleryPopup.descTxt.text = this._artObjects[imageId].desc;
this._artGalleryPopup.descTxt.y = DESC_TXT_Y_POS;
if(this._artGalleryPopup.descTxt.numLines == 1)
{
this._artGalleryPopup.descTxt.y += 11;
}
this._artGalleryPopup.titleTxt.text = this._artObjects[imageId].title;
}
}
private function onArtDataLoaded(data:Object) : void
{
var delim:int = 0;
var text:String = null;
var title:String = null;
var desc:String = null;
if(Boolean(data) && Boolean(this._bulletinBoardPopup))
{
text = data.data.text;
delim = text.indexOf("|");
title = text.substr(0,delim);
desc = text.substr(delim + 1,text.length);
desc = LocalizationManager.translateAvatarName(desc);
this._artObjects[data.data.imageId] = {
"img":null,
"title":LocalizationManager.translateIdOnly(int(title)),
"desc":desc.toUpperCase()
};
this.displayText(data.data.imageId);
this._jcLoader.destroy();
this._jcLoader = null;
this._jcLoader = new JCDefHelper();
this._jcLoader.init(this._artMediaIds[this._artPageNum],this.onArtLoaded,true,true);
}
}
private function onArtLoaded(img:MovieClip) : void
{
var k:Number = NaN;
var obj:Object = null;
if(Boolean(img) && Boolean(this._bulletinBoardPopup))
{
if(Boolean(this._artGalleryPopup) && this._artGalleryPopup.visible)
{
obj = this._artObjects[img.defHelper.id];
k = this._artGalleryPopup.itemWindow.height / this._artGalleryPopup.itemWindow.width;
if(img.width * k > img.height)
{
k = this._artGalleryPopup.itemWindow.width / img.width;
}
else
{
k = this._artGalleryPopup.itemWindow.height / img.height;
}
img.width *= k;
img.height *= k;
img.y = (this._artGalleryPopup.itemWindow.height - img.height) * 0.5;
img.x = (this._artGalleryPopup.itemWindow.width - img.width) * 0.5;
obj.img = img;
while(this._artGalleryPopup.itemWindow.numChildren > 1)
{
this._artGalleryPopup.itemWindow.removeChildAt(this._artGalleryPopup.itemWindow.numChildren - 1);
}
this._artSpiral.visible = false;
this._artGalleryPopup.itemWindow.addChild(img);
this._artGalleryPopup.descTxt.text = obj.desc;
this._artGalleryPopup.titleTxt.text = obj.title;
}
else
{
k = this._bulletinBoardPopup.artItemWindow.height / this._bulletinBoardPopup.artItemWindow.width;
if(img.width * k > img.height)
{
k = this._bulletinBoardPopup.artItemWindow.width / img.width;
}
else
{
k = this._bulletinBoardPopup.artItemWindow.height / img.height;
}
img.width *= k;
img.height *= k;
img.y = (this._bulletinBoardPopup.artItemWindow.height - img.height) * 0.5;
img.x = (this._bulletinBoardPopup.artItemWindow.width - img.width) * 0.5;
while(this._bulletinBoardPopup.artItemWindow.numChildren > 1)
{
this._bulletinBoardPopup.artItemWindow.removeChildAt(this._bulletinBoardPopup.artItemWindow.numChildren - 1);
}
this._bulletinBoardPopup.artItemWindow.addChild(img);
this._artSpiral.visible = false;
}
img.defHelper.destroy();
delete img.defHelper;
}
}
private function onIntroLoaded(mc:MovieClip) : void
{
gMainFrame.stage.quality = StageQuality.HIGH;
DarkenManager.showLoadingSpiral(false);
if(!SBAudio.isMusicMuted || !SBAudio.areSoundsMuted)
{
SBAudio.muteMusic(false);
SBAudio.muteSounds();
this._musicMutedByPlayer = true;
}
this._intro = mc;
this._intro.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
this._guiLayer.addChild(this._intro);
DarkenManager.darken(this._intro);
this._intro.playMovie(this.onIntroClose);
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this._introCloseId,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
this._introMediaHelper.destroy();
this._introMediaHelper = null;
}
private function onIntroClose(evt:MouseEvent = null) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(this._intro.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._intro);
}
if(Boolean(this._intro))
{
this._intro.stopMovie();
DarkenManager.unDarken(this._intro);
}
if(Boolean(this._introCloseBtn) && this._introCloseBtn.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._introCloseBtn);
}
if(this._musicMutedByPlayer)
{
this._musicMutedByPlayer = false;
SBAudio.unmuteMusic(false);
SBAudio.unmuteSounds();
}
gMainFrame.stage.quality = StageQuality.MEDIUM;
}
private function onTutorialGLReceived(glId:int, streamIds:Array, thumbIds:Array, baseTitles:Array, indivTitles:Array, statusIds:Array, subtitleIds:Array) : void
{
this._tutorialStreamId = streamIds[0];
this._introCloseId = 178;
LocalizationManager.translateId(this._bulletinBoardPopup.videoTitleTxt,baseTitles[0]);
this._tutorialText = baseTitles[0];
this._tutorialMediaId = thumbIds[0];
this._tutorialSubtitleId = subtitleIds[0];
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this._tutorialMediaId,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
private function onArtGLReceived(data:Object) : void
{
var tempArray:Array = null;
var j:int = 0;
var nameSplit:Array = null;
var i:int = 0;
if(Boolean(this._bulletinBoardPopup))
{
this._artMediaIds = data.data.jammerCentralGallery;
tempArray = data.data.jammerCentralHowls.split(/\"\|/g);
j = 0;
this.shuffle(tempArray);
this._howlsTextArray = [];
for(i = 0; i < tempArray.length; i++)
{
if(this._howlsTextArray[j] == null)
{
this._howlsTextArray[j] = new String();
}
else if(this._howlsTextArray[j].length > 1700)
{
i--;
j++;
continue;
}
nameSplit = tempArray[i].split(":");
nameSplit[0] = LocalizationManager.translateAvatarName(nameSplit[0]).toUpperCase();
tempArray[i] = nameSplit.join(":");
tempArray[i] = tempArray[i].replace(/\n/g,"");
this._howlsTextArray[j] += tempArray[i] + "\" - ";
}
this._howlIndex = 0;
this.setUpHowls();
this._artPageNum = 0;
this._jcLoader = new JCDefHelper();
this._jcLoader.init(this._artMediaIds[this._artPageNum],this.onArtDataLoaded);
}
}
private function shuffle(target:Array) : void
{
var tmp:String = null;
var randomNum:int = 0;
for(var i:int = 0; i < target.length; i++)
{
tmp = target[i];
randomNum = Math.floor(Math.random() * target.length);
target[i] = target[randomNum];
target[randomNum] = tmp;
}
}
private function onPopupDown(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onPopupClose(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.pop();
switch(evt.currentTarget.parent)
{
case this._calendarPopup:
this._guiLayer.removeChild(this._calendarPopup);
DarkenManager.unDarken(this._calendarPopup);
break;
case this._artGalleryPopup:
this._guiLayer.removeChild(this._artGalleryPopup);
DarkenManager.unDarken(this._artGalleryPopup);
this._artGalleryPopup.visible = false;
this._artSpiral.visible = false;
break;
case this._bulletinBoardPopup:
if(this._closeCallback != null)
{
this._closeCallback();
}
else
{
this.destroy();
}
break;
case this._costumePopup:
this._guiLayer.removeChild(this._costumePopup);
DarkenManager.unDarken(this._costumePopup);
}
}
private function onPlayMovieDown(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.showLoadingSpiral(true);
GuiManager.initMoviePlayer(MovieManager.VID_PLAYER_MEDIA_ID,[this._tutorialStreamId],[this._tutorialText],[this._tutorialSubtitleId],false,768,432);
GuiManager.setVideoPlayerSkin(MovieManager.BIGGER_FRAME);
}
private function onMinigameInfoResponse() : void
{
DarkenManager.showLoadingSpiral(false);
MinigameManager.handleGameClick(this._gameLaunchObj,null,false);
}
private function onCostumeBtnDown(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/jammerCentral/costumeCorner",-1,SBTracker.TYPE_EVENT);
if(Boolean(this._costumePopup))
{
this._guiLayer.addChild(this._costumePopup);
DarkenManager.darken(this._costumePopup);
}
else
{
DarkenManager.showLoadingSpiral(true);
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(COSTUME_MEDIA_ID,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
}
private function onCalendarBtnDown(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/jammerCentral/calendar",-1,SBTracker.TYPE_EVENT);
if(Boolean(this._calendarPopup))
{
this._guiLayer.addChild(this._calendarPopup);
DarkenManager.darken(this._calendarPopup);
}
else
{
DarkenManager.showLoadingSpiral(true);
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(CAL_MEDIA_ID,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
}
private function onSubmitHowlDown(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/jammerCentral/submit/howl",-1,SBTracker.TYPE_EVENT);
DarkenManager.showLoadingSpiral(true);
FeedbackManager.openFeedbackPopup(FeedbackManager.TYPE_HOWL);
}
private function onSubmitWorkDown(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/jammerCentral/submit/art",-1,SBTracker.TYPE_EVENT);
DarkenManager.showLoadingSpiral(true);
FeedbackManager.openFeedbackPopup(FeedbackManager.TYPE_WORK);
}
private function onArtGalleryDown(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(this._artSpiral) && this._artSpiral.visible)
{
return;
}
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/jammerCentral/artGallery/#page1",-1,SBTracker.TYPE_EVENT);
if(Boolean(this._artGalleryPopup))
{
this._guiLayer.addChild(this._artGalleryPopup);
DarkenManager.darken(this._artGalleryPopup);
this._artGalleryPopup.visible = true;
}
else
{
DarkenManager.showLoadingSpiral(true);
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(GALLERY_MEDIA_ID,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
}
private function onGalleryLeftRightDown(evt:MouseEvent) : void
{
var id:int = 0;
var obj:Object = null;
if(!this._artSpiral.visible)
{
if(Boolean(evt))
{
evt.stopPropagation();
if(evt.currentTarget.name == "lBtn")
{
if(this._artPageNum - 1 < 0)
{
this._artPageNum = this._artMediaIds.length - 1;
}
else
{
--this._artPageNum;
}
}
else if(this._artPageNum + 1 >= this._artMediaIds.length)
{
this._artPageNum = 0;
}
else
{
++this._artPageNum;
}
SBTracker.trackPageview("/game/play/popup/jammerCentral/artGallery/#page" + (this._artPageNum + 1),-1,SBTracker.TYPE_EVENT);
}
id = int(this._artMediaIds[this._artPageNum]);
obj = this._artObjects[id];
if(Boolean(obj) && obj.img != null)
{
while(this._artGalleryPopup.itemWindow.numChildren > 1)
{
this._artGalleryPopup.itemWindow.removeChildAt(1);
}
this._artGalleryPopup.itemWindow.addChild(obj.img);
this.displayText(id);
}
else
{
this._artSpiral.setNewParent(this._artGalleryPopup.itemWindow,this._artGalleryPopup.itemWindow.width * 0.5,this._artGalleryPopup.itemWindow.height * 0.5);
this._artSpiral.visible = true;
this._jcLoader = new JCDefHelper();
this._jcLoader.init(this._artMediaIds[this._artPageNum],this.onArtDataLoaded);
}
}
}
private function setUpHowls() : void
{
this._howlTextField.cacheAsBitmap = true;
this._howlTextField.autoSize = TextFieldAutoSize.LEFT;
this._howlTextField.antiAliasType = AntiAliasType.ADVANCED;
this._howlTextField.text = this._howlsTextArray[this._howlIndex];
this._howlTextField.scrollRect = new Rectangle(0,0,564,18);
this._scrollRect = this._howlTextField.scrollRect;
this._scrollRect.x = -564;
this._howlTextField.scrollRect = this._scrollRect;
if(Boolean(this._howlTimer))
{
this._howlTimer.reset();
this._howlTimer.start();
}
else
{
this._howlTimer = new Timer(1000 / 24);
this._howlTimer.addEventListener(TimerEvent.TIMER,this.onTimerEvent,false,0,true);
this._howlTimer.start();
}
}
private function onTimerEvent(t:TimerEvent) : void
{
if(this._scrollRect.x >= this._howlTextField.textWidth)
{
this._scrollRect.x = -564;
if(this._howlIndex < this._howlsTextArray.length - 1)
{
++this._howlIndex;
}
else
{
this._howlIndex = 0;
}
this._howlTextField.text = this._howlsTextArray[this._howlIndex];
}
else
{
this._scrollRect.x += 1;
}
this._howlTextField.scrollRect = this._scrollRect;
t.updateAfterEvent();
}
private function addGalleryListeners() : void
{
this._artGalleryPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
this._artGalleryPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupClose,false,0,true);
this._artGalleryPopup.lBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onGalleryLeftRightDown,false,0,true);
this._artGalleryPopup.rBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onGalleryLeftRightDown,false,0,true);
}
private function removeGalleryListeners() : void
{
this._artGalleryPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown);
this._artGalleryPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupClose);
this._artGalleryPopup.lBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onGalleryLeftRightDown);
this._artGalleryPopup.rBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onGalleryLeftRightDown);
}
private function addBoardListeners() : void
{
this._bulletinBoardPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
this._bulletinBoardPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupClose,false,0,true);
this._bulletinBoardPopup.playMovBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovieDown,false,0,true);
this._bulletinBoardPopup.seeCalBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onCalendarBtnDown,false,0,true);
this._bulletinBoardPopup.submitHowlBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSubmitHowlDown,false,0,true);
this._bulletinBoardPopup.submitWorkBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSubmitWorkDown,false,0,true);
this._bulletinBoardPopup.artBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onArtGalleryDown,false,0,true);
}
private function removeBoardListeners() : void
{
this._bulletinBoardPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown);
this._bulletinBoardPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupClose);
this._bulletinBoardPopup.playMovBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovieDown);
this._bulletinBoardPopup.seeCalBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCalendarBtnDown);
this._bulletinBoardPopup.submitHowlBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSubmitHowlDown);
this._bulletinBoardPopup.submitWorkBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSubmitWorkDown);
this._bulletinBoardPopup.artBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onArtGalleryDown);
}
}
}
@@ -0,0 +1,457 @@
package gui
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.text.TextFieldAutoSize;
import loader.MediaHelper;
import localization.LocalizationManager;
public dynamic class ChatBalloon extends MovieClip
{
private const CHAT_TIMEOUT_MS:int = 8000;
private const BALLOON_BEGIN_FADEOUT:Number = 1000;
private const BALLOON_MAX_ALPHA:Number = 0.75;
private const TEXT_COLOR_NORMAL:uint = 4477529;
private const TEXT_COLOR_BAD_TEXT:uint = 13369344;
private var _maxAlpha:Number;
private var _timeout:int = 0;
private var _avType:int = 0;
private var _originalFrameId:int = 0;
private var _originalCustomMsgText:String;
private var _emoteBG:MovieClip = null;
private var _emote:Sprite = null;
private var _permEmoteMediaId:int = -1;
private var _permEmoteMediaHelper:MediaHelper;
private var _hasSbTextfield:Boolean;
public var msgTxt:Object;
public var balloonBG:MovieClip;
private var btnBallonBG:MovieClip;
private var btnBalloonMouseBG:MovieClip;
private var btnBalloonUpBG:MovieClip;
private var btnBalloonDownBg:MovieClip;
private var btnBalloonGrayBG:MovieClip;
private var _onCustomAdventureBtn:Function;
private var _onCustomPVPBtn:Function;
private var _emoteBGOffsetFunc:Function;
public function ChatBalloon()
{
super();
}
public function init(avType:int, emoteBGOffsetFunc:Function, opaque:Boolean = false, frameId:int = 1, sbtextField:Class = null, onCustomAdventureBtn:Function = null, onCustomPVPBtn:Function = null) : void
{
this._originalFrameId = frameId;
this.gotoAndStop(frameId);
this.balloonBG = this["balloon_bg"];
this.msgTxt = this["message_txt"];
this._onCustomAdventureBtn = onCustomAdventureBtn;
this._onCustomPVPBtn = onCustomPVPBtn;
this._emoteBGOffsetFunc = emoteBGOffsetFunc;
this._avType = avType;
visible = false;
this.msgTxt.autoSize = TextFieldAutoSize.CENTER;
if(opaque)
{
this._maxAlpha = 1;
}
else
{
this._maxAlpha = this.BALLOON_MAX_ALPHA;
}
this._emoteBG = GETDEFINITIONBYNAME("emo_bubble");
this.setEmoteBgOffsets();
}
public function setText(txt:String, changeFontColor:Boolean = false, addToParent:Boolean = true) : void
{
var adjustment:int = 0;
if(Boolean(this._emote))
{
this._permEmoteMediaId = -1;
this._emoteBG.itemWindow.removeChild(this._emote);
this._emote = null;
}
if(contains(this._emoteBG))
{
removeChild(this._emoteBG);
}
if(txt != this.msgTxt.text && this._hasSbTextfield)
{
this.balloonBG.visible = false;
this.setAlpha(this._maxAlpha);
this.visible = false;
}
else
{
this.balloonBG.visible = true;
this.setAlpha(this._maxAlpha);
this.visible = true;
}
this.msgTxt.text = txt;
if(!this._hasSbTextfield)
{
if(addToParent)
{
if(Math.abs(this.msgTxt.height - Math.floor(this.msgTxt.height) - 0.5) < 0.3)
{
adjustment = 1;
}
this.balloonBG.m.height = Math.floor(this.msgTxt.height - adjustment);
this.balloonBG.m.y = this.balloonBG.b.y - this.balloonBG.m.height;
this.balloonBG.t.y = this.balloonBG.m.y - this.balloonBG.t.height;
this.msgTxt.y = -this.balloonBG.b.height - this.msgTxt.height - (this.msgTxt.height - this.balloonBG.m.height);
}
else
{
this.balloonBG.m.height = Math.floor(this.msgTxt.height);
this.balloonBG.b.y = Math.round(this.balloonBG.m.y + this.balloonBG.m.height);
this.msgTxt.y = this.balloonBG.t.height + (this.balloonBG.m.height * 0.5 - this.msgTxt.height * 0.5) + 3;
}
if(this.currentFrameLabel == "advBtn")
{
this.btnBallonBG.y = this.balloonBG.y + this.balloonBG.t.y - this.btnBallonBG.height + this.balloonBG.t.height;
}
}
if(changeFontColor)
{
this.msgTxt.textColor = this.TEXT_COLOR_BAD_TEXT;
}
else
{
this.msgTxt.textColor = this.TEXT_COLOR_NORMAL;
}
this._timeout = this.CHAT_TIMEOUT_MS;
if(addToParent && Boolean(this.parent))
{
this.parent.addChild(this);
}
}
public function setCustomAdventureMessage(infoText:String, userText:String, difficulty:int, changeFontColor:Boolean = false, isForPVP:Boolean = false) : void
{
var pvpGameId:int = 0;
var scriptDefId:int = 0;
var splitText:Array = userText.split("|");
if(isForPVP)
{
userText = splitText[0];
pvpGameId = int(splitText[1]);
}
else
{
userText = splitText[0];
scriptDefId = int(splitText[1]);
}
if(userText == "on")
{
if(Boolean(this._emote) && Boolean(this._emoteBG))
{
this._emoteBG.itemWindow.removeChild(this._emote);
this._emote = null;
if(contains(this._emoteBG))
{
removeChild(this._emoteBG);
}
}
if(this.currentFrameLabel != "advBtn")
{
this.gotoAndStop("advBtn");
}
this.balloonBG = this["balloon_bg"];
this.btnBallonBG = this["btnBalloon_bg"];
this.btnBalloonMouseBG = this.btnBallonBG.mouse.mouse;
this.btnBalloonUpBG = this.btnBallonBG.mouse.up;
this.btnBalloonDownBg = this.btnBallonBG.down;
this.btnBalloonGrayBG = this.btnBallonBG.gray;
this.btnBallonBG.isForPVP = isForPVP;
this.btnBallonBG.PVPGameId = pvpGameId;
this.btnBallonBG.scriptDefId = scriptDefId;
this.btnBallonBG.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnBG,false,0,true);
this.msgTxt = this["message_txt"];
this.msgTxt.autoSize = TextFieldAutoSize.CENTER;
LocalizationManager.translateId(this.btnBalloonMouseBG.message_txt,11259);
LocalizationManager.translateId(this.btnBalloonUpBG.message_txt,11259);
LocalizationManager.translateId(this.btnBalloonDownBg.message_txt,11259);
LocalizationManager.translateId(this.btnBalloonGrayBG.message_txt,11259);
if(difficulty > 0)
{
this.btnBalloonMouseBG.message_txt.x = 3;
this.btnBalloonUpBG.message_txt.x = 3;
this.btnBalloonDownBg.message_txt.x = 3;
this.btnBalloonGrayBG.message_txt.x = 3;
this.btnBallonBG["redDot"].visible = true;
}
else
{
this.btnBalloonMouseBG.message_txt.x = 17;
this.btnBalloonUpBG.message_txt.x = 17;
this.btnBalloonDownBg.message_txt.x = 17;
this.btnBalloonGrayBG.message_txt.x = 17;
this.btnBallonBG["redDot"].visible = false;
}
this.msgTxt.text = infoText;
this._originalCustomMsgText = infoText;
this.balloonBG.m.height = Math.floor(this.msgTxt.height);
this.balloonBG.m.y = this.balloonBG.b.y - this.balloonBG.m.height;
this.balloonBG.t.y = this.balloonBG.m.y - this.balloonBG.t.height;
this.msgTxt.y = -this.balloonBG.b.height - this.msgTxt.height - (this.msgTxt.height - this.balloonBG.m.height);
this.btnBallonBG.y = this.balloonBG.y + this.balloonBG.t.y - this.btnBallonBG.height + this.balloonBG.t.height;
if(Boolean(this.itemWindow))
{
this.itemWindow.y = this.btnBallonBG.y;
}
this.balloonBG.t.alpha = 0;
this.setAlpha(this._maxAlpha);
this.visible = true;
this._timeout = this.CHAT_TIMEOUT_MS;
if(Boolean(this.parent))
{
this.parent.addChild(this);
}
}
else
{
if(Boolean(this.btnBallonBG))
{
if(this.btnBallonBG.isForPVP != isForPVP)
{
return;
}
this.btnBallonBG.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnBG);
}
if(this.currentFrameLabel == "advBtn")
{
this.gotoAndStop(this._originalFrameId);
}
this.balloonBG = this["balloon_bg"];
this.msgTxt = this["message_txt"];
this.msgTxt.autoSize = TextFieldAutoSize.CENTER;
this.visible = false;
}
}
public function get isPvpCustom() : Boolean
{
if(Boolean(this.btnBallonBG))
{
return this.btnBallonBG.isForPVP;
}
return false;
}
public function get pvpGameId() : int
{
if(Boolean(this.btnBallonBG))
{
return this.btnBallonBG.PVPGameId;
}
return 0;
}
public function setCustomPVPImage(img:MovieClip) : void
{
if(this.currentFrameLabel == "advBtn")
{
while(this.itemWindow.numChildren > 0)
{
this.itemWindow.removeChildAt(0);
}
this.itemWindow.addChild(img);
}
}
private function onBtnBG(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(evt.currentTarget.isForPVP))
{
this._onCustomPVPBtn(evt.currentTarget.PVPGameId);
}
else
{
this._onCustomAdventureBtn(evt.currentTarget.scriptDefId);
}
}
private function updateCustAdventureBGSize(bg:MovieClip, messageText:Object) : void
{
this.balloonBG.m.height = Math.floor(this.msgTxt.height);
this.balloonBG.m.y = this.balloonBG.b.y - this.balloonBG.m.height;
this.balloonBG.t.y = this.balloonBG.m.y - this.balloonBG.t.height;
this.msgTxt.y = -this.balloonBG.b.height - this.msgTxt.height - (this.msgTxt.height - this.balloonBG.m.height);
this.btnBallonBG.y = this.balloonBG.y + this.balloonBG.t.y - this.btnBallonBG.height + this.balloonBG.t.height;
if(Boolean(this.itemWindow))
{
this.itemWindow.y = this.btnBallonBG.y;
}
}
private function updateSizeFunction() : void
{
this.balloonBG.m.height = Math.floor(this.msgTxt.height);
this.balloonBG.m.y = Math.floor(this.balloonBG.b.y - this.balloonBG.m.height);
this.balloonBG.t.y = Math.floor(this.balloonBG.m.y - this.balloonBG.t.height);
var adjustedBy:Number = Number(this.msgTxt.y);
this.msgTxt.y = -this.balloonBG.b.height - this.msgTxt.height - (this.msgTxt.height - this.balloonBG.m.height);
this.msgTxt.adjustSmileys(adjustedBy - this.msgTxt.y);
this.balloonBG.visible = true;
this.visible = true;
}
public function setEmote(emoteRef:Sprite, permEmoteMediaId:int = -1) : void
{
if(this.currentFrameLabel != "advBtn")
{
this._permEmoteMediaId = permEmoteMediaId;
if(Boolean(this._emote))
{
this._emoteBG.itemWindow.removeChild(this._emote);
this._emote = null;
}
if(this._permEmoteMediaId >= 0)
{
emoteRef = new Sprite();
this._permEmoteMediaHelper = new MediaHelper();
this._permEmoteMediaHelper.init(this._permEmoteMediaId,this.permEmoteMediaCallback);
}
if(Boolean(emoteRef))
{
this.msgTxt.text = "";
addChild(this._emoteBG);
this._emote = emoteRef;
this._emote.y = -5;
this._emoteBG.itemWindow.addChild(this._emote);
if(this._emote is MovieClip)
{
MovieClip(this._emote).gotoAndPlay(1);
}
if(this.currentFrameLabel != "advBtn")
{
this._timeout = this.CHAT_TIMEOUT_MS;
}
this.balloonBG.visible = false;
this.setAlpha(1);
this._emoteBG.bubble.alpha = this._maxAlpha;
this._emoteBG.itemWindow.alpha = 1;
this.visible = true;
}
}
}
public function setReadyForClear() : void
{
if(this.visible && this._timeout > this.BALLOON_BEGIN_FADEOUT)
{
this._timeout = this.BALLOON_BEGIN_FADEOUT;
}
this._permEmoteMediaId = -1;
}
public function setPos(x:int, y:int) : void
{
this.x = x;
this.y = y;
}
public function heartbeat(ms:int) : void
{
if(Boolean(this._timeout) && this._permEmoteMediaId < 0)
{
if(ms >= this._timeout)
{
this._timeout = 0;
if(Boolean(this._emote))
{
this._emoteBG.itemWindow.removeChild(this._emote);
this._emote = null;
}
if(this.currentFrameLabel != "advBtn")
{
this.visible = false;
}
else
{
this.msgTxt.text = this._originalCustomMsgText;
this.updateCustAdventureBGSize(this.balloonBG,this.msgTxt);
}
}
else
{
this._timeout -= ms;
if(this.currentFrameLabel != "advBtn" && this._timeout < this.BALLOON_BEGIN_FADEOUT)
{
this.setAlpha(this._timeout / this.BALLOON_BEGIN_FADEOUT * this._maxAlpha);
}
}
}
}
public function set avType(value:int) : void
{
if(value != this._avType)
{
this._avType = value;
this.setEmoteBgOffsets();
}
}
public function updateEmoteBgOffsets() : void
{
this.setEmoteBgOffsets();
}
private function setAlpha(alpha:Number) : void
{
this.alpha = alpha;
this.msgTxt.alpha = 1;
}
private function permEmoteMediaCallback(img:MovieClip) : void
{
if(Boolean(img) && Boolean(this._emote) && this._permEmoteMediaId >= 0)
{
img.scaleX = 0.5;
img.scaleY = 0.5;
img.x = -(img.width * 0.5);
img.y = -(img.height * 0.5);
this._emote.addChild(img);
}
}
private function setEmoteBgOffsets() : void
{
var p:Point = this._emoteBGOffsetFunc(this._avType);
this._emoteBG.x = p.x;
this._emoteBG.y = p.y;
}
}
}
@@ -0,0 +1,955 @@
package gui
{
import avatar.Avatar;
import avatar.AvatarInfo;
import avatar.AvatarManager;
import com.sbi.analytics.SBTracker;
import com.sbi.debug.DebugUtility;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBYesNoPopup;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TextEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import flash.ui.Mouse;
import flash.utils.Timer;
import localization.LocalizationManager;
import room.RoomXtCommManager;
public class ChatHistory
{
public static const SG_CHAT_TYPE_BUBBLE:int = 0;
public static const SG_CHAT_TYPE_FREE:int = 1;
public static const SG_CHAT_TYPE_PREDICTIVE:int = 2;
public static const SG_CHAT_TYPE_RESTR_BUBBLE:int = 3;
public static const TEXT_RESTRICTION:String = "A-Za-z0-9!\'.,():? ";
public static const TEXT_RESTRICTION_WO_PAREN:String = "A-Za-z0-9!\'.,:? ";
public static const TEXT_RESTRICTION_WO_OPEN_PAREN:String = "A-Za-z0-9!\'.,):? ";
public static const TEXT_RESTRICTION_INTERROBANG:String = "?!.";
private const CHAT_DIM_ALPHA:Number = 0.5;
private const CHAT_BRIGHT_ALPHA:Number = 1;
private var _keyListenersActive:Boolean;
private var _enableFreeChat:Boolean = true;
private var _predictiveTextManager:PredictiveTextManager;
private var _keyboardEvent:KeyboardEvent;
private var _predictiveText:MovieClip;
private var _chatText:TextField;
private var _chatBarContainer:MovieClip;
private var _chatRepeatBtn:MovieClip;
private var _chatRepeatWindow:MovieClip;
private var _repeatChatWindows:WindowGenerator;
private var _chatRepeatArray:Array;
private var _hasSetupChatRepeatBtn:Boolean;
private var _previousRestriction:String;
private var _numInterrobangs:int;
private var _textColorTimer:Timer;
private var _defaultTextColor:uint;
public var chatHistory:MovieClip;
public var chatUpDown:MovieClip;
public var chatMsgText:TextField;
public var chatSendBtn:MovieClip;
public var sendMsgCallback:Function;
public function ChatHistory(chatHistoryMC:MovieClip, chatBarContainer:MovieClip, upAndDownMovieClip:MovieClip, buddyListButton:MovieClip, chatMessageText:TextField, chatSendButton:MovieClip, sendMessageCallback:Function, predictiveText:MovieClip, chatHistoryRepeatBtn:MovieClip, chatHistoryRepeatWindow:MovieClip)
{
super();
if(Boolean(this.chatHistory))
{
throw new Error("ERROR: Singleton ChatHistory did not expect to be created twice!");
}
this.setupInitialItems(chatHistoryMC,chatBarContainer,upAndDownMovieClip,buddyListButton,chatMessageText,chatSendButton,sendMessageCallback,predictiveText,chatHistoryRepeatBtn,chatHistoryRepeatWindow);
}
public function reload(chatHistoryMC:MovieClip, chatBarContainer:MovieClip, upAndDownMovieClip:MovieClip, buddyListButton:MovieClip, chatMessageText:TextField, chatSendButton:MovieClip, predictiveText:MovieClip, chatHistoryRepeatBtn:MovieClip, chatHistoryRepeatWindow:MovieClip, completeRebuild:Boolean) : void
{
this._keyListenersActive = true;
if(Boolean(this.chatHistory))
{
this.chatHistory.removeEventListener(MouseEvent.MOUSE_DOWN,this.chatClickHandler);
}
if(Boolean(this.chatUpDown))
{
this.chatUpDown.removeEventListener(MouseEvent.MOUSE_DOWN,this.openCloseHandler);
}
if(Boolean(this._chatText))
{
this._chatText.removeEventListener(MouseEvent.MOUSE_DOWN,this.chatClickHandler);
}
if(Boolean(this.chatMsgText))
{
this.chatMsgText.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener);
this.chatMsgText.removeEventListener(KeyboardEvent.KEY_UP,this.keyUpListener);
this.chatMsgText.removeEventListener(MouseEvent.MOUSE_DOWN,this.msgTextDownHandler);
this.chatMsgText.removeEventListener(TextEvent.TEXT_INPUT,this.onTextInput);
if(Boolean(Mouse["supportsNativeCursor"]))
{
this.chatMsgText.removeEventListener(MouseEvent.MOUSE_OVER,this.mouseOverMsgText);
this.chatMsgText.removeEventListener(MouseEvent.MOUSE_OUT,this.mouseOutMsgText);
}
}
if(Boolean(this._chatRepeatBtn))
{
this._chatRepeatBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onChatRepeatBtn);
}
this._hasSetupChatRepeatBtn = false;
this.setupInitialItems(chatHistoryMC,chatBarContainer,upAndDownMovieClip,buddyListButton,chatMessageText,chatSendButton,this.sendMsgCallback,predictiveText,chatHistoryRepeatBtn,chatHistoryRepeatWindow);
}
public function resetChatPrivs(reload:Boolean = false) : void
{
var sgChatType:int = 0;
if(Utility.canChat())
{
sgChatType = int(gMainFrame.userInfo.sgChatType);
if(this.isAllowedFreeChat())
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
this._previousRestriction = null;
this._numInterrobangs = 0;
this._textColorTimer = new Timer(150,3);
this._textColorTimer.addEventListener(TimerEvent.TIMER,this.onColorTimerComplete,false,0,true);
this._defaultTextColor = 4531987;
this.enableFreeChat(true);
}
else if(sgChatType != SG_CHAT_TYPE_BUBBLE && sgChatType != SG_CHAT_TYPE_RESTR_BUBBLE && (sgChatType == SG_CHAT_TYPE_PREDICTIVE || !this.isAllowedFreeChat()))
{
if(Boolean(reload) && Boolean(this._predictiveTextManager) && PredictiveTextManager.findPredictiveTextNodeIfPossible != null)
{
this._predictiveTextManager.reload(this.chatMsgText,this._predictiveText,this._chatBarContainer);
}
else
{
this._predictiveTextManager = new PredictiveTextManager();
this._predictiveTextManager.init(this.chatMsgText,PredictiveTextManager.findPredictiveTextNodeIfPossible,PredictiveTextManager.USE_TYPE_ALL,this._predictiveText,this._chatBarContainer,this.sendMsgCallback);
}
this._chatText.selectable = true;
this._chatText.text = "";
this.chatMsgText.selectable = true;
this._enableFreeChat = true;
}
else
{
this.enableFreeChat(false);
}
}
else
{
this.enableFreeChat(false);
}
}
public function destroy() : void
{
this.chatMsgText.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener);
this._keyListenersActive = false;
this.chatMsgText.removeEventListener(MouseEvent.MOUSE_DOWN,this.msgTextDownHandler);
this._chatText.removeEventListener(MouseEvent.MOUSE_DOWN,this.chatClickHandler);
this._chatText = null;
this.chatHistory.removeEventListener(MouseEvent.MOUSE_DOWN,this.chatClickHandler);
this.chatHistory.visible = false;
this.chatHistory = null;
this.chatUpDown.removeEventListener(MouseEvent.MOUSE_DOWN,this.openCloseHandler);
this.chatUpDown.visible = false;
this.chatUpDown = null;
}
public function showChatInput(flag:Boolean) : void
{
this.chatUpDown.visible = flag;
this.chatMsgText.visible = flag;
this.chatSendBtn.visible = flag;
}
public function addMessageById(userId:int, chatMessage:String) : void
{
var userName:String = null;
var avInfo:AvatarInfo = null;
var avt:Avatar = AvatarManager.getAvatarBySfsUserId(userId);
if(Boolean(avt))
{
userName = avt.userName;
if(userName != null && userName != "_unknown")
{
avInfo = gMainFrame.userInfo.getAvatarInfoByUserName(userName);
if(Boolean(avInfo))
{
this.addMessage(avInfo.avName,avInfo.userName,chatMessage);
}
}
}
}
public function addMessage(avatarName:String, userName:String, chatMessage:String) : void
{
var tempStr:String = null;
var containsText:Boolean = false;
var indexOfContainedMsg:int = 0;
var i:int = 0;
if(avatarName != null && avatarName.length > 0)
{
this._chatText.appendText(avatarName + ": " + chatMessage + "\n");
if(Boolean(this._chatRepeatWindow) && Boolean(AvatarManager.playerAvatar) && userName == AvatarManager.playerAvatar.userName)
{
for(i = 0; i < this._chatRepeatArray.length; i++)
{
if(this._chatRepeatArray[i] == chatMessage)
{
containsText = true;
indexOfContainedMsg = i;
break;
}
}
if(!containsText)
{
if(this._chatRepeatArray.length >= 5)
{
this._chatRepeatArray.shift();
}
this._chatRepeatArray.push(chatMessage);
this.onChatRepeatBtn(null);
}
else
{
this._chatRepeatArray.splice(indexOfContainedMsg,1);
this._chatRepeatArray.push(chatMessage);
this.onChatRepeatBtn(null);
}
this.setupRepeatChat();
}
}
else
{
this._chatText.appendText("\"" + chatMessage + "\"" + "\n");
}
while(this._chatText.numLines >= 100)
{
tempStr = this._chatText.text;
this._chatText.text = tempStr.substr(tempStr.indexOf("\r") + 1);
}
this._chatText.scrollV = this._chatText.maxScrollV;
}
public function removeEmotesFromChatRepeat() : void
{
var i:int = 0;
if(Boolean(this._chatRepeatArray) && this._chatRepeatArray.length > 0)
{
for(i = 0; i < this._chatRepeatArray.length; i++)
{
if(EmoticonUtility.doesStringMatchAnEmote(this._chatRepeatArray[i]))
{
this._chatRepeatArray.splice(i,1);
i--;
}
}
this.setupRepeatChat();
this.onChatRepeatBtn(null);
}
}
public function addPrivateMessage(senderName:String, recipientName:String, chatMessage:String) : void
{
var normalFormat:TextFormat = new TextFormat();
var whisperFormat:TextFormat = new TextFormat();
DebugUtility.debugTrace("sender: " + senderName + " recip: " + recipientName);
normalFormat.color = 6572056;
normalFormat.bold = false;
whisperFormat.color = 16711680;
whisperFormat.bold = true;
if(this._chatText.length == 0)
{
this._chatText.setTextFormat(whisperFormat);
}
else
{
this._chatText.setTextFormat(whisperFormat,this._chatText.length - 1,this._chatText.length);
}
if(recipientName == null)
{
this._chatText.appendText(senderName + ": " + chatMessage + "\n");
}
else
{
this._chatText.appendText(senderName + " to " + recipientName + ": " + chatMessage + "\n");
}
this._chatText.setTextFormat(normalFormat,this._chatText.length - 1,this._chatText.length);
}
public function reAddKeyListeners() : void
{
if(!this._keyListenersActive)
{
this.chatMsgText.addEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener,false,0,true);
this.chatMsgText.addEventListener(KeyboardEvent.KEY_UP,this.keyUpListener,false,0,true);
this._keyListenersActive = true;
}
}
public function removeKeyListeners() : void
{
if(this._keyListenersActive)
{
this.chatMsgText.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener);
this.chatMsgText.removeEventListener(KeyboardEvent.KEY_UP,this.keyUpListener);
this._keyListenersActive = false;
}
}
public function clearChat() : void
{
this._chatText.text = "";
this._chatRepeatArray = [];
this.setupRepeatChat();
this.onRepeatWindoesLoaded(true);
this._chatText.scrollV = 0;
}
public function openChat() : void
{
if(this.chatHistory.currentFrameLabel != "open")
{
this.chatUpDown.gotoAndStop("down");
if(!gMainFrame.userInfo.isMember)
{
this.chatUpDown["down"].activateGrayState(true);
}
this.chatHistory.gotoAndPlay("open");
this.brightenChat();
AJAudio.playChatOpenSound();
this.closeChatRepeatWindow();
}
}
public function closeChatRepeatWindow() : void
{
if(Boolean(this._chatRepeatWindow) && this._chatRepeatWindow.visible)
{
this._chatRepeatWindow.visible = false;
this._chatRepeatBtn.downToUpState();
}
}
public function dimChat() : void
{
if(this.chatHistory.currentFrameLabel == "open" && this.chatHistory.alpha == this.CHAT_BRIGHT_ALPHA)
{
this.chatHistory.alpha = this.CHAT_DIM_ALPHA;
}
}
public function brightenChat() : void
{
if(this.chatHistory.alpha != this.CHAT_BRIGHT_ALPHA)
{
this.chatHistory.alpha = this.CHAT_BRIGHT_ALPHA;
}
}
public function closeChat() : void
{
if(this.chatHistory.currentFrameLabel != null && this.chatHistory.currentFrameLabel != "close")
{
this.brightenChat();
this.chatUpDown.gotoAndStop("up");
if(!gMainFrame.userInfo.isMember)
{
this.chatUpDown["up"].activateGrayState(true);
}
this.chatHistory.gotoAndPlay("close");
AJAudio.playChatCloseSound();
}
}
public function get enableFreeChatValue() : Boolean
{
return this._enableFreeChat;
}
public function enableFreeChat(value:Boolean) : void
{
this._enableFreeChat = value;
this.chatMsgText.text = "";
if(!value)
{
this.chatMsgText.restrict = "";
this._chatText.selectable = false;
this.chatMsgText.selectable = false;
}
else
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
this._chatText.selectable = true;
this.chatMsgText.selectable = true;
}
}
public function resetTreeSearch() : void
{
if(Boolean(this._predictiveTextManager))
{
this._predictiveTextManager.resetTreeSearch();
}
if(this.isAllowedFreeChat())
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
}
}
public function doesChatContainText() : Boolean
{
if(this.chatMsgText.text != "")
{
return true;
}
return false;
}
public function setFocusOnMsgText() : void
{
if(gMainFrame.userInfo.firstFiveMinutes > 0)
{
gMainFrame.stage.focus = this.chatMsgText;
}
else
{
gMainFrame.stage.focus = null;
}
}
public function toggleInGameHud(enable:Boolean) : void
{
if(enable)
{
this.chatMsgText.maxChars = 40;
}
else
{
this.chatMsgText.maxChars = 70;
}
}
private function setupInitialItems(chatHistoryMC:MovieClip, chatBarContainer:MovieClip, upAndDownMovieClip:MovieClip, buddyListButton:MovieClip, chatMessageText:TextField, chatSendButton:MovieClip, sendMessageCallback:Function, predictiveText:MovieClip, chatHistoryRepeatBtn:MovieClip, chatHistoryRepeatWindow:MovieClip) : void
{
this._keyListenersActive = true;
this.chatHistory = chatHistoryMC;
this._predictiveText = predictiveText;
this._chatBarContainer = chatBarContainer;
this._chatRepeatBtn = chatHistoryRepeatBtn;
this._chatRepeatWindow = chatHistoryRepeatWindow;
this._chatRepeatArray = [];
this.chatHistory.gotoAndStop(1);
this.chatHistory.addEventListener(MouseEvent.MOUSE_DOWN,this.chatClickHandler,false,0,true);
this.chatUpDown = upAndDownMovieClip;
this.chatUpDown.gotoAndStop(1);
this.chatUpDown["up"].mouse.gotoAndStop(1);
if(!gMainFrame.userInfo.isMember)
{
this.chatUpDown["up"].activateGrayState(true);
}
this.chatUpDown.addEventListener(MouseEvent.MOUSE_DOWN,this.openCloseHandler,false,0,true);
if(Boolean(buddyListButton))
{
buddyListButton.glow.visible = false;
}
this.chatMsgText = chatMessageText;
this.toggleInGameHud(false);
this.chatMsgText.text = "";
this._previousRestriction = null;
if(gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_BUBBLE || gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_RESTR_BUBBLE)
{
this.chatMsgText.restrict = "";
}
else
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
}
if(this.isAllowedFreeChat())
{
GuiManager.mainHud.ansChatBtn.visible = false;
chatSendButton = GuiManager.mainHud.sendChatBtn;
chatSendButton.visible = true;
}
else
{
GuiManager.mainHud.sendChatBtn.visible = false;
chatSendButton = GuiManager.mainHud.ansChatBtn;
chatSendButton.visible = true;
}
if(Boolean(this._chatRepeatWindow))
{
this._chatRepeatWindow.visible = false;
}
this.setupLanguageFlag();
predictiveText.visible = false;
this._chatText = GuiManager.mainHud.chatHistTxt;
this.chatSendBtn = chatSendButton;
this.sendMsgCallback = sendMessageCallback;
this._chatText.addEventListener(MouseEvent.MOUSE_DOWN,this.chatClickHandler,false,0,true);
this.chatMsgText.addEventListener(Event.CHANGE,this.onTextFieldChanged,false,0,true);
this.chatMsgText.addEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener,false,0,true);
this.chatMsgText.addEventListener(KeyboardEvent.KEY_UP,this.keyUpListener,false,0,true);
this.chatMsgText.addEventListener(MouseEvent.MOUSE_DOWN,this.msgTextDownHandler,false,0,true);
this.chatMsgText.addEventListener(TextEvent.TEXT_INPUT,this.onTextInput,false,0,true);
if(Boolean(Mouse["supportsNativeCursor"]))
{
this.chatMsgText.addEventListener(MouseEvent.MOUSE_OVER,this.mouseOverMsgText,false,0,true);
this.chatMsgText.addEventListener(MouseEvent.MOUSE_OUT,this.mouseOutMsgText,false,0,true);
}
this.chatSendBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.sendChatBtnDownHandler,false,0,true);
this.setupRepeatChat();
this.resetChatPrivs();
this.setFocusOnMsgText();
}
private function setupRepeatChat() : void
{
if(Boolean(this._chatRepeatBtn))
{
if(Boolean(gMainFrame.userInfo.isMember) && this._chatRepeatArray.length > 0)
{
this._chatRepeatBtn.visible = true;
GuiManager.mainHud.bgChatRepeat.visible = true;
if(!this._hasSetupChatRepeatBtn)
{
this._chatRepeatBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onChatRepeatBtn,false,0,true);
}
this._hasSetupChatRepeatBtn = true;
}
else if(this._chatRepeatBtn.visible || Boolean(GuiManager.mainHud.bgChatRepeat.visible))
{
this._chatRepeatBtn.visible = false;
GuiManager.mainHud.bgChatRepeat.visible = false;
this._chatRepeatBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onChatRepeatBtn);
this._hasSetupChatRepeatBtn = false;
}
}
}
private function setupLanguageFlag() : void
{
if(LocalizationManager.currentLanguage != LocalizationManager.accountLanguage)
{
this._chatBarContainer.flag.gotoAndStop(LocalizationManager.currentLanguage + 1);
this._chatBarContainer.text01_chat.width = 258.75;
this._chatBarContainer.text01_chat.x = -130.5;
this._chatBarContainer.flag.addEventListener(MouseEvent.MOUSE_DOWN,this.onEscapeFlagDown,false,0,true);
}
else
{
this._chatBarContainer.flag.gotoAndStop("off");
this._chatBarContainer.text01_chat.width = 290.75;
this._chatBarContainer.text01_chat.x = -162.5;
this._chatBarContainer.flag.removeEventListener(MouseEvent.MOUSE_DOWN,this.onEscapeFlagDown);
}
}
private function isAllowedFreeChat() : Boolean
{
return gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_FREE && LocalizationManager.currentLanguage == LocalizationManager.accountLanguage && LocalizationManager.currentLanguage == LocalizationManager.LANG_ENG;
}
private function onEscapeFlagDown(m:MouseEvent) : void
{
if(Boolean(m))
{
m.stopPropagation();
}
new SBYesNoPopup(GuiManager.guiLayer,LocalizationManager.translatePreferredIdOnly(15989),true,this.onConfirmEscape);
}
private function onConfirmEscape(o:Object) : void
{
if(Boolean(o.status))
{
RoomXtCommManager.sendRoomJoinRequest("jamaa_township.room_main#-1");
}
}
private function openCloseHandler(m:MouseEvent) : void
{
if(this.chatHistory.currentFrameLabel == "open")
{
this.closeChat();
}
else if(!m.currentTarget["up"].isGray)
{
this.openChat();
}
}
private function mouseOverMsgText(m:MouseEvent) : void
{
CursorManager.showICursor(true);
}
private function mouseOutMsgText(m:MouseEvent) : void
{
CursorManager.showICursor(false);
}
private function onTextInput(e:TextEvent) : void
{
e.preventDefault();
this.keyDownListener(this._keyboardEvent,e.text);
}
private function msgTextDownHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(gMainFrame.userInfo.firstFiveMinutes > 0)
{
if(gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_BUBBLE || gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_RESTR_BUBBLE || !Utility.canChat())
{
if(gMainFrame.userInfo.sgChatType != gMainFrame.userInfo.sgChatTypeNonDegraded)
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18406));
}
else
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14713));
}
gMainFrame.stage.focus = null;
return;
}
this.chatMsgText.setSelection(this.chatMsgText.length,this.chatMsgText.length);
gMainFrame.stage.focus = this.chatMsgText;
}
else
{
gMainFrame.stage.focus = null;
}
}
private function chatClickHandler(m:MouseEvent) : void
{
this.brightenChat();
}
private function onTextFieldChanged(evt:Event) : void
{
if(Boolean(this._predictiveTextManager))
{
this._predictiveTextManager.onTextFieldChanged(evt);
}
}
private function keyUpListener(evt:KeyboardEvent) : void
{
if(evt.keyCode > 36 && evt.keyCode < 41)
{
this.chatMsgText.setSelection(this.chatMsgText.length,this.chatMsgText.length);
return;
}
if(this._enableFreeChat)
{
if(gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_PREDICTIVE && !this.isAllowedFreeChat())
{
if(Boolean(this._predictiveTextManager))
{
this._predictiveTextManager.onKeyUp(evt);
}
}
else if(this.isAllowedFreeChat())
{
if(evt.keyCode == Keyboard.ENTER)
{
return;
}
if(evt.keyCode == Keyboard.BACKSPACE)
{
if(this.chatMsgText.restrict == "")
{
this.chatMsgText.restrict = this._previousRestriction;
this._previousRestriction = null;
}
else if(this.chatMsgText.restrict == TEXT_RESTRICTION_INTERROBANG)
{
if(this._numInterrobangs == 0)
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
this._previousRestriction = null;
}
}
}
}
}
}
private function keyDownListener(evt:KeyboardEvent, textFieldInput:String = null) : void
{
var showColorChange:Boolean = false;
var regEx:RegExp = null;
var matchArray:Array = null;
if(textFieldInput == null && evt.keyCode != Keyboard.ENTER && evt.keyCode != Keyboard.BACKSPACE && evt.keyCode != Keyboard.TAB && evt.keyCode != Keyboard.SHIFT && evt.keyCode != Keyboard.ALTERNATE && !evt.altKey && !evt.ctrlKey)
{
this._keyboardEvent = evt;
return;
}
if(this._keyboardEvent == null && evt == null)
{
return;
}
if(this._enableFreeChat)
{
if(this.isAllowedFreeChat())
{
if(evt.shiftKey && evt.keyCode != Keyboard.SHIFT)
{
AJAudio.playTextType();
}
else if(evt.keyCode != Keyboard.SHIFT)
{
AJAudio.playTextType();
}
if(evt.keyCode == Keyboard.ENTER)
{
AJAudio.playTextEnter();
if(this.chatMsgText.text.length > 0)
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
this._previousRestriction = null;
this._numInterrobangs = 0;
this.sendMsgCallback(null);
this._keyboardEvent = null;
return;
}
}
if(evt.keyCode == Keyboard.BACKSPACE)
{
if(this.chatMsgText.restrict == TEXT_RESTRICTION_INTERROBANG)
{
if(this._numInterrobangs == 1)
{
this.chatMsgText.restrict = this._previousRestriction;
this._previousRestriction = TEXT_RESTRICTION;
}
--this._numInterrobangs;
}
else if(this.chatMsgText.restrict == "")
{
this.chatMsgText.restrict = this._previousRestriction;
if(this._previousRestriction == TEXT_RESTRICTION_INTERROBANG)
{
--this._numInterrobangs;
this._previousRestriction = TEXT_RESTRICTION;
}
}
else if(this.chatMsgText.restrict == TEXT_RESTRICTION)
{
this._numInterrobangs = 0;
}
if(evt.ctrlKey)
{
this._numInterrobangs = 0;
this.chatMsgText.restrict = TEXT_RESTRICTION;
this._previousRestriction = null;
}
}
else if(textFieldInput == "." && !evt.shiftKey || evt.shiftKey && (textFieldInput == "?" || textFieldInput == "!"))
{
if(this.chatMsgText.restrict == TEXT_RESTRICTION)
{
this._previousRestriction = TEXT_RESTRICTION;
this.chatMsgText.restrict = TEXT_RESTRICTION_INTERROBANG;
}
++this._numInterrobangs;
}
if(textFieldInput != null && evt.keyCode != Keyboard.SHIFT && evt.keyCode != Keyboard.BACKSPACE && !evt.ctrlKey && evt.keyCode != Keyboard.CAPS_LOCK && evt.keyCode != 144 && evt.keyCode != 145 && evt.keyCode != Keyboard.PAUSE && evt.keyCode != Keyboard.TAB && evt.keyCode != Keyboard.ESCAPE && (evt.keyCode < 112 || evt.keyCode > 126) && evt.keyCode != 91)
{
regEx = new RegExp("[" + this.chatMsgText.restrict + "]","g");
matchArray = textFieldInput.match(regEx);
if(matchArray == null || matchArray.length == 0 || matchArray.length != textFieldInput.length || (this.chatMsgText.maxChars > 0 ? Boolean(this.chatMsgText.length >= this.chatMsgText.maxChars) : Boolean(false)))
{
showColorChange = true;
}
else
{
this.chatMsgText.appendText(textFieldInput);
}
if(showColorChange)
{
AJAudio.playLimitedChatErrorSound();
this.chatMsgText.textColor = 16711680;
this._textColorTimer.start();
}
else
{
this._textColorTimer.reset();
this.chatMsgText.textColor = this._defaultTextColor;
}
}
else
{
this._textColorTimer.reset();
this.chatMsgText.textColor = this._defaultTextColor;
}
this.chatMsgText.setSelection(this.chatMsgText.length,this.chatMsgText.length);
this._keyboardEvent = null;
return;
}
if(Boolean(this._predictiveTextManager))
{
this._predictiveTextManager.onKeyDown(evt,textFieldInput);
}
}
this._keyboardEvent = null;
}
private function onColorTimerComplete(t:TimerEvent) : void
{
if(this._textColorTimer.currentCount == this._textColorTimer.repeatCount)
{
this._textColorTimer.reset();
this.chatMsgText.textColor = this._defaultTextColor;
}
else if(this._textColorTimer.currentCount % 2 == 0)
{
this.chatMsgText.textColor = 16711680;
}
else
{
this.chatMsgText.textColor = this._defaultTextColor;
}
}
private function sendChatBtnDownHandler(evt:MouseEvent) : void
{
if(!evt.currentTarget.isGray)
{
if(gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_PREDICTIVE || !this.isAllowedFreeChat())
{
if(LocalizationManager.accountLanguage != LocalizationManager.currentLanguage)
{
this.onEscapeFlagDown(null);
}
else
{
FeedbackManager.openFeedbackPopup(FeedbackManager.TYPE_DICTIONARY);
}
}
else if(this._enableFreeChat)
{
if(gMainFrame.userInfo.sgChatType == SG_CHAT_TYPE_FREE)
{
this.chatMsgText.restrict = TEXT_RESTRICTION;
this._previousRestriction = null;
this._numInterrobangs = 0;
if(this.chatMsgText.text.length > 0)
{
this.sendMsgCallback(null);
}
return;
}
if(Boolean(this._predictiveTextManager))
{
this._predictiveTextManager.onSendBtnDown(evt);
}
this.chatSendBtn.down.visible = false;
this.chatSendBtn.mouse.visible = true;
this.chatSendBtn.mouse.gotoAndPlay(1);
}
}
}
private function onChatRepeatBtn(evt:MouseEvent) : void
{
if(evt == null || !evt.currentTarget.isGray)
{
if(evt != null && this._chatRepeatWindow.visible)
{
this._chatRepeatWindow.visible = false;
return;
}
if(evt == null && !this._chatRepeatWindow.visible)
{
return;
}
this._chatRepeatWindow.visible = true;
if(this.chatHistory.visible)
{
this.closeChat();
}
if(Boolean(this._repeatChatWindows))
{
this._repeatChatWindows.destroy();
this._repeatChatWindows = null;
}
while(this._chatRepeatWindow.itemWindow.numChildren > 1)
{
this._chatRepeatWindow.itemWindow.removeChildAt(1);
}
this._repeatChatWindows = new WindowGenerator();
this._repeatChatWindows.init(1,this._chatRepeatArray.length,this._chatRepeatArray.length,0,0,0,ItemWindowTextNode,this._chatRepeatArray,"",{
"mouseDown":this.onRepeatChatSelected,
"mouseOver":null,
"mouseOut":null
},null,this.onRepeatWindoesLoaded);
this._chatRepeatWindow.itemWindow.addChild(this._repeatChatWindows);
}
}
private function onRepeatWindoesLoaded(reset:Boolean = false) : void
{
if(Boolean(this._chatRepeatWindow))
{
this._chatRepeatWindow.m.height = reset ? 33 : Math.round(this._repeatChatWindows.height);
this._chatRepeatWindow.m.width = this._chatRepeatWindow.t.width = this._chatRepeatWindow.b.width = reset ? 268 : this._repeatChatWindows.width + 2;
this._chatRepeatWindow.m.y = this._chatRepeatWindow.b.y - this._chatRepeatWindow.m.height;
this._chatRepeatWindow.t.y = this._chatRepeatWindow.m.y - this._chatRepeatWindow.t.height;
this._chatRepeatWindow.itemWindow.x = this._chatRepeatWindow.m.x;
this._chatRepeatWindow.itemWindow.y = this._chatRepeatWindow.m.y;
}
}
private function onRepeatChatSelected(evt:MouseEvent) : void
{
if(!AvatarManager.playerAvatarWorldView.isSameMessage(evt.currentTarget.text))
{
this.sendMsgCallback(null,evt.currentTarget.text);
SBTracker.trackPageview("/game/play/popup/repeatChat/#repeat",-1,SBTracker.TYPE_EVENT);
}
else
{
SBTracker.trackPageview("/game/play/popup/repeatChat/#repeatDeny",-1,SBTracker.TYPE_EVENT);
}
this.closeChatRepeatWindow();
}
}
}
@@ -0,0 +1,175 @@
package gui
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
public class ColorTable extends MovieClip
{
private var _bm:Bitmap;
private var _bmd:BitmapData;
private var _id:int;
private var _currColor:int;
private var _currColorSwatch:Sprite;
private var _secretColorIdx:int;
private var _colorValues:Array;
private var _colorIndexes:Array;
private var _width:int;
private var _height:int;
private var _numRows:int;
private var _numCols:int;
private var _cellWidth:int;
private var _cellHeight:int;
private var _colorChangeCallback:Function;
public function ColorTable()
{
super();
}
public function init(id:int, width:int, height:int, numCols:int, numRows:int, colorValues:Array, colorIndexes:Array, defColor:int, colorChangeCallback:Function, secretColor:int = -1) : void
{
this._id = id;
this._width = width;
this._height = height;
this._colorValues = colorValues;
this._colorIndexes = colorIndexes;
this._numCols = numCols;
this._numRows = numRows;
this._cellWidth = this._width / this._numCols;
this._cellHeight = this._height / this._numRows;
this._colorChangeCallback = colorChangeCallback;
this._secretColorIdx = secretColor;
this._bmd = new BitmapData(this._width,this._height,false,0);
this.fillColorTable();
this._currColor = defColor;
this.setCurrentColorSwatch(this._currColor);
addEventListener(MouseEvent.MOUSE_DOWN,this.colorTableClickHandler,false,0,true);
}
public function destroy() : void
{
if(Boolean(this._bm))
{
this.removeChild(this._bm);
this._bm = null;
}
if(Boolean(this._bmd))
{
this._bmd = null;
}
this._colorIndexes = null;
this._colorValues = null;
removeEventListener(MouseEvent.MOUSE_DOWN,this.colorTableClickHandler);
}
private function fillColorTable() : void
{
var x:int = 0;
var y:int = 0;
var rect:Rectangle = null;
for(var i:int = 0; i < this._colorIndexes.length; i++)
{
x = i % this._numCols * (this._width / this._numCols);
y = Math.floor(i / this._numCols) * (this._height / this._numRows);
rect = new Rectangle(x,y,this._width / this._numCols,this._height / this._numRows);
this._bmd.fillRect(rect,this._colorValues[this._colorIndexes[i]]);
}
this._bm = new Bitmap(this._bmd);
this.addChild(this._bm);
}
private function setCurrentColorSwatch(color:int) : void
{
var i:int;
var x:int = 0;
var y:int = 0;
var idxInPalette:int = -1;
for(i = 0; i < this._colorIndexes.length; i++)
{
if(this._colorIndexes[i] == color)
{
idxInPalette = i;
break;
}
}
if(Boolean(this._currColorSwatch))
{
this.removeChild(this._currColorSwatch);
this._currColorSwatch = null;
}
if(idxInPalette >= 0)
{
x = idxInPalette % this._numCols * this._cellWidth;
y = Math.floor(idxInPalette / this._numCols) * this._cellHeight;
this._currColorSwatch = new Sprite();
with(this._currColorSwatch.graphics)
{
beginFill(0);
drawRect(x,y,_cellWidth,5);
drawRect(x,y + _cellHeight - 5,_cellWidth,5);
drawRect(x,y,5,_cellHeight);
drawRect(x + _cellWidth - 5,y,5,_cellHeight);
}
this.addChild(this._currColorSwatch);
}
}
private function colorTableClickHandler(evt:MouseEvent) : void
{
var idxInColorArray:int = 0;
var clickPt:Point = new Point(evt.localX,evt.localY);
var newColor:int = -1;
if(clickPt.x == this._width)
{
if(this._secretColorIdx == -1)
{
clickPt.x = this._width - 1;
}
else if(clickPt.y < this._cellHeight * (this._numRows - 1))
{
clickPt.x = this._width - 1;
}
else
{
newColor = this._secretColorIdx;
}
}
if(newColor < 0)
{
idxInColorArray = Math.floor(clickPt.x / this._cellWidth) + Math.floor(clickPt.y / this._cellHeight) * this._numCols;
newColor = int(this._colorIndexes[idxInColorArray]);
}
if(this._currColor != newColor)
{
this._currColor = newColor;
this.setCurrentColorSwatch(newColor);
if(this._colorChangeCallback != null)
{
this._colorChangeCallback(this._id,newColor);
}
}
}
}
}
@@ -0,0 +1,94 @@
package gui
{
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.ui.Mouse;
import flash.ui.MouseCursor;
import flash.ui.MouseCursorData;
public class CursorManager extends Sprite
{
private static var _customCursor:Sprite;
private static var _mcd:MouseCursorData;
private static var _previousCursor:String;
public static const CUSTOM_CURSOR:String = "custom_cursor";
public static const DEFAULT_I_CURSOR:String = "ibeam";
public static const DEFAULT_CURSOR:String = "Default_Cursor";
public function CursorManager()
{
super();
}
public static function init() : void
{
_customCursor = GETDEFINITIONBYNAME("Cursor");
_mcd = new MouseCursorData();
}
public static function changeDefaultMouse() : void
{
var v:Vector.<BitmapData> = new Vector.<BitmapData>();
v[0] = convertToBitmapData(_customCursor);
_mcd.data = v;
_mcd.hotSpot = new Point(5,0.5);
Mouse.registerCursor("custom_cursor",_mcd);
Mouse.cursor = "custom_cursor";
}
public static function switchToCursor(cursorName:String) : void
{
var vec:Vector.<BitmapData> = new Vector.<BitmapData>();
switch(cursorName)
{
case CUSTOM_CURSOR:
vec[0] = convertToBitmapData(_customCursor);
_mcd.hotSpot = new Point(5,0.5);
_mcd.data = vec;
Mouse.registerCursor("custom_cursor",_mcd);
Mouse.cursor = "custom_cursor";
break;
case DEFAULT_I_CURSOR:
Mouse.cursor = MouseCursor.IBEAM;
break;
case DEFAULT_CURSOR:
Mouse.unregisterCursor("custom_cursor");
_previousCursor = "";
}
}
public static function showICursor(show:Boolean) : void
{
if(Mouse.cursor != "auto")
{
if(show)
{
_previousCursor = Mouse.cursor;
switchToCursor(DEFAULT_I_CURSOR);
}
else
{
switchToCursor(_previousCursor);
}
}
}
private static function convertToBitmapData(dis:DisplayObject) : BitmapData
{
var bounds:Rectangle = new Rectangle(0,0,19,24);
var bitmap:BitmapData = new BitmapData(19,24,true,0);
bitmap.draw(dis);
return bitmap;
}
}
}
@@ -0,0 +1,307 @@
package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBOkPopup;
import den.DenItem;
import den.DenXtCommManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import item.Item;
import item.ItemXtCommManager;
import loader.MediaHelper;
import localization.LocalizationManager;
public class DailyGiftManager
{
private const GIFTS_RECEIVED_UV:int = 373;
private var _giftingPopupMediaHelper:MediaHelper;
private var _giftingPopupContent:MovieClip;
private var _giftPopup:GiftPopup;
private var _giftIndex:int;
private var _guiLayer:DisplayLayer;
private var _randColorIndex:int;
private var _gemAmount:int;
private var _diamondAmount:int;
private var _closeCallback:Function;
public function DailyGiftManager()
{
super();
}
public function init(giftIndex:int, closeCallback:Function) : void
{
this._guiLayer = GuiManager.guiLayer;
this._closeCallback = closeCallback;
this._giftIndex = giftIndex;
this._giftingPopupMediaHelper = new MediaHelper();
this._giftingPopupMediaHelper.init(2539,this.giftingPopupCallback);
}
public function destroy() : void
{
this.removeEventListeners();
if(Boolean(this._giftPopup))
{
this._giftPopup.destroy();
this._giftPopup = null;
}
if(Boolean(this._giftingPopupContent))
{
DarkenManager.unDarken(this._giftingPopupContent.parent);
this._guiLayer.removeChild(this._giftingPopupContent.parent);
this._giftingPopupContent.visible = false;
this._giftingPopupContent = null;
this._giftingPopupMediaHelper = null;
}
}
private function giftingPopupCallback(img:MovieClip) : void
{
if(Boolean(img))
{
DarkenManager.showLoadingSpiral(false);
this._giftingPopupContent = MovieClip(img.getChildAt(0));
img.x = MainFrame.VIEW_WIDTH * 0.5;
img.y = MainFrame.VIEW_HEIGHT * 0.5;
this.setupPopup();
this.addEventListeners();
this._guiLayer.addChild(img);
DarkenManager.darken(img);
}
}
private function setupPopup() : void
{
var currGift:MovieClip = null;
var itemsReceivedValue:int = int(gMainFrame.userInfo.userVarCache.getUserVarValueById(this.GIFTS_RECEIVED_UV));
for(var i:int = 1; i <= 25; i++)
{
currGift = this._giftingPopupContent["gift" + i];
if(i < this._giftIndex + 1)
{
if(itemsReceivedValue != -1 && (itemsReceivedValue & 1 << i - 1) > 0)
{
currGift.gotoAndStop("opened");
}
else
{
currGift.gotoAndStop("missed");
}
}
else if(i > this._giftIndex + 1)
{
currGift.gotoAndStop("unopened");
currGift.unopenedGift.highlight.visible = false;
currGift.unopenedGift.openTag.visible = false;
currGift.unopenedGift.currIndex = i;
currGift.unopenedGift.shine.visible = false;
currGift.unopenedGift.gift.addEventListener(MouseEvent.MOUSE_DOWN,this.onFutureGiftDown,false,0,true);
}
else if(i == this._giftIndex + 1)
{
currGift.gotoAndStop("unopened");
currGift.unopenedGift.openTag.visible = true;
currGift.unopenedGift.highlight.visible = false;
currGift.unopenedGift.highlight.mouseChildren = false;
currGift.unopenedGift.highlight.mouseEnabled = false;
currGift.unopenedGift.shine.mouseChildren = false;
currGift.unopenedGift.shine.mouseEnabled = false;
currGift.unopenedGift.gift.addEventListener(MouseEvent.MOUSE_DOWN,this.onGiftDown,false,0,true);
currGift.unopenedGift.gift.addEventListener(MouseEvent.ROLL_OVER,this.onGiftOver,false,0,true);
currGift.unopenedGift.gift.addEventListener(MouseEvent.ROLL_OUT,this.onGiftOut,false,0,true);
}
}
}
public function setupGiftPopup() : void
{
var currItem:Object = null;
var def:Object = null;
var giftType:int = 0;
var CLOTHING_ITEM:int = 0;
var DEN_ITEM:int = 1;
var GEMS:int = 2;
var DIAMONDS:int = 3;
var giftValue:Array = new Array(DEN_ITEM,GEMS,CLOTHING_ITEM,DEN_ITEM,GEMS,DEN_ITEM,CLOTHING_ITEM,DIAMONDS,DEN_ITEM,DEN_ITEM,GEMS,CLOTHING_ITEM,DEN_ITEM,GEMS,DEN_ITEM,DEN_ITEM,GEMS,DEN_ITEM,DEN_ITEM,DEN_ITEM,DIAMONDS,DEN_ITEM,CLOTHING_ITEM,CLOTHING_ITEM,GEMS);
var defArray:Array = new Array(1354,300,690,1349,400,1352,691,1,1351,715,600,526,1353,700,1348,1350,800,1161,1164,1165,1,717,525,692,1000);
var randColor:int = 0;
var index:int = int(gMainFrame.clientInfo.dailyGiftIndex);
if(index <= giftValue.length)
{
if(giftValue[this._giftIndex] == CLOTHING_ITEM)
{
def = ItemXtCommManager.getItemDef(defArray[index]);
this._randColorIndex = (def.colors.length - 1) * Math.random();
currItem = new Item();
currItem.init(def.defId,0,def.colors[this._randColorIndex],0,0,true);
giftType = GiftPopup.GIFT_TYPE_CLOTHING;
}
else if(giftValue[this._giftIndex] == DEN_ITEM)
{
def = DenXtCommManager.getDenItemDef(defArray[index]);
currItem = new DenItem();
currItem.initShopItem(def.id,0);
giftType = GiftPopup.GIFT_TYPE_DEN_ACC;
}
else if(giftValue[this._giftIndex] == GEMS)
{
giftType = GiftPopup.GIFT_TYPE_GEMS;
}
else if(giftValue[this._giftIndex] == DIAMONDS)
{
giftType = GiftPopup.GIFT_TYPE_DIAMOND;
}
if(giftType == GiftPopup.GIFT_TYPE_GEMS)
{
this._gemAmount = defArray[index];
this._giftingPopupMediaHelper = new MediaHelper();
this._giftingPopupMediaHelper.init(StartupPopups.GEMS_MEDIA_ID,this.onGemIconLoaded);
}
else if(giftType == GiftPopup.GIFT_TYPE_DIAMOND)
{
this._diamondAmount = defArray[index];
this._giftingPopupMediaHelper = new MediaHelper();
this._giftingPopupMediaHelper.init(StartupPopups.DIAMOND_MEDIA_ID,this.onDiamondIconLoaded);
}
else
{
this._giftPopup = new GiftPopup();
this._giftPopup.init(this._guiLayer,currItem.largeIcon,currItem.name,defArray[index],GiftPopup.POPUP_TYPE_JAMAALIDAY_GIFT,giftType,this.keepGiftCallback,this.rejectGiftCallback);
}
}
else
{
DarkenManager.showLoadingSpiral(false);
}
}
private function onGemIconLoaded(img:MovieClip) : void
{
if(Boolean(img))
{
this._giftPopup = new GiftPopup();
this._giftPopup.init(this._guiLayer,img,LocalizationManager.translateIdAndInsertOnly(LocalizationManager.GEMS_CAPITALIZED,this._gemAmount),this._gemAmount,GiftPopup.POPUP_TYPE_JAMAALIDAY_GIFT,GiftPopup.GIFT_TYPE_GEMS,null,this.keepGiftCallback,null,false,GiftPopup.BUTTONS_TYPE_OK);
}
}
private function onDiamondIconLoaded(img:MovieClip) : void
{
if(Boolean(img))
{
this._giftPopup = new GiftPopup();
this._giftPopup.init(this._guiLayer,img,LocalizationManager.translateIdAndInsertOnly(LocalizationManager.DIAMONDS_CAPITALIZED,this._diamondAmount),this._gemAmount,GiftPopup.POPUP_TYPE_JAMAALIDAY_GIFT,GiftPopup.GIFT_TYPE_DIAMOND,null,this.keepGiftCallback,null,false,GiftPopup.BUTTONS_TYPE_OK);
}
}
private function onClose(m:MouseEvent) : void
{
m.stopPropagation();
SBTracker.trackPageview("game/play/popup/dailyGift/close");
this.close();
}
private function keepGiftCallback() : void
{
DarkenManager.showLoadingSpiral(true);
this._giftingPopupContent.visible = false;
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_DAILY_GEM_BONUS,this._randColorIndex,this.setVarCallback);
AchievementXtCommManager.requestSetUserVar(this.GIFTS_RECEIVED_UV,this._giftIndex);
}
private function rejectGiftCallback() : void
{
this.close();
}
private function setVarCallback(varDefId:int, value:int) : void
{
if(this._gemAmount > 0)
{
gMainFrame.clientInfo.gemCount += this._gemAmount;
}
if(this._diamondAmount > 0)
{
gMainFrame.clientInfo.diamondCount += this._diamondAmount;
}
DarkenManager.showLoadingSpiral(false);
this.close();
}
private function close() : void
{
if(this._closeCallback != null)
{
this._closeCallback();
this._closeCallback = null;
}
else
{
this.destroy();
}
}
private function onGiftDown(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.trackPageview("game/play/popup/dailyGift/" + evt.currentTarget.name);
this.setupGiftPopup();
}
private function onFutureGiftDown(evt:MouseEvent) : void
{
evt.stopPropagation();
var numDays:int = evt.currentTarget.parent.currIndex - (this._giftIndex + 1);
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdAndInsertOnly(numDays == 1 ? 11383 : 11384,numDays));
}
private function onGiftOver(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.parent.highlight.visible = true;
}
private function onGiftOut(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.parent.highlight.visible = false;
}
private function onPopupDown(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function addEventListeners() : void
{
this._giftingPopupContent.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
this._giftingPopupContent.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
}
private function removeEventListeners() : void
{
var currGift:MovieClip = null;
this._giftingPopupContent.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._giftingPopupContent.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown);
for(var i:int = this._giftIndex + 1; i <= 25; i++)
{
currGift = this._giftingPopupContent["gift" + i];
currGift.unopenedGift.removeEventListener(MouseEvent.MOUSE_DOWN,this.onGiftDown);
currGift.unopenedGift.removeEventListener(MouseEvent.ROLL_OVER,this.onGiftOver);
currGift.unopenedGift.removeEventListener(MouseEvent.ROLL_OUT,this.onGiftOut);
}
}
}
}
@@ -0,0 +1,252 @@
package gui
{
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.getTimer;
public class DarkenManager
{
private static var _darken:Vector.<DisplayObjectContainer>;
private static var _stageDarkBG:Sprite;
private static var _darkBG:Sprite;
private static var _stageBlockBG:Sprite;
private static var _layer:DisplayLayer;
private static var _spiral:LoadingSpiral;
public static var setFocus:Function;
public function DarkenManager()
{
super();
}
public static function init(layer:DisplayLayer) : void
{
_darken = new Vector.<DisplayObjectContainer>();
_darkBG = new Sprite();
_stageBlockBG = new Sprite();
_stageDarkBG = new Sprite();
addListeners();
makeDarkShape();
makeStageDarkBG();
makeLightStageBlock();
gMainFrame.stage.addEventListener(Event.RESIZE,onStageResize,false,0,true);
_spiral = new LoadingSpiral(null);
_spiral.isDarkenManagersSpiral = true;
_layer = layer;
}
public static function destroy() : void
{
_darkBG.removeEventListener(MouseEvent.MOUSE_DOWN,blockMouseHandler);
_stageDarkBG.removeEventListener(MouseEvent.MOUSE_DOWN,blockMouseHandler);
_stageBlockBG.removeEventListener(MouseEvent.MOUSE_DOWN,blockMouseHandler);
for(var i:int = 0; i < _darken.length; i++)
{
while(Boolean(_darken[i].numChildren))
{
_darken[i].removeChildAt(0);
}
}
if(Boolean(_spiral))
{
_spiral.destroy();
_spiral = null;
}
_darken = null;
_darkBG.x = undefined;
_darkBG.y = undefined;
_darkBG = null;
removeInvisibleBlockBG();
_stageBlockBG.x = undefined;
_stageBlockBG.y = undefined;
_stageBlockBG = null;
_layer = null;
_stageDarkBG = null;
}
public static function showLoadingSpiral(show:Boolean, displayPercentText:Boolean = false) : void
{
if(Boolean(_spiral))
{
if(show)
{
_spiral.setNewParent(_layer,450,275,displayPercentText);
darken(_spiral);
}
else
{
unDarken(_spiral);
_spiral.destroy();
}
}
}
public static function updateLoadingSpiralPercentage(percent:String) : void
{
_spiral.updatePercentText(percent);
}
public static function clearDarkenList() : void
{
if(Boolean(_darken))
{
_darken.length = 0;
}
removeInvisibleBlockBG();
}
public static function addListeners() : void
{
_darkBG.addEventListener(MouseEvent.MOUSE_DOWN,blockMouseHandler,false,0,true);
_stageDarkBG.addEventListener(MouseEvent.MOUSE_DOWN,blockMouseHandler,false,0,true);
_stageBlockBG.addEventListener(MouseEvent.MOUSE_DOWN,blockMouseHandler,false,0,true);
}
public static function makeDarkShape() : void
{
_darkBG.graphics.beginFill(0,0.5);
_darkBG.graphics.drawRect(0,0,MainFrame.VIEW_WIDTH,MainFrame.VIEW_HEIGHT);
_darkBG.graphics.endFill();
_darkBG.x = -MainFrame.VIEW_WIDTH * 0.5;
_darkBG.y = -MainFrame.VIEW_HEIGHT * 0.5;
}
private static function makeLightStageBlock() : void
{
_stageBlockBG.graphics.beginFill(0,0);
_stageBlockBG.graphics.drawRect(0,0,gMainFrame.stage.stageWidth,gMainFrame.stage.stageHeight);
_stageBlockBG.graphics.endFill();
_stageBlockBG.x = -gMainFrame.stage.stageWidth * 0.5 + MainFrame.VIEW_WIDTH * 0.5;
_stageBlockBG.y = -gMainFrame.stage.stageHeight * 0.5 + MainFrame.VIEW_HEIGHT * 0.5;
}
private static function makeStageDarkBG(evt:Event = null) : void
{
_stageDarkBG.graphics.clear();
_stageDarkBG.graphics.beginFill(0,0.5);
_stageDarkBG.graphics.drawRect(0,0,gMainFrame.stage.stageWidth,gMainFrame.stage.stageHeight);
_stageDarkBG.graphics.endFill();
_stageDarkBG.x = -gMainFrame.stage.stageWidth * 0.5 + MainFrame.VIEW_WIDTH * 0.5;
_stageDarkBG.y = -gMainFrame.stage.stageHeight * 0.5 + MainFrame.VIEW_HEIGHT * 0.5;
if(_stageDarkBG.parent == null)
{
gMainFrame.stage.addChildAt(_stageDarkBG,0);
}
}
private static function onStageResize(evt:Event) : void
{
makeStageDarkBG(evt);
}
private static function blockMouseHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
}
public static function addInvisibleBlockBG() : void
{
if(Boolean(_stageBlockBG))
{
if(Boolean(_stageBlockBG.parent))
{
_stageBlockBG.parent.removeChild(_stageBlockBG);
}
gMainFrame.stage.addChild(_stageBlockBG);
}
}
public static function removeInvisibleBlockBG() : void
{
if(Boolean(_stageBlockBG))
{
if(Boolean(_stageBlockBG.parent))
{
_stageBlockBG.parent.removeChild(_stageBlockBG);
}
}
}
public static function darken(popUp:DisplayObjectContainer) : void
{
popUp.addChildAt(_darkBG,0);
var parentPopup:DisplayObjectContainer = popUp;
while(parentPopup != null && parentPopup.parent != _layer)
{
if(parentPopup.parent == null)
{
break;
}
parentPopup = parentPopup.parent;
}
_darkBG.x = -parentPopup.x;
_darkBG.y = -parentPopup.y;
if(setFocus != null)
{
setFocus(false);
}
if(_darken.indexOf(popUp) < 0)
{
_darken.push(popUp);
}
}
public static function unDarken(popup:DisplayObjectContainer) : void
{
var index:int = 0;
var nextPopup:DisplayObjectContainer = null;
var parentPopup:DisplayObjectContainer = null;
var time:int = getTimer();
if(Boolean(popup) && _darkBG.parent == popup)
{
popup.removeChild(_darkBG);
index = _darken.indexOf(popup);
if(index >= 0)
{
_darken.splice(index,1);
}
if(_darken.length > 0)
{
nextPopup = _darken[_darken.length - 1];
parentPopup = nextPopup;
nextPopup.addChildAt(_darkBG,0);
while(parentPopup != null && parentPopup.parent != _layer)
{
if(parentPopup.parent == null)
{
break;
}
parentPopup = parentPopup.parent;
}
_darkBG.x = -parentPopup.x;
_darkBG.y = -parentPopup.y;
}
gMainFrame.stage.invalidate();
}
}
public static function get isDarkened() : Boolean
{
var isDarkened:Boolean = false;
for(var i:int = 0; i < _darken.length; i++)
{
if(_darken[i].visible)
{
isDarkened = true;
break;
}
}
return isDarkened;
}
}
}
@@ -0,0 +1,346 @@
package gui
{
import avatar.AvatarSwitch;
import avatar.AvatarXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.corelib.audio.SBAudio;
import com.sbi.debug.DebugUtility;
import com.sbi.loader.LoaderCache;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import loader.MediaHelper;
import localization.LocalizationManager;
public class DemotionMessages
{
private var _demotionMessage:MediaHelper;
private var _newMemberPopup:MovieClip;
private var _content:MovieClip;
private var _idx:int;
private var _gaIdx:int;
private var _choose:SwitchManager;
private var _currSound:Sound;
private var _currSoundChannel:SoundChannel;
private var _closeCallBack:Function;
private var _roomVolume:Number;
private var _hasChosen:Boolean;
private var _wasMusicMuted:Boolean;
private var _startingIndex:int;
public function DemotionMessages()
{
super();
}
public function init(initCloseCallback:Function = null) : void
{
this._demotionMessage = new MediaHelper();
this._demotionMessage.init(156,this.demotionCallback);
this._closeCallBack = initCloseCallback;
}
public function destroy() : void
{
this.removeListeners();
DarkenManager.unDarken(this._newMemberPopup);
if(Boolean(this._demotionMessage))
{
this._demotionMessage.destroy();
}
this._newMemberPopup.visible = false;
this._newMemberPopup = null;
this._content.visible = false;
this._content = null;
if(this._closeCallBack != null)
{
this._closeCallBack();
}
if(Boolean(this._currSoundChannel))
{
this._currSoundChannel.stop();
this._currSoundChannel = null;
}
this._closeCallBack = null;
}
public function goToNextPage() : void
{
this.nextBtnHandler(null);
}
public function set hasChosen(value:Boolean) : void
{
this._hasChosen = value;
}
private function demotionCallback(img:MovieClip) : void
{
this._newMemberPopup = img;
this._newMemberPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._newMemberPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._newMemberPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.demotionMouseDownHandler,false,0,true);
GuiManager.guiLayer.addChild(this._newMemberPopup);
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._newMemberPopup);
this._content = this._newMemberPopup.getChildAt(1)["c"];
this._content.soundBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.soundBtnHandler,false,0,true);
this._content.chooseBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.chooseBtnHandler,false,0,true);
this._content.renewBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.joinBtnHandler,false,0,true);
this._content.nextBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.nextBtnHandler,false,0,true);
this._content.noThanksBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.demotionCloseHandler,false,0,true);
this._content.chooseBtn.visible = false;
this._content.noThanksBtn.visible = false;
switch(LocalizationManager.currentLanguage)
{
case LocalizationManager.LANG_ENG:
this._startingIndex = 67;
break;
case LocalizationManager.LANG_SPA:
this._startingIndex = 676;
break;
case LocalizationManager.LANG_POR:
this._startingIndex = 631;
break;
case LocalizationManager.LANG_FRE:
this._startingIndex = 626;
break;
case LocalizationManager.LANG_DE:
this._startingIndex = 621;
break;
default:
this._startingIndex = 67;
}
this._idx = 1;
this._gaIdx = 2;
this._currSound = new Sound();
this._currSound.load(LoaderCache.fetchCDNURLRequest("streams/" + (this._startingIndex + this._idx) + ".mp3"));
this.playSoundCallback();
}
private function playSoundCallback() : void
{
this._wasMusicMuted = SBAudio.isMusicMuted;
if(!this._wasMusicMuted)
{
SBAudio.muteMusic();
}
this._currSoundChannel = this._currSound.play();
}
private function nextBtnHandler(m:MouseEvent) : void
{
var avatars:Array = null;
var avatarsChosen:Array = null;
var slot1:int = 0;
var slot2:int = 0;
var shouldAdd:Boolean = false;
var numNonMemberAvatars:int = 0;
var i:int = 0;
if(Boolean(m))
{
m.stopPropagation();
}
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/demotion/#page" + this._gaIdx);
var shouldChoose:Boolean = AvatarSwitch.shouldChoose();
++this._gaIdx;
++this._idx;
if(!this._hasChosen && !shouldChoose && this._idx > 2)
{
++this._idx;
avatars = AvatarSwitch.avatars;
avatarsChosen = new Array();
numNonMemberAvatars = AvatarSwitch.numNonMemberAvatars;
for(i = 0; i < avatars.length; i++)
{
if(Boolean(avatars[i]))
{
if(!AvatarSwitch.isMemberOnlyAvatar(i))
{
shouldAdd = true;
}
}
else if(i >= numNonMemberAvatars - 1)
{
shouldAdd = true;
}
if(shouldAdd)
{
shouldAdd = false;
if(avatarsChosen[0] == null && Boolean(avatars[i]))
{
avatarsChosen[0] = slot1 = i;
}
else
{
avatarsChosen[1] = slot2 = i;
}
if(avatarsChosen[0] != null && avatarsChosen[1] != null)
{
break;
}
}
}
if(avatarsChosen[1] != null && Boolean(avatars[slot2]))
{
AvatarSwitch.availSlotFlags = 1 << AvatarXtCommManager.avSlotInfo[avatars[slot1].perUserAvId].avInvId | 1 << AvatarXtCommManager.avSlotInfo[avatars[slot2].perUserAvId].avInvId;
}
else
{
AvatarSwitch.availSlotFlags = 1 << AvatarXtCommManager.avSlotInfo[avatars[slot1].perUserAvId].avInvId;
}
DarkenManager.showLoadingSpiral(true);
this._content.nextBtn.visible = false;
AvatarSwitch.chooseTwo(avatarsChosen,this.onAvatarChooseCallback);
return;
}
if(this._idx == 3)
{
this._content.renewBtn.visible = false;
this._content.nextBtn.visible = false;
this._content.chooseBtn.visible = true;
}
if(this._idx == 4 && shouldChoose)
{
this._content.chooseBtn.visible = false;
this._content.nextBtn.visible = false;
this._content.noThanksBtn.visible = true;
}
if(Boolean(this._currSoundChannel))
{
this._currSoundChannel.stop();
}
this._currSound = new Sound();
this._currSound.load(LoaderCache.fetchCDNURLRequest("streams/" + (this._startingIndex + this._idx) + ".mp3"));
this._currSoundChannel = this._currSound.play();
this._content.gotoAndStop("p" + this._idx);
}
private function onAvatarChooseCallback(success:Boolean) : void
{
DarkenManager.showLoadingSpiral(false);
if(Boolean(this._currSoundChannel))
{
this._currSoundChannel.stop();
}
if(success)
{
this._content.chooseBtn.visible = false;
this._content.nextBtn.visible = false;
this._content.noThanksBtn.visible = true;
this._currSound = new Sound();
this._currSound.load(LoaderCache.fetchCDNURLRequest("streams/" + (this._startingIndex + this._idx) + ".mp3"));
this._currSoundChannel = this._currSound.play();
this._content.gotoAndStop("p" + this._idx);
}
else
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(11233));
this._content.nextBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.nextBtnHandler);
this._content.nextBtn.visible = true;
}
}
private function joinBtnHandler(m:MouseEvent) : void
{
var url:String;
var request:URLRequest;
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/demotion/renew");
m.stopPropagation();
url = gMainFrame.clientInfo.websiteURL + "membership";
request = new URLRequest(url);
try
{
navigateToURL(request,"_blank");
}
catch(e:Error)
{
DebugUtility.debugTrace("error with loading URL");
}
}
private function chooseBtnHandler(m:MouseEvent) : void
{
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/demotion/avatarChoose");
m.stopPropagation();
if(Boolean(this._currSoundChannel))
{
this._currSoundChannel.stop();
}
GuiManager.openAvatarChoose();
this._content.chooseBtn.visible = false;
this._content.renewBtn.visible = true;
this._content.noThanksBtn.visible = true;
}
private function soundBtnHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(Boolean(this._currSoundChannel))
{
this._currSoundChannel.stop();
this._currSoundChannel = this._currSound.play();
}
else
{
this._currSoundChannel = this._currSound.play();
}
}
private function demotionMouseDownHandler(m:MouseEvent) : void
{
m.stopPropagation();
}
private function demotionCloseHandler(m:MouseEvent) : void
{
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/demotion/page4_noThanks");
if(Boolean(this._currSoundChannel))
{
this._currSoundChannel.stop();
this._currSoundChannel = this._currSound.play();
}
else
{
this._currSoundChannel = this._currSound.play();
}
if(!this._wasMusicMuted)
{
SBAudio.unmuteMusic();
}
m.stopPropagation();
this.destroy();
}
private function removeListeners() : void
{
this._content.chooseBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.chooseBtnHandler);
this._content.renewBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.joinBtnHandler);
this._content.nextBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.nextBtnHandler);
this._content.noThanksBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.demotionCloseHandler);
this._newMemberPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.demotionMouseDownHandler);
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,155 @@
package gui
{
import com.sbi.popup.SBYesNoPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import localization.LocalizationManager;
import room.RoomManagerWorld;
public class DenPreviewManager
{
private static var _currentShop:Shop;
private static var _buyAndBackBtns:MovieClip;
private static var _loadingMediaHelper:MediaHelper;
public function DenPreviewManager()
{
super();
}
public static function setCurrentShop(shop:Shop) : void
{
_currentShop = shop;
}
public static function handleAllRequiredVisibilities(on:Boolean) : void
{
GuiManager.toggleHud();
handleDenSwitcherandShopVisibility(on);
GuiManager.showDenHudItems(on);
if(Boolean(_buyAndBackBtns))
{
_buyAndBackBtns.visible = !on;
}
else if(!on)
{
showBuyAndBackBtns(true);
}
}
public static function handleDenPurchase() : void
{
if(Boolean(_buyAndBackBtns) && _buyAndBackBtns.visible)
{
RoomManagerWorld.instance.reloadCurrentNormalRoom();
_buyAndBackBtns.visible = false;
}
}
public static function showBuyAndBackBtns(show:Boolean) : void
{
if(show)
{
if(Boolean(_buyAndBackBtns))
{
_buyAndBackBtns.visible = true;
}
else
{
_loadingMediaHelper = new MediaHelper();
_loadingMediaHelper.init(2969,onBuyAndBackBtnsLoaded);
}
}
else if(Boolean(_buyAndBackBtns))
{
_buyAndBackBtns.visible = false;
}
}
public static function exitPreview() : void
{
onBackBtn(null);
}
private static function handleDenSwitcherandShopVisibility(show:Boolean) : void
{
if(show)
{
GuiManager.showDenSwitcher(true);
if(Boolean(_currentShop))
{
_currentShop.showShop(true);
}
}
else
{
if(Boolean(_currentShop))
{
_currentShop.showShop(false);
}
GuiManager.showDenSwitcher(false);
}
}
private static function onBuyAndBackBtnsLoaded(img:MovieClip) : void
{
if(Boolean(img))
{
_buyAndBackBtns = img;
_buyAndBackBtns.backBtn.addEventListener(MouseEvent.MOUSE_DOWN,onBackBtn,false,0,true);
_buyAndBackBtns.buyBtn.addEventListener(MouseEvent.MOUSE_DOWN,onBuyBtn,false,0,true);
GuiManager.guiLayer.addChild(_buyAndBackBtns);
}
}
private static function onBackBtn(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(Boolean(_buyAndBackBtns) && _buyAndBackBtns.visible)
{
RoomManagerWorld.instance.reloadCurrentNormalRoom();
_buyAndBackBtns.visible = false;
}
}
private static function onBuyBtn(evt:MouseEvent) : void
{
var denDef:Object = null;
evt.stopPropagation();
if(Boolean(_currentShop))
{
if(_currentShop.isDiamondStore)
{
_currentShop.attemptToBuyCurrrentItem();
}
else
{
denDef = gMainFrame.userInfo.denRoomDefs[_currentShop.getCurrentItemDefId()];
if(Boolean(denDef))
{
new SBYesNoPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(10305,Utility.convertNumberToString(denDef.value)),true,onPreviewBuy);
}
}
}
}
private static function onPreviewBuy(o:Object) : void
{
if(Boolean(o.status))
{
if(Boolean(_currentShop))
{
_currentShop.attemptToBuyCurrrentItem();
}
}
}
}
}
@@ -0,0 +1,171 @@
package gui
{
import avatar.UserInfo;
import den.DenXtCommManager;
public class DenSwitch
{
public static var activeDenIdx:int;
public static var playerUserInfo:UserInfo;
public static var playerUsername:String;
public static var playerSfsUserId:int;
private static var _denList:Array;
private static var _addDenCallback:Function;
private static var _removeCallback:Function;
private static var _switchIdx:int;
private static var _removeIdx:int;
private static var _maxSlots:int;
private static var _numSlots:int;
public static const RECYCLE_DEN_ROOM:int = 99;
public function DenSwitch()
{
super();
}
public static function init(initActiveDenIdx:int) : void
{
setActiveDenIdx(initActiveDenIdx);
}
public static function destroy() : void
{
}
public static function setActiveDenIdx(newActiveDenIdx:int) : void
{
activeDenIdx = newActiveDenIdx;
}
public static function denInfoSet() : void
{
}
private static function updateDens() : void
{
}
public static function get numSlots() : int
{
return _numSlots;
}
public static function get numDens() : int
{
var numDens:int = 0;
for(var i:int = 0; i < _denList.length; i++)
{
if(Boolean(_denList[i]))
{
numDens++;
}
}
return numDens;
}
public static function addNewDen(caIdx:int, denName:String, addDenCallback:Function) : void
{
_addDenCallback = addDenCallback;
}
public static function addDenResponse(success:Boolean, newDenId:int) : void
{
if(success)
{
}
if(_addDenCallback != null)
{
_addDenCallback(success);
}
}
public static function switchDens(switchIdx:int, switchDensCallback:Function = null) : void
{
if(switchIdx < 0 || switchIdx >= _denList.length)
{
throw new Error("Invalid switchIdx:" + switchIdx);
}
_switchIdx = switchIdx;
activeDenIdx = _denList[_switchIdx].invId;
DenXtCommManager.requestDenChange(switchIdx,switchDensCallback);
}
public static function denListResponse(dList:Array) : void
{
_denList = dList;
}
public static function removeDen(removeIdx:int, removeDensCallback:Function) : void
{
if(removeIdx < 0 || removeIdx >= _denList.length)
{
throw new Error("Invalid removeIdx:" + removeIdx);
}
_removeCallback = removeDensCallback;
_removeIdx = removeIdx;
if(_denList[removeIdx].invId != activeDenIdx && _denList[removeIdx].invId > 0)
{
DenXtCommManager.requestRecycle(false,_denList[removeIdx].invId,denRecycleResponse);
}
else
{
denRecycleResponse(false);
}
}
public static function denRecycleResponse(success:Boolean) : void
{
if(success)
{
_denList[_removeIdx] = null;
}
if(_removeCallback != null)
{
_removeCallback(success,_removeIdx);
}
_removeIdx = -1;
}
public static function get denList() : Array
{
return _denList;
}
public static function get nextFreeSlotIdx() : int
{
for(var i:int = 0; i < SwitchManager.NUM_DEN_ROOM_SLOTS; i++)
{
if(!_denList[i])
{
return i;
}
}
return -1;
}
public static function haveOceanDen() : Boolean
{
for(var i:int = 0; i < _denList.length; i++)
{
if(Boolean(_denList[i]) && _denList[i].enviroType == Utility.ENVIRO_OCEAN)
{
return true;
}
}
return false;
}
}
}
@@ -0,0 +1,641 @@
package gui
{
import avatar.Avatar;
import com.sbi.client.KeepAlive;
import com.sbi.popup.SBYesNoPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.DefPacksDefHelper;
import loader.MediaHelper;
import localization.LocalizationManager;
public class DenSwitcher
{
private const MIN_NUM_DENS:int = 1;
private const DENSWITCH_MEDIA_ID:int = 1168;
private var _numTotalSlots:int;
private var _playerAvatar:Avatar;
private var _guiLayer:DisplayLayer;
private var _closeCallback:Function;
private var _shop:Shop;
private var _views:Array;
private var _activeIdx:int;
private var _idx:int;
private var _recycling:Boolean;
private var _recyclingOnly:Boolean;
private var _loadingMediaHelper:MediaHelper;
private var _mediaHelpers:Array;
private var _contentItems:Array;
private var _switchContent:MovieClip;
private var _closeBtn:MovieClip;
private var _choosingContent:MovieClip;
private var _scrollButtons:SBScrollbar;
private var _itemWindows:WindowGenerator;
private var _openStoreOnly:Boolean;
private var _firstOpenIdx:int;
private var _glId:int;
private var _storeItemIndex:int;
public function DenSwitcher()
{
super();
}
public function init(initPlayerAvatar:Avatar, initGuiLayer:DisplayLayer, isRecycling:Boolean = false, openStoreOnly:Boolean = false, initCloseCallback:Function = null, initFirstOpenIndex:int = -1, initGlId:int = -1, initShopItemIndex:int = -1, initPopupX:int = 450, initPopupY:int = 250) : void
{
DarkenManager.showLoadingSpiral(true);
this._playerAvatar = initPlayerAvatar;
this._guiLayer = initGuiLayer;
this._closeCallback = initCloseCallback;
this._recyclingOnly = isRecycling;
this._openStoreOnly = openStoreOnly;
this._firstOpenIdx = initFirstOpenIndex;
this._storeItemIndex = initShopItemIndex;
this._numTotalSlots = SwitchManager.NUM_DEN_ROOM_SLOTS;
this._mediaHelpers = [];
if(initGlId == -1)
{
this._glId = GenericListXtCommManager.DEN_ROOM_SHOP_ID;
}
else
{
this._glId = initGlId;
}
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this.DENSWITCH_MEDIA_ID,this.onMediaItemLoaded,true);
this._mediaHelpers.push(this._loadingMediaHelper);
}
public function destroy() : void
{
this.removeListeners();
KeepAlive.stopKATimer(this._switchContent);
for(var i:int = 0; i < this._views.length; i++)
{
if(Boolean(this._views[i]))
{
this._views[i].destroy();
this._views[i] = null;
}
}
if(Boolean(this._shop))
{
this._shop.destroy();
this._shop = null;
}
if(Boolean(this._switchContent))
{
if(this._switchContent.root.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._switchContent.root);
}
DarkenManager.unDarken(MovieClip(this._switchContent.root));
this._switchContent.root.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._switchContent = null;
if(Boolean(this._closeBtn))
{
this._closeBtn = null;
}
if(Boolean(this._contentItems))
{
this._contentItems = null;
}
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
this._recyclingOnly = false;
this._recycling = false;
this._closeCallback = null;
}
public function close() : void
{
if(this._closeCallback != null)
{
this._closeCallback();
}
else
{
this.destroy();
}
}
public function get idx() : int
{
return this._idx;
}
public function showDenSwitcher(show:Boolean) : void
{
if(Boolean(this._switchContent) && this._switchContent.root.visible != show)
{
this._switchContent.root.visible = show;
if(show)
{
DarkenManager.darken(MovieClip(this._switchContent.root));
}
else
{
DarkenManager.unDarken(MovieClip(this._switchContent.root));
}
}
}
private function onMediaItemLoaded(img:MovieClip) : void
{
var shouldOpenItemWindow:Boolean = false;
if(Boolean(img))
{
this._closeBtn = MovieClip(img.getChildAt(0)).bx;
this._switchContent = MovieClip(img.getChildAt(0)).c;
KeepAlive.startKATimer(this._switchContent);
this._guiLayer.addChild(img);
img.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
img.x = MainFrame.VIEW_WIDTH * 0.5;
img.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(img);
this.addListeners();
shouldOpenItemWindow = this._firstOpenIdx != -1;
this.initVisibilityAndStates();
this.buildWindows();
if(this._openStoreOnly)
{
img.visible = false;
this.onItemWindowDown(null);
}
else if(shouldOpenItemWindow)
{
this.onItemWindowDown(null);
}
}
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function initVisibilityAndStates() : void
{
this._activeIdx = DenSwitch.activeDenIdx;
this._switchContent.buyPopup.tag.visible = false;
this._switchContent.oopsPopup.body_txt.text = "";
LocalizationManager.translateId(this._switchContent.switchTitleTxt,11271);
this._switchContent.buyPopup.tag.txt.text = "";
this._switchContent.buyPopup.paw.gray.visible = false;
this._switchContent.buyPopup.banner.visible = false;
this._switchContent.buyPopup.lock.visible = false;
this._switchContent.buyPopup.lockOpen.visible = false;
this._switchContent.buyPopup.colorChange_btn.visible = false;
this._switchContent.buyPopup.paw.visible = true;
this._switchContent.buyPopup.visible = false;
this._switchContent.oopsPopup.visible = false;
this._switchContent.oopsCostPopup.visible = false;
this._switchContent.denShopTag.visible = false;
this._switchContent.saveAmlTag.visible = false;
}
private function buildWindows() : void
{
var mc:MovieClip = null;
var denRoomHelper:MediaHelper = null;
if(Boolean(this._scrollButtons))
{
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
var numItemsInCurrentArray:int = this._numTotalSlots;
var xCount:int = Math.min(numItemsInCurrentArray,4);
var yCount:int = Math.ceil(xCount / 2);
this._itemWindows = new WindowGenerator();
this._itemWindows.init(xCount,yCount,numItemsInCurrentArray,2,2,0,ItemWindowAnimal,DenSwitch.denList,"icon",{
"mouseDown":this.onItemWindowDown,
"mouseOver":this.onItemWindowOver,
"mouseOut":this.onItemWindowOut
},{"recylingOnly":this._recyclingOnly},null,false,false);
this._switchContent.itemBlock.addChild(this._itemWindows);
this._views = new Array(this._numTotalSlots);
this._contentItems = new Array(this._numTotalSlots);
this._activeIdx = DenSwitch.activeDenIdx;
for(var i:int = 0; i < this._numTotalSlots; i++)
{
mc = MovieClip(this._itemWindows.bg.getChildAt(i));
this._contentItems[i] = mc;
if(DenSwitch.denList[i] != null)
{
denRoomHelper = new MediaHelper();
denRoomHelper.init(DenSwitch.denList[i].mediaId,this.mediaHelperCallback,DenSwitch.denList[i].isMemberOnly);
this._views[i] = denRoomHelper;
}
else if(this._firstOpenIdx == -1)
{
this._firstOpenIdx = i;
}
}
if(this._firstOpenIdx == -1)
{
this._firstOpenIdx = 0;
}
var numDens:int = DenSwitch.numDens;
if(numDens > this.MIN_NUM_DENS)
{
this._switchContent.recycleBtn.gray.visible = false;
this._switchContent.recycleBtn.mouse.visible = true;
this._switchContent.recycleBtn.down.visible = false;
}
else
{
this._switchContent.recycleBtn.gray.visible = true;
this._switchContent.recycleBtn.mouse.visible = false;
this._switchContent.recycleBtn.down.visible = false;
}
if(this._recyclingOnly)
{
this._recycling = true;
}
if(numDens >= this._numTotalSlots && !this._recyclingOnly)
{
this._switchContent.denShopTag.visible = true;
}
else
{
this._switchContent.denShopTag.visible = false;
}
this._scrollButtons = new SBScrollbar();
this._scrollButtons.init(this._itemWindows,840,440,0,"scrollbar2",224.6);
}
public function switchDenCallback(success:Boolean) : void
{
if(success)
{
this.close();
}
else
{
DarkenManager.darken(this._switchContent.oopsPopup);
LocalizationManager.translateId(this._switchContent.oopsPopup.body_txt,11272);
this._switchContent.oopsPopup.visible = true;
}
DarkenManager.showLoadingSpiral(false);
}
private function recycleDenCallback(success:Boolean, removedIndex:int) : void
{
var slotMC:MovieClip = null;
var i:int = 0;
if(success)
{
if(this._recyclingOnly)
{
DarkenManager.showLoadingSpiral(false);
if(this._closeCallback != null)
{
this._closeCallback(true);
}
else
{
this.destroy();
}
}
else
{
slotMC = this._contentItems[removedIndex];
if(Boolean(this._views[removedIndex]))
{
this._views[removedIndex].destroy();
this._views[removedIndex] = null;
}
this._recycling = false;
for(i = 0; i < this._numTotalSlots; i++)
{
this._contentItems[i].recycle.visible = false;
}
slotMC.resetWindow(removedIndex);
if(DenSwitch.numDens <= this.MIN_NUM_DENS)
{
this._switchContent.recycleBtn.gray.visible = true;
this._switchContent.recycleBtn.mouse.visible = false;
this._switchContent.recycleBtn.down.visible = false;
}
if(DenSwitch.numDens >= this._numTotalSlots)
{
this._switchContent.denShopTag.visible = true;
}
else
{
this._switchContent.denShopTag.visible = false;
}
}
}
else
{
DarkenManager.darken(this._switchContent.oopsPopup);
LocalizationManager.translateId(this._switchContent.oopsPopup.body_txt,11273);
this._switchContent.oopsPopup.visible = true;
this._recycling = true;
}
DarkenManager.showLoadingSpiral(false);
}
private function purchasedDenRoomCallback() : void
{
DenPreviewManager.handleDenPurchase();
if(!this._openStoreOnly)
{
this.closeDenShop(true);
}
MovieClip(this._itemWindows).bg.getChildAt(this._idx).currItem = DenSwitch.denList[this._idx];
var slotMC:MovieClip = this._contentItems[this._idx];
slotMC.buyDen.visible = false;
slotMC.den.visible = true;
slotMC.den.txt.text = DenSwitch.denList[this._idx].name;
slotMC.den.sel.visible = false;
var denRoomHelper:MediaHelper = new MediaHelper();
denRoomHelper.init(DenSwitch.denList[this._idx].mediaId,this.mediaHelperCallback,DenSwitch.denList[this._idx].isMemberOnly);
this._views[this._idx] = denRoomHelper;
if(DenSwitch.numDens >= this._numTotalSlots)
{
this._switchContent.denShopTag.visible = true;
}
else
{
this._switchContent.denShopTag.visible = false;
}
if(DenSwitch.numDens > this.MIN_NUM_DENS)
{
this._switchContent.recycleBtn.gray.visible = false;
this._switchContent.recycleBtn.mouse.visible = true;
this._switchContent.recycleBtn.down.visible = false;
}
if(Boolean(this._shop))
{
this._shop.denItemIdx = this._firstOpenIdx = Math.max(0,DenSwitch.nextFreeSlotIdx);
}
}
public function closeDenShop(itemsPurchased:Boolean = false) : void
{
if(Boolean(this._shop))
{
this._shop.destroy();
this._shop = null;
}
if(this._openStoreOnly)
{
this.close();
}
}
private function mediaHelperCallback(mc:MovieClip) : void
{
for(var j:int = 0; j < this._views.length; j++)
{
if(this._views[j] == mc.mediaHelper)
{
if(Boolean(mc.passback) && !gMainFrame.userInfo.isMember)
{
this._contentItems[j].gray.amlMask.amlBox.addChild(mc);
}
else
{
this._contentItems[j].den.itemBlock.addChild(mc);
}
break;
}
}
}
private function confirmRecycleHandler(o:Object) : void
{
if(Boolean(o.status))
{
DenSwitch.removeDen(this._idx,this.recycleDenCallback);
DarkenManager.showLoadingSpiral(true);
}
}
private function onItemWindowDown(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
this._idx = evt.currentTarget.index;
}
else
{
this._idx = this._firstOpenIdx;
}
if(Boolean(this._contentItems[this._idx].buyDen.visible) || this._openStoreOnly)
{
if(!GenericListGuiManager.isWorldShopOpen())
{
this._shop = new Shop();
this._shop.init(this._glId,DefPacksDefHelper.DEF_DEN_ROOM,this._playerAvatar,this._guiLayer,true,this.closeDenShop,MainFrame.VIEW_WIDTH * 0.5,MainFrame.VIEW_HEIGHT * 0.5,this._idx,this.purchasedDenRoomCallback,this._openStoreOnly,this._storeItemIndex);
}
}
else if(this._contentItems[this._idx].gray.visible == true && !this._recycling)
{
if(!gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.DENS,"useLockedDen/" + DenSwitch.denList[this._idx].name);
}
}
else if(this._recycling)
{
if(this._idx == this._activeIdx)
{
DarkenManager.darken(this._switchContent.oopsPopup);
LocalizationManager.translateId(this._switchContent.oopsPopup.body_txt,11274);
this._switchContent.oopsPopup.visible = true;
}
else if(this._idx == 0)
{
DarkenManager.darken(this._switchContent.oopsPopup);
LocalizationManager.translateId(this._switchContent.oopsPopup.body_txt,11275);
this._switchContent.oopsPopup.visible = true;
}
else
{
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdAndInsertOnly(14715,Utility.convertNumberToString(DenSwitch.denList[this._idx].recycleValue)),true,this.confirmRecycleHandler);
}
}
else if(this._contentItems[this._idx].den.visible == true)
{
if(this._idx != this._activeIdx)
{
DarkenManager.showLoadingSpiral(true);
DenSwitch.switchDens(this._idx,this.switchDenCallback);
}
}
}
private function onItemWindowOver(evt:MouseEvent) : void
{
evt.stopPropagation();
this._idx = evt.currentTarget.index;
if(this._contentItems[this._idx].den.currentFrameLabel != "mouse")
{
this._contentItems[this._idx].den.gotoAndPlay("mouse");
}
AJAudio.playSubMenuBtnRollover();
}
private function onItemWindowOut(evt:MouseEvent) : void
{
evt.stopPropagation();
this._idx = evt.currentTarget.index;
if(this._contentItems[this._idx].den.currentFrameLabel != "out")
{
this._contentItems[this._idx].den.gotoAndPlay("out");
}
}
private function onOopsClose(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.unDarken(this._switchContent.oopsPopup);
this._switchContent.oopsPopup.visible = false;
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
this.close();
}
private function onRecycleDown(evt:MouseEvent) : void
{
var i:int = 0;
var j:int = 0;
evt.stopPropagation();
if(!this._recyclingOnly)
{
if(this._recycling)
{
for(i = 0; i < this._numTotalSlots; i++)
{
this._contentItems[i].recycle.visible = false;
}
this._recycling = false;
}
else if(!this._switchContent.recycleBtn.gray.visible)
{
this._recycling = true;
for(j = 0; j < this._numTotalSlots; j++)
{
if(Boolean(this._views[j]))
{
if(!this._contentItems[j].buyDen.visible)
{
this._contentItems[j].recycle.visible = true;
}
}
}
}
else
{
this._switchContent.recycleBtn.mouse.visible = false;
}
}
}
private function onRecycleOver(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.init(this._guiLayer,LocalizationManager.translateIdOnly(14626),843,480);
GuiManager.toolTip.startTimer(evt);
}
private function onRecycleOut(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private function onMoreDenDown(evt:MouseEvent) : void
{
evt.stopPropagation();
if(!this._recyclingOnly)
{
this._shop = new Shop();
this._shop.init(this._glId,DefPacksDefHelper.DEF_DEN_ROOM,this._playerAvatar,this._guiLayer,true,this.closeDenShop,MainFrame.VIEW_WIDTH * 0.5,MainFrame.VIEW_HEIGHT * 0.5,this._idx,this.purchasedDenRoomCallback);
}
}
private function addListeners() : void
{
if(Boolean(this._closeBtn))
{
this._closeBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
if(Boolean(this._switchContent))
{
this._switchContent.recycleBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onRecycleDown,false,0,true);
this._switchContent.recycleBtn.addEventListener(MouseEvent.MOUSE_OVER,this.onRecycleOver,false,0,true);
this._switchContent.recycleBtn.addEventListener(MouseEvent.MOUSE_OUT,this.onRecycleOut,false,0,true);
this._switchContent.oopsPopup.closeBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onOopsClose,false,0,true);
this._switchContent.denShopTag.denShopBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onMoreDenDown,false,0,true);
}
}
private function removeListeners() : void
{
for(var i:int = 0; i < this._numTotalSlots; i++)
{
if(Boolean(this._contentItems[i]))
{
this._contentItems[i].removeEventListener(MouseEvent.MOUSE_DOWN,this.onItemWindowDown);
this._contentItems[i].removeEventListener(MouseEvent.ROLL_OVER,this.onItemWindowOver);
this._contentItems[i].removeEventListener(MouseEvent.ROLL_OUT,this.onItemWindowOut);
}
}
if(Boolean(this._closeBtn))
{
this._closeBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
if(Boolean(this._switchContent))
{
this._switchContent.recycleBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onRecycleDown);
this._switchContent.recycleBtn.removeEventListener(MouseEvent.MOUSE_OVER,this.onRecycleOver);
this._switchContent.recycleBtn.removeEventListener(MouseEvent.MOUSE_OUT,this.onRecycleOut);
this._switchContent.oopsPopup.closeBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onOopsClose);
this._switchContent.denShopTag.denShopBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMoreDenDown);
}
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,215 @@
package gui
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import localization.LocalizationManager;
public class EmoticonManager
{
private const EMOTEWINDOW_DIM_ALPHA:Number = 0.5;
private const EMOTEWINDOW_BRIGHT_ALPHA:Number = 1;
private var emoteBtn:MovieClip;
private var emoteWindow:MovieClip;
private var emoteBtnsBg:Sprite;
private var actionBtn:MovieClip;
private var actionWindow:Sprite;
private var safeChatBtn:MovieClip;
private var safeChatTree:MovieClip;
private var setEmoteCallback:Function;
private var _useMemberOnlyEmotes:Boolean;
private var _emotes:MovieClip;
public function EmoticonManager(emoteCallbackRef:Function, emoticonBtn:MovieClip, emoticonWindow:MovieClip, actBtn:MovieClip, actWindow:Sprite, safeChatButton:MovieClip, safeChatTreeGui:MovieClip, useMemberOnlyEmotes:Boolean = true)
{
super();
this._useMemberOnlyEmotes = useMemberOnlyEmotes;
this.setEmoteCallback = emoteCallbackRef;
this.emoteBtn = emoticonBtn;
this.emoteBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.emoteBtnDownHandler,false,0,true);
this.emoteWindow = emoticonWindow;
this.addAllEmotes();
this.emoteWindow.visible = false;
this.actionBtn = actBtn;
this.actionWindow = actWindow;
this.safeChatBtn = safeChatButton;
this.safeChatTree = safeChatTreeGui;
this.emoteBtnsBg = GETDEFINITIONBYNAME("emo_mouse");
this.emoteWindow.addChild(this.emoteBtnsBg);
this.emoteBtnsBg.visible = false;
LocalizationManager.translateId(emoticonWindow.titleTxt,6308);
}
public function reload(initEmoteBtn:MovieClip, emoticonWindow:MovieClip, actBtn:MovieClip, actWindow:Sprite, safeChatButton:MovieClip, safeChatTreeGui:MovieClip) : void
{
if(Boolean(this.emoteBtn))
{
this.emoteBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.emoteBtnDownHandler);
}
this.emoteBtn = initEmoteBtn;
this.emoteBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.emoteBtnDownHandler,false,0,true);
this.emoteWindow = emoticonWindow;
this.emoteWindow.addChild(this._emotes);
this.emoteWindow.addChild(this.emoteBtnsBg);
this.emoteWindow.visible = false;
this.actionBtn = actBtn;
this.actionWindow = actWindow;
this.safeChatBtn = safeChatButton;
this.safeChatTree = safeChatTreeGui;
this.emoteBtnsBg.visible = false;
this.resetEmotePrivs();
LocalizationManager.translateId(emoticonWindow.titleTxt,6308);
this.emoteBtn.downToUpState();
}
public function resetEmotePrivs() : void
{
if(Boolean(gMainFrame.userInfo.isMember))
{
this.emoteWindow.locked.visible = false;
}
else
{
this.emoteWindow.locked.visible = true;
}
}
private function addAllEmotes() : void
{
this._emotes = EmoticonUtility.setupEmotes(this.emoteWindow,this._useMemberOnlyEmotes,this.smileyClickHandler,this.smileyRollOverHandler,this.smileyRollOutHandler);
this.emoteWindow.addChild(this._emotes);
if(this.emoteWindow.hasOwnProperty("locked"))
{
this.emoteWindow.setChildIndex(this.emoteWindow.locked,this.emoteWindow.numChildren - 1);
this.emoteWindow.locked.mouseChidren = false;
this.emoteWindow.locked.mouseEnabled = false;
if(Boolean(gMainFrame.userInfo.isMember))
{
this.emoteWindow.locked.visible = false;
}
else
{
this.emoteWindow.locked.visible = true;
}
}
}
public function destroy() : void
{
this.setEmoteCallback = null;
this.emoteBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.emoteBtnDownHandler);
this.emoteBtn = null;
this.emoteWindow.visible = false;
this.emoteWindow = null;
this.actionBtn = null;
this.actionWindow = null;
this.safeChatBtn = null;
this.safeChatTree = null;
}
public function openEmotes() : void
{
if(!this.emoteWindow.visible)
{
this.emoteWindow.visible = true;
this.emoteWindow.gotoAndPlay(1);
this.brightenEmotes();
}
}
public function dimEmotes() : void
{
if(this.emoteWindow.visible && this.emoteWindow.alpha != this.EMOTEWINDOW_DIM_ALPHA)
{
this.emoteWindow.alpha = this.EMOTEWINDOW_DIM_ALPHA;
}
}
public function brightenEmotes() : void
{
if(this.emoteWindow.alpha != this.EMOTEWINDOW_BRIGHT_ALPHA)
{
this.emoteWindow.alpha = this.EMOTEWINDOW_BRIGHT_ALPHA;
}
}
public function closeEmotes(fromBtnEvent:Boolean = false) : void
{
if(this.emoteWindow.visible)
{
this.emoteWindow.visible = false;
this.brightenEmotes();
if(!fromBtnEvent)
{
this.emoteBtn.downToUpState();
}
}
}
private function emoteBtnDownHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(!m.currentTarget.isGray)
{
if(this.emoteWindow.visible)
{
this.closeEmotes(true);
}
else
{
if(Boolean(this.safeChatTree) && this.safeChatTree.visible)
{
this.safeChatBtn.dispatchEvent(m);
}
if(Boolean(this.actionWindow) && this.actionWindow.visible)
{
this.actionBtn.dispatchEvent(m);
}
this.openEmotes();
}
}
}
private function smileyClickHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(!this.emoteBtn.isGray)
{
EmoticonUtility.handleSmileyClick(m.target,this.setEmoteCallback);
this.emoteBtn.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
AJAudio.playSubMenuBtnClick();
}
}
private function smileyRollOverHandler(m:MouseEvent) : void
{
if(m.target is MovieClip)
{
MovieClip(m.target).gotoAndPlay(1);
}
AJAudio.playSubMenuBtnRollover();
this.emoteWindow.setChildIndex(this.emoteBtnsBg,1);
this.emoteBtnsBg.x = m.currentTarget.x;
this.emoteBtnsBg.y = m.currentTarget.y;
this.emoteBtnsBg.visible = true;
}
private function smileyRollOutHandler(m:MouseEvent) : void
{
this.emoteBtnsBg.visible = false;
}
}
}
@@ -0,0 +1,376 @@
package gui
{
import avmplus.getQualifiedClassName;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class EmoticonUtility
{
private static var displaySprites:Array = ["emoMO_angry_sml","emoMO_combat_sml","emoMO_confused_sml","emoMO_laugh_sml","emoMO_phantom_sml","emoMO_sad_sml","emoMO_sleep_sml","emoMO_heartbreak_sml","emoMO_lovesick_sml","emoMO_ninja_sml","emoMO_sick_sml","emoMO_smiley_sml","emoMO_sunglasses_sml","emoMO_vampire_sml","emo_peace_sml","emo_angry_sml","emo_blush_sml","emo_confused_sml","emo_cool_sml","emo_cry_sml","emo_evil_sml","emo_grin_sml","emo_happy_sml","emo_laugh_sml","emo_love_sml","emo_rainy_sml","emo_sick_sml","emo_sleep_sml","emo_sneaky_sml","emo_surprise_sml","emo_think_sml","emo_tongue_sml","emo_wink_sml","emo_game_sml","emo_hearts_sml","emo_brokenHeart_sml","emo_burger_sml","emo_icecream_sml","emo_sword_sml","emo_star1_sml","emo_star2_sml","emo_star3_sml"];
private static var emoteSprites:Array = ["emoMO_angry","emoMO_combat","emoMO_confused","emoMO_laugh","emoMO_phantom","emoMO_sad","emoMO_sleep","emoMO_heartbreak","emoMO_lovesick","emoMO_ninja","emoMO_sick","emoMO_smiley","emoMO_sunglasses","emoMO_vampire","emo_peace","emo_angry","emo_blush","emo_confused","emo_cool","emo_cry","emo_evil","emo_grin","emo_happy","emo_laugh","emo_love","emo_rainy","emo_sick","emo_sleep","emo_sneaky","emo_surprise","emo_think","emo_tongue","emo_wink","emo_game","emo_hearts","emo_brokenHeart","emo_burger","emo_icecream","emo_sword","emo_star1","emo_star2","emo_star3"];
private static var _emoteStrings:Object = new Object();
private static var _emoteChatStrings:Object = new Object();
private static const MEMBER_EMOTES_WINDOW_OFFSET_Y:Number = -70;
private static const MEMBER_EMOTES_ROWS:int = 2;
private static const EMOTES_MARGIN_TOP:int = 14;
private static const EMOTES_MARGIN_LEFT:int = 11;
private static const EMOTES_STEP_V:int = 23;
private static const EMOTES_STEP_H:int = 33;
private static const EMOTES_ROW_MAX:uint = 7;
private static const EMOTES_WINDOW_OFFSET_X:Number = -109;
private static const EMOTES_WINDOW_OFFSET_Y:Number = -55;
private static const NUM_MEMBER_EMOTES:int = 14;
_emoteStrings["emoMO_angry"] = [":mad:"];
_emoteStrings["emoMO_combat"] = [":scuffle:"];
_emoteStrings["emoMO_confused"] = [":puzzle:"];
_emoteStrings["emoMO_laugh"] = [":joy:"];
_emoteStrings["emoMO_phantom"] = [":phantom:"];
_emoteStrings["emoMO_sad"] = [":sad:"];
_emoteStrings["emoMO_sleep"] = [":sleepy:"];
_emoteStrings["emoMO_heartbreak"] = [":breakingheart:"];
_emoteStrings["emoMO_lovesick"] = [":lovesick:"];
_emoteStrings["emoMO_ninja"] = [":ninja:"];
_emoteStrings["emoMO_sick"] = [":queasy:"];
_emoteStrings["emoMO_smiley"] = [":smiley:"];
_emoteStrings["emoMO_sunglasses"] = [":sunglasses:"];
_emoteStrings["emoMO_vampire"] = [":vampire:"];
_emoteStrings["emo_peace"] = [":peace:"];
_emoteStrings["emo_angry"] = [":angry:","X(","X-("];
_emoteStrings["emo_blush"] = [":blush:"];
_emoteStrings["emo_brokenHeart"] = [":brokenheart:"];
_emoteStrings["emo_burger"] = [":burger:"];
_emoteStrings["emo_confused"] = [":confused:",":/"];
_emoteStrings["emo_cool"] = [":cool:"];
_emoteStrings["emo_cry"] = [":cry:"];
_emoteStrings["emo_evil"] = [":evil:"];
_emoteStrings["emo_game"] = [":game:"];
_emoteStrings["emo_grin"] = [":D",":grin:"];
_emoteStrings["emo_happy"] = [":)",":happy:"];
_emoteStrings["emo_hearts"] = [":hearts:","<3<3<3"];
_emoteStrings["emo_icecream"] = [":icecream:"];
_emoteStrings["emo_laugh"] = [":laugh:",":))"];
_emoteStrings["emo_love"] = [":love:","(l)","(L)","(^_^)<3"];
_emoteStrings["emo_rainy"] = [":rainy:"];
_emoteStrings["emo_sick"] = [":sick:"];
_emoteStrings["emo_sleep"] = [":tired:","|)","|-)",":zzz:","-_-","-_-zzz","--_"];
_emoteStrings["emo_sneaky"] = [":sneaky:"];
_emoteStrings["emo_surprise"] = [":surprise:",":O",":-O"];
_emoteStrings["emo_sword"] = [":sword:"];
_emoteStrings["emo_think"] = [":think:",":?"];
_emoteStrings["emo_tongue"] = [":P",":p",":tongue:"];
_emoteStrings["emo_wink"] = [":wink:",";)",";-)"];
_emoteStrings["emo_star1"] = [":singlestar:"];
_emoteStrings["emo_star2"] = [":doublestar:"];
_emoteStrings["emo_star3"] = [":triplestar:"];
_emoteChatStrings["emo_happy"] = [":happy:"];
public function EmoticonUtility()
{
super();
}
public static function setupEmotes(emoteWindow:MovieClip, useMemberOnlyEmotes:Boolean, emoteDown:Function, emoteOver:Function, emoteOut:Function) : MovieClip
{
var b:Sprite = null;
var EMOTES_NON_MEMBER_OFFSET_INDEX:int = useMemberOnlyEmotes ? 0 : int(EMOTES_ROW_MAX * MEMBER_EMOTES_ROWS);
var allEmotes:MovieClip = new MovieClip();
for(var i:uint = 0; i < displaySprites.length; i++)
{
b = GETDEFINITIONBYNAME(displaySprites[i]);
if(i < EMOTES_ROW_MAX * MEMBER_EMOTES_ROWS)
{
if(!useMemberOnlyEmotes)
{
continue;
}
b.x = EMOTES_MARGIN_LEFT + i % EMOTES_ROW_MAX * EMOTES_STEP_H + EMOTES_WINDOW_OFFSET_X;
b.y = EMOTES_MARGIN_TOP + Math.floor(i / EMOTES_ROW_MAX) * EMOTES_STEP_V + MEMBER_EMOTES_WINDOW_OFFSET_Y;
}
else
{
b.x = EMOTES_MARGIN_LEFT + i % EMOTES_ROW_MAX * EMOTES_STEP_H + EMOTES_WINDOW_OFFSET_X;
b.y = EMOTES_MARGIN_TOP + Math.floor((i - EMOTES_NON_MEMBER_OFFSET_INDEX) / EMOTES_ROW_MAX) * EMOTES_STEP_V + EMOTES_WINDOW_OFFSET_Y;
}
allEmotes.addChild(b);
b.addChild(GETDEFINITIONBYNAME("emo_place_holder"));
b.buttonMode = true;
b.useHandCursor = true;
b.mouseChildren = false;
b.tabEnabled = true;
b.tabChildren = false;
b.addEventListener(MouseEvent.CLICK,emoteDown,false,0,true);
b.addEventListener(MouseEvent.ROLL_OVER,emoteOver,false,0,true);
b.addEventListener(MouseEvent.ROLL_OUT,emoteOver,false,0,true);
}
return allEmotes;
}
public static function getEmoteString(emote:Sprite) : String
{
if(Boolean(_emoteStrings[getQualifiedClassName(emote)]))
{
return _emoteStrings[getQualifiedClassName(emote)][0];
}
return null;
}
public static function matchEmoteString(emoteStr:String) : Object
{
var obj:Object = null;
var ec:String = null;
for each(ec in emoteSprites)
{
if(_emoteStrings[ec].indexOf(emoteStr) != -1)
{
if(ec.slice(3,5) == "MO" && !gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.EMOTES,"useLockedEmote");
return {
"sprite":null,
"status":false
};
}
return {
"sprite":GETDEFINITIONBYNAME(ec),
"status":true
};
}
}
return {
"sprite":null,
"status":true
};
}
public static function doesStringMatchAnEmote(emoteStr:String) : Boolean
{
var ec:String = null;
for each(ec in emoteSprites)
{
if(_emoteStrings[ec].indexOf(emoteStr) != -1)
{
return true;
}
}
return false;
}
public static function emoteForId(emoteId:int) : Sprite
{
if(emoteId >= 0 && emoteId < emoteSprites.length)
{
return GETDEFINITIONBYNAME(emoteSprites[emoteId]);
}
return null;
}
public static function idForEmote(emote:Sprite) : int
{
return emoteSprites.indexOf(getQualifiedClassName(emote));
}
public static function stringForId(emoteId:int) : String
{
if(emoteId >= 0 && emoteId < emoteSprites.length)
{
return _emoteStrings[emoteSprites[emoteId]][0];
}
return null;
}
public static function handleSmileyClick(target:Object, setEmoteCallback:Function) : void
{
var index:int = displaySprites.indexOf(getQualifiedClassName(target));
if(index != -1 && index < NUM_MEMBER_EMOTES && !gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.EMOTES,"useLockedEmote");
}
else
{
setEmoteCallback(GETDEFINITIONBYNAME(emoteSprites[index]));
}
}
public static function formatStringForSmiley(str:String, stringIndex:int, smileyArray:Array, allowMultiples:Boolean) : Object
{
var emoteArray:Array = null;
var s:String = null;
var hasFoundEmote:Boolean = false;
var hasRemoved:Boolean = false;
var currString:String = null;
var i:int = 0;
var strArray:Array = null;
var smiley:String = null;
var emoteString:String = null;
var smileyMC:MovieClip = null;
var smileySpacer:String = null;
var smileyTempString:String = null;
var emoteTempString:String = null;
var emoteBuildString:String = null;
var emoteIndex:int = 0;
var counter:Array = null;
var addAdditionalSpace:Boolean = false;
var splitString:Array = [];
for each(emoteArray in _emoteChatStrings)
{
for each(s in emoteArray)
{
splitString = str.split(s);
if(allowMultiples)
{
str = splitString.join("|*|" + s);
}
else if(splitString.length > 1)
{
str = "";
for(i = 0; i < splitString.length; i++)
{
currString = splitString[i];
if(i == 0 && currString != " ")
{
str += currString;
}
else if(!hasFoundEmote)
{
if(currString != "" && currString != " ")
{
str += "|*|" + s + currString;
}
else
{
str += "|*|" + s;
}
hasFoundEmote = true;
}
else if(currString != "" && currString != " ")
{
str += currString;
}
}
}
}
}
strArray = str.split("|*|");
if(strArray[0] == "")
{
strArray.shift();
}
var smileystart:String = "false";
for(s in strArray)
{
if(s == "0" && strArray[s] == "")
{
smileystart = "true";
}
for(emoteString in _emoteChatStrings)
{
for each(smiley in _emoteChatStrings[emoteString])
{
emoteTempString = strArray[s];
if(emoteTempString == "" || emoteTempString.charAt() == " ")
{
break;
}
smileyTempString = smiley;
emoteIndex = emoteTempString.indexOf(smileyTempString);
if(emoteIndex != -1)
{
emoteBuildString = "";
for(i = 0; i < smiley.length; i++)
{
emoteBuildString += emoteTempString.charAt(emoteIndex + i);
}
}
if(emoteBuildString == smileyTempString)
{
if(emoteString.slice(3,5) == "MO" && !gMainFrame.userInfo.isMember)
{
break;
}
smileyMC = GETDEFINITIONBYNAME(emoteString + "_sml");
smileyMC.y -= 3;
if(smileystart == "false" && strArray[s].charAt(strArray[s].length - 1) != "")
{
addAdditionalSpace = true;
}
if(smileyMC.width <= 20)
{
smileySpacer = " .";
}
else if(smileyMC.width <= 22)
{
smileySpacer = " . ";
}
else if(smileyMC.width <= 25)
{
smileySpacer = " . ";
}
else
{
smileySpacer = " . ";
}
strArray[s] = smileySpacer + (addAdditionalSpace == true ? " " : "") + strArray[s].substr(smiley.length,strArray[s].length);
smileyArray.push({
"strindex":stringIndex,
"emoticon":smileyMC,
"added":false,
"smileystart":smileystart
});
break;
}
}
}
counter = strArray[s].split("");
stringIndex += counter.length;
}
return {
"str":strArray.join(""),
"smileyArray":smileyArray,
"stringIndex":stringIndex
};
}
public static function getSmallSmileyMCForEmoteString(emoteStr:String) : MovieClip
{
var s:String = null;
var smiley:String = null;
loop0:
for(s in _emoteStrings)
{
var _loc6_:int = 0;
var _loc7_:* = _emoteStrings[s];
do
{
for each(smiley in _loc7_)
{
}
continue loop0;
}
while(smiley != emoteStr);
if(s.slice(3,5) == "MO" && !gMainFrame.userInfo.isMember)
{
return null;
}
return GETDEFINITIONBYNAME(s + "_sml");
}
return null;
}
}
}
@@ -0,0 +1,550 @@
package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.client.KeepAlive;
import com.sbi.popup.SBStandardTitlePopup;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLRequestHeader;
import flash.net.URLRequestMethod;
import flash.utils.ByteArray;
import flash.utils.Endian;
import loader.FeedbackDefHelper;
import loader.MediaHelper;
import localization.LocalizationManager;
public class FeedbackManager
{
private static var _feedbackDefCache:Array;
private static var _feedbackLocs:Array;
private static var _feedbackDefHelpers:Array;
private static var _tabMediaHelper:MediaHelper;
private static var _tabTemplate:MovieClip;
private static var _popupMediaHelper:MediaHelper;
private static var _popup:MovieClip;
private static var _imageUploader:UserImageUpload;
private static var _guiLayer:DisplayLayer;
private static var _worldLayer:DisplayLayer;
private static var _secondaryType:int;
public static const TYPE_ASK_BRADY:int = 1;
public static const TYPE_ITEMS:int = 2;
public static const TYPE_HOWL:int = 3;
public static const TYPE_WORK:int = 4;
public static const TYPE_SERVERS:int = 5;
public static const TYPE_FLAGS:int = 6;
public static const TYPE_PETS:int = 7;
public static const TYPE_PARTIES:int = 8;
public static const TYPE_EPIC_ITEMS:int = 9;
public static const TYPE_ARCADE:int = 10;
public static const TYPE_ASK_TIERNEY:int = 11;
public static const TYPE_DONATION:int = 12;
public static const TYPE_CARNIVAL:int = 13;
public static const TYPE_ARTSTUDIO:int = 14;
public static const TYPE_JAMSESSION:int = 15;
public static const TYPE_DIAMOND:int = 16;
public static const TYPE_ADVENTURE:int = 17;
public static const TYPE_DICTIONARY:int = 18;
private static const TAB_MEDIA_ID:int = 153;
private static const POPUP_MEDIA_ID:int = 457;
private static const TAB_FRAME_LABEL:String = "answer";
public function FeedbackManager()
{
super();
}
public static function init(initGuiLayer:DisplayLayer, initWorldLayer:DisplayLayer) : void
{
_feedbackDefCache = [];
_guiLayer = initGuiLayer;
_worldLayer = initWorldLayer;
_popupMediaHelper = new MediaHelper();
_tabMediaHelper = new MediaHelper();
_tabMediaHelper.init(TAB_MEDIA_ID,mediaHelperCallback,true);
_imageUploader = new UserImageUpload();
_imageUploader.init();
}
public static function setUpOrbs(feedbackDefIds:Array, feedbackLocs:Array) : void
{
var def:Object = null;
var fdh:FeedbackDefHelper = null;
_feedbackLocs = feedbackLocs;
_feedbackDefHelpers = [];
for(var i:int = 0; i < feedbackDefIds.length; i++)
{
if(feedbackDefIds[i] == 0)
{
DarkenManager.showLoadingSpiral(false);
throw new Error("Id == 0");
}
def = _feedbackDefCache[feedbackDefIds[i]];
if(!def)
{
fdh = new FeedbackDefHelper();
fdh.init(feedbackDefIds[i],onDefReceived);
_feedbackDefHelpers[feedbackDefIds[i]] = fdh;
}
else
{
setUpOrb(def);
}
}
}
public static function openFeedbackPopup(defId:int) : void
{
var fdh:FeedbackDefHelper = null;
if(defId == 0)
{
DarkenManager.showLoadingSpiral(false);
throw new Error("Id == 0");
}
DarkenManager.showLoadingSpiral(true);
if(!_feedbackDefHelpers)
{
_feedbackDefHelpers = [];
}
var def:Object = _feedbackDefCache[defId];
if(!def)
{
fdh = new FeedbackDefHelper();
fdh.init(defId,onDefReceived);
_feedbackDefHelpers[defId] = fdh;
}
else
{
displayFeedbackPopup(def);
}
}
private static function onDefReceived(fdh:FeedbackDefHelper) : void
{
var o:Object = fdh.def;
var defTxt:String = LocalizationManager.translateIdOnly(int(o.defaultStrRef));
var patt:RegExp = /\r\n/g;
defTxt = defTxt.replace(patt,"\n");
patt = /\r/g;
defTxt = defTxt.replace(patt,"\n");
var def:Object = {
"id":int(o.id),
"titleTxt":LocalizationManager.translateIdOnly(int(o.titleStrRef)),
"defaultTxt":defTxt,
"thanksTxt":LocalizationManager.translateIdOnly(int(o.thankStrRef)),
"allowImg":Boolean(int(o.bAcceptImage)),
"userVarId":int(o.userVarRef),
"bitIdx":int(o.bitIndex)
};
_feedbackDefCache[def.id] = def;
_feedbackDefHelpers[def.id] = null;
def.seen = gMainFrame.userInfo.userVarCache.isBitSet(def.userVarId,def.bitIdx);
if(def.id == TYPE_ASK_BRADY || def.id == TYPE_ASK_TIERNEY || def.id == TYPE_HOWL || def.id == TYPE_WORK || def.id == TYPE_SERVERS || def.id == TYPE_DICTIONARY)
{
displayFeedbackPopup(def);
}
else
{
setUpOrb(def);
}
}
private static function setUpOrb(def:Object) : void
{
var tab:MovieClip = null;
var defId:int = 0;
if(Boolean(_tabTemplate))
{
tab = new _tabTemplate.constructor();
tab.def = def;
defId = int(tab.id = int(def.id));
tab.x = _feedbackLocs[defId].x;
tab.y = _feedbackLocs[defId].y;
if(Boolean(def.seen))
{
tab.gotoAndPlay(TAB_FRAME_LABEL + "Dim");
}
else
{
tab.gotoAndPlay(TAB_FRAME_LABEL);
}
tab.addEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown,false,0,true);
_worldLayer.addChild(tab);
}
}
private static function mediaHelperCallback(img:MovieClip) : void
{
var pid:int = 0;
if(Boolean(img))
{
if(img.mediaHelper.id == TAB_MEDIA_ID)
{
pid = int(img.mediaHelper.id);
_tabTemplate = MovieClip(img.getChildAt(0));
_tabMediaHelper.destroy();
_tabMediaHelper = null;
}
else if(img.mediaHelper.id == POPUP_MEDIA_ID)
{
_popup = img;
_popupMediaHelper.destroy();
_popupMediaHelper = null;
_popup.x = MainFrame.VIEW_WIDTH * 0.5;
_popup.y = MainFrame.VIEW_HEIGHT * 0.5;
_popup.parent.x = _popup.x;
_popup.parent.y = _popup.y;
displayFeedbackPopup(img.passback);
}
}
}
private static function onTabMouseDown(m:MouseEvent) : void
{
m.stopPropagation();
var tab:MovieClip = MovieClip(m.currentTarget);
var def:Object = tab.def;
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/feedback/" + def.id);
DarkenManager.showLoadingSpiral(true);
if(!def.seen)
{
tab.gotoAndPlay(TAB_FRAME_LABEL + "Dim");
}
displayFeedbackPopup(def);
}
public static function displayFeedbackPopup(def:Object) : void
{
var splitTxt:Array = null;
var type:int = int(def.id);
if(!_popup)
{
_popupMediaHelper.init(POPUP_MEDIA_ID,mediaHelperCallback,def);
return;
}
if(!def.seen)
{
def.seen = true;
AchievementXtCommManager.requestSetUserVar(def.userVarId,def.bitIdx);
}
_popup.gotoAndStop(frameLabelForType(type));
_popup.submitBtn.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown,false,0,true);
_popup.bx.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown,false,0,true);
_popup.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown,false,0,true);
_popup.txt.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown,false,0,true);
_popup.def = def;
if(Boolean(_popup["descTxt"]))
{
splitTxt = def.defaultTxt.split("|");
LocalizationManager.updateToFit(_popup.descTxt,splitTxt[0]);
LocalizationManager.updateToFit(_popup.txt,splitTxt[1]);
}
else
{
LocalizationManager.updateToFit(_popup.txt,def.defaultTxt);
}
_popup.defaultTxt = _popup.txt.text;
_popup.titleTxt.text = def.titleTxt;
if(Boolean(def.allowImg))
{
_popup.addFileBtn.visible = true;
_imageUploader.setUploadBtn(_popup.addFileBtn);
_popup.removeFileBtn.addEventListener(MouseEvent.MOUSE_DOWN,onRemoveFileBtn,false,0,true);
}
else
{
if(Boolean(_popup.addFileBtn))
{
_popup.addFileBtn.visible = false;
}
if(Boolean(_popup.removeFileBtn))
{
_popup.removeFileBtn.visible = false;
}
}
_popup.txt.maxChars = maxCharsForType(type);
if(type == TYPE_DICTIONARY)
{
_popup.txt.restrict = "^ ";
}
else
{
_popup.txt.restrict = null;
}
_popup.visible = true;
_popup.clickedTextBox = false;
KeepAlive.startKATimer(_popup);
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(DisplayObjectContainer(_popup));
_guiLayer.addChild(DisplayObjectContainer(_popup));
}
private static function frameLabelForType(type:int) : int
{
switch(type)
{
case TYPE_ASK_BRADY:
return 1;
case TYPE_HOWL:
return 2;
case TYPE_WORK:
case TYPE_ITEMS:
case TYPE_SERVERS:
case TYPE_FLAGS:
case TYPE_PETS:
case TYPE_PARTIES:
case TYPE_EPIC_ITEMS:
case TYPE_ARCADE:
case TYPE_CARNIVAL:
case TYPE_JAMSESSION:
case TYPE_DIAMOND:
case TYPE_ADVENTURE:
return 3;
case TYPE_ASK_TIERNEY:
return 4;
case TYPE_DICTIONARY:
return 6;
default:
return 1;
}
}
private static function maxCharsForType(type:int) : int
{
switch(type)
{
case TYPE_ASK_BRADY:
case TYPE_ASK_TIERNEY:
return 150;
case TYPE_HOWL:
return 50;
case TYPE_WORK:
return 3000;
case TYPE_ITEMS:
case TYPE_SERVERS:
case TYPE_FLAGS:
case TYPE_PARTIES:
case TYPE_EPIC_ITEMS:
case TYPE_ARCADE:
case TYPE_CARNIVAL:
case TYPE_JAMSESSION:
case TYPE_DIAMOND:
case TYPE_DONATION:
case TYPE_PETS:
case TYPE_ARTSTUDIO:
return 100;
case TYPE_ADVENTURE:
return 200;
case TYPE_DICTIONARY:
return 25;
default:
return 1;
}
}
private static function onRemoveFileBtn(m:MouseEvent) : void
{
m.stopPropagation();
_imageUploader.resetUploader();
_popup.addFileBtn.visible = true;
}
private static function onMouseDown(m:MouseEvent) : void
{
var popupTxt:String = null;
var patt:RegExp = null;
m.stopPropagation();
if(m.currentTarget == _popup)
{
return;
}
if(m.currentTarget == _popup.txt)
{
if(!_popup.clickedTextBox)
{
_popup.txt.text = "";
_popup.clickedTextBox = true;
gMainFrame.stage.focus = _popup.txt;
_popup.txt.setSelection(0,0);
}
return;
}
if(m.currentTarget.name == "submitBtn")
{
popupTxt = _popup.txt.text;
patt = /\r\n/g;
popupTxt = popupTxt.replace(patt,"\n");
patt = /\r/g;
popupTxt = popupTxt.replace(patt,"\n");
if(popupTxt.length > 0 && popupTxt != _popup.defaultTxt || _imageUploader.fileName != "")
{
if(popupTxt == _popup.def.defaultTxt)
{
popupTxt = _popup.txt.text = "";
}
setupRequest(_imageUploader,popupTxt,_popup.def.id,_secondaryType,onSendComplete,onSendError);
}
}
_popup.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
_popup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
_popup.submitBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
_popup.txt.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
if(Boolean(_popup.def.allowImg))
{
_imageUploader.resetUploader();
_popup.addFileBtn.visible = true;
_popup.removeFileBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onRemoveFileBtn);
}
DarkenManager.unDarken(_popup);
_popup.visible = false;
SBTracker.pop();
if(m.currentTarget.name != "bx")
{
new SBStandardTitlePopup(_guiLayer,_popup.def.thanksTxt);
}
KeepAlive.stopKATimer(_popup);
}
public static function setupRequest(imageUploaded:UserImageUpload, message:String, typeDefId:int, secondaryType:int, initOnSendComplete:Function, initOnSendError:Function) : void
{
var boundary:String = "---------------------------" + Math.floor(Math.random() * 100000000000000);
var formData:Object = {
"userName":gMainFrame.userInfo.myUserName,
"type":typeDefId,
"message":message,
"secondaryType":secondaryType,
"languageId":LocalizationManager.currentLanguage
};
var request:URLRequest = new URLRequest(gMainFrame.clientInfo.mdUrl + "fb");
request.contentType = "multipart/form-data; boundary=" + boundary;
request.requestHeaders.push(new URLRequestHeader("Cache-Control","no-cache"));
request.method = URLRequestMethod.POST;
request.data = createPostData(imageUploaded.fileName,imageUploaded.uploadedImage,boundary,formData);
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE,initOnSendComplete);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,initOnSendError);
urlLoader.load(request);
}
public static function createPostData(fileName:String, image:ByteArray, boundary:String, formData:Object = null) : ByteArray
{
var stringToAppend:String = null;
var name:String = null;
var i:int = 0;
var postData:ByteArray = new ByteArray();
postData.endian = Endian.BIG_ENDIAN;
if(formData == null)
{
formData = new Object();
}
for(name in formData)
{
writeBoundary(postData,boundary);
writeLineBreak(postData);
stringToAppend = "Content-Disposition: form-data; name=\"" + name + "\"";
for(i = 0; i < stringToAppend.length; i++)
{
postData.writeByte(stringToAppend.charCodeAt(i));
}
writeLineBreak(postData);
writeLineBreak(postData);
postData.writeUTFBytes(formData[name]);
writeLineBreak(postData);
}
if(Boolean(image))
{
writeBoundary(postData,boundary);
writeLineBreak(postData);
stringToAppend = "Content-Disposition: form-data; name=\"image\"; filename=\"" + fileName + "\"";
for(i = 0; i < stringToAppend.length; i++)
{
postData.writeByte(stringToAppend.charCodeAt(i));
}
writeLineBreak(postData);
stringToAppend = "Content-Type: image/jpeg";
for(i = 0; i < stringToAppend.length; i++)
{
postData.writeByte(stringToAppend.charCodeAt(i));
}
writeLineBreak(postData);
writeLineBreak(postData);
postData.writeBytes(image,0,image.length);
writeLineBreak(postData);
}
writeBoundary(postData,boundary);
writeDoubleDash(postData);
writeLineBreak(postData);
return postData;
}
private static function writeLineBreak(postData:ByteArray) : void
{
postData.writeShort(3338);
}
private static function writeDoubleDash(postData:ByteArray) : void
{
postData.writeShort(11565);
}
private static function writeBoundary(postData:ByteArray, boundary:String) : void
{
writeDoubleDash(postData);
for(var i:int = 0; i < boundary.length; i++)
{
postData.writeByte(boundary.charCodeAt(i));
}
}
private static function onSendComplete(evt:Event) : void
{
trace("w00t!");
}
private static function onSendError(evt:Event) : void
{
trace("Argh! Error sending....");
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,43 @@
package gui
{
import flash.text.Font;
import flash.text.TextFormat;
public class Fonts
{
public static var defaultFont:Font;
public static var defaultFontBold:Font;
public static var titleFont:Font;
public static var defaultFontFormat:TextFormat;
public static var defaultFontBoldFormat:TextFormat;
public static var defaultFontRedFormat:TextFormat;
public static var defaultFontBlackFormat:TextFormat;
public static var titleFontFormat:TextFormat;
public function Fonts()
{
super();
}
public static function init() : void
{
defaultFontFormat = new TextFormat();
defaultFontBoldFormat = new TextFormat();
defaultFontBoldFormat.bold = true;
defaultFontRedFormat = new TextFormat();
defaultFontRedFormat.color = 13369344;
defaultFontBlackFormat = new TextFormat();
defaultFontBlackFormat.color = 0;
titleFontFormat = new TextFormat();
}
}
}
@@ -0,0 +1,217 @@
package gui
{
import com.sbi.popup.SBPopup;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import localization.LocalizationManager;
public class GameCardPopup extends SBPopup
{
public static const LEADERBOARD_TYPE_ALLTIME:int = 1;
public static const LEADERBOARD_TYPE_THISWEEK:int = 2;
public static const LEADERBOARD_TYPE_BUDDY:int = 3;
private var _onStartClicked:Function;
private var _onInstructionsClicked:Function;
private var _onLeaderBoardClicked:Function;
private var _onLeaderBoardSelected:Function;
private var _thePopup:MovieClip = GETDEFINITIONBYNAME("JoinGameContent");
private var _theSkin:MovieClip;
private var _originalBX:int;
public function GameCardPopup(parent:DisplayObjectContainer, gameCard:Sprite, onStartClicked:Function, onInstrClicked:Function, onXClicked:Function, onLeaderBoardClicked:Function, onLeaderBoardSelected:Function, showProModeBtn:Boolean, proModeValue:int, isMultiplayer:Boolean)
{
LocalizationManager.translateId(this._thePopup.msg.msgTxt,11279);
if(this._thePopup.hasOwnProperty("gameTitle") && gameCard != null)
{
this._thePopup.gameTitle.addChild(gameCard);
}
this._onStartClicked = onStartClicked;
this._onInstructionsClicked = onInstrClicked;
this._onLeaderBoardClicked = onLeaderBoardClicked;
this._onLeaderBoardSelected = onLeaderBoardSelected;
this._thePopup.startBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onAnyStartClicked,false,0,true);
this._thePopup.proStartBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onAnyStartClicked,false,0,true);
this._thePopup.instrBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onInstructionsClicked,false,0,true);
if(isMultiplayer && !Utility.canMultiplayer())
{
this._thePopup.startBtn.activateGrayState(true);
this._thePopup.proStartBtn.activateGrayState(true);
}
if(this._onLeaderBoardClicked != null)
{
this._thePopup.leaderboardsButton.gotoAndStop("active");
this._thePopup.leaderboards_popup.thisWeekDown.addEventListener(MouseEvent.CLICK,this.thisWeekClicked);
this._thePopup.leaderboards_popup.buddiesDown.addEventListener(MouseEvent.CLICK,this.buddiesClicked);
this._thePopup.leaderboards_popup.allTimeDown.addEventListener(MouseEvent.CLICK,this.allTimeClicked);
this._thePopup.leaderboards_popup.bx.addEventListener(MouseEvent.CLICK,this.leaderBoardBXClicked);
this._thePopup.leaderboardsButton.btn.addEventListener(MouseEvent.CLICK,this.leaderBoardClicked,false,0,true);
}
if(showProModeBtn)
{
this._thePopup.gotoAndPlay("pro");
if(proModeValue <= 0)
{
this._thePopup.proStartBtn.activateGrayState(true);
}
}
this._theSkin = GETDEFINITIONBYNAME("JoinGameSkin");
this._theSkin.bx.addEventListener(MouseEvent.CLICK,onXClicked,false,0,true);
this._originalBX = this._theSkin.bx.y;
super(parent,this._theSkin,this._thePopup,true,true,false,false,true);
}
public function getVisibleLeaderBoard() : int
{
if(Boolean(this._thePopup.leaderboards_popup.thisWeekUp.visible))
{
return LEADERBOARD_TYPE_THISWEEK;
}
if(Boolean(this._thePopup.leaderboards_popup.allTimeUp.visible))
{
return LEADERBOARD_TYPE_ALLTIME;
}
return LEADERBOARD_TYPE_BUDDY;
}
private function thisWeekClicked(e:MouseEvent) : void
{
this._thePopup.leaderboards_popup.thisWeekUp.visible = true;
this._thePopup.leaderboards_popup.allTimeUp.visible = false;
this._thePopup.leaderboards_popup.buddiesUp.visible = false;
if(this._onLeaderBoardSelected != null)
{
this._onLeaderBoardSelected();
}
}
private function buddiesClicked(e:MouseEvent) : void
{
this._thePopup.leaderboards_popup.thisWeekUp.visible = false;
this._thePopup.leaderboards_popup.allTimeUp.visible = false;
this._thePopup.leaderboards_popup.buddiesUp.visible = true;
if(this._onLeaderBoardSelected != null)
{
this._onLeaderBoardSelected();
}
}
private function allTimeClicked(e:MouseEvent) : void
{
this._thePopup.leaderboards_popup.thisWeekUp.visible = false;
this._thePopup.leaderboards_popup.allTimeUp.visible = true;
this._thePopup.leaderboards_popup.buddiesUp.visible = false;
if(this._onLeaderBoardSelected != null)
{
this._onLeaderBoardSelected();
}
}
private function leaderBoardClicked(e:MouseEvent) : void
{
this._thePopup.leaderboardsButton.gotoAndPlay("off");
this._thePopup.gotoAndPlay("normal_l");
this._thePopup.gotoAndPlay("pro_l");
this._theSkin.bx.y = -1000;
if(this._onLeaderBoardClicked != null)
{
this._onLeaderBoardClicked();
}
}
private function leaderBoardBXClicked(e:MouseEvent) : void
{
this._thePopup.leaderboardsButton.gotoAndPlay("on");
this._thePopup.gotoAndPlay("normal_l_close");
this._thePopup.gotoAndPlay("pro_l_close");
this._theSkin.bx.y = this._originalBX;
}
public function populateLeaderBoard(leaderBoardData:Array) : void
{
var i:int = 0;
if(leaderBoardData != null && leaderBoardData.length > 0)
{
if(leaderBoardData[0]._score != -1)
{
this._thePopup.leaderboards_popup["p11"].text = leaderBoardData[0]._name;
this._thePopup.leaderboards_popup["s11"].text = leaderBoardData[0]._score;
}
else
{
this._thePopup.leaderboards_popup["p11"].text = "";
this._thePopup.leaderboards_popup["s11"].text = "";
}
for(i = 1; i < 11; i++)
{
if(i < leaderBoardData.length)
{
this._thePopup.leaderboards_popup["p" + i].text = leaderBoardData[i]._name;
this._thePopup.leaderboards_popup["s" + i].text = leaderBoardData[i]._score;
if(leaderBoardData[i]._name == leaderBoardData[0]._name)
{
this._thePopup.leaderboards_popup["p" + i].textColor = 26265;
this._thePopup.leaderboards_popup["s" + i].textColor = 26265;
}
else
{
this._thePopup.leaderboards_popup["p" + i].textColor = 4137240;
this._thePopup.leaderboards_popup["s" + i].textColor = 4137240;
}
}
else
{
this._thePopup.leaderboards_popup["p" + i].text = "";
this._thePopup.leaderboards_popup["s" + i].text = "";
}
}
}
else
{
for(i = 1; i <= 11; i++)
{
this._thePopup.leaderboards_popup["p" + i].text = "";
this._thePopup.leaderboards_popup["s" + i].text = "";
}
}
}
private function onAnyStartClicked(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(evt.currentTarget.isGray))
{
return;
}
if(evt.currentTarget.name == "startBtn")
{
this._onStartClicked(0);
}
else if(evt.currentTarget.name == "proStartBtn")
{
this._onStartClicked(1);
}
}
private function onInstructionsClicked(evt:MouseEvent) : void
{
evt.stopPropagation();
if(this._onInstructionsClicked != null)
{
this._onInstructionsClicked();
}
}
}
}
@@ -0,0 +1,321 @@
package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.analytics.SBTracker;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.system.ApplicationDomain;
import flash.utils.Timer;
import loader.MediaHelper;
public class GemBonusSpinWheel
{
private const WHEEL_SPIN_MEDIA_ID:int = 1025;
private var _loadingMediaHelper:MediaHelper;
private var _mediaHelpers:Array;
private var _guiLayer:DisplayLayer;
private var _spinWheelMC:MovieClip;
private var _gems:int;
private var _multiplier:int;
private var _spinEndPoint:int;
private var _wheelNumbers:Array;
private var _displayTimer:Timer;
private var _callback:Function;
private var _isDiamond:Boolean;
private var _isGift:Boolean;
public function GemBonusSpinWheel()
{
super();
}
public function init(dailyGemVarValue:int, callback:Function) : void
{
this._guiLayer = GuiManager.guiLayer;
this._callback = callback;
this._mediaHelpers = [];
this._wheelNumbers = [500,100,25,50,1,75,25,100,0,100,25,50,1,75,1,100];
this._displayTimer = new Timer(375);
this._displayTimer.addEventListener(TimerEvent.TIMER,this.onTimerComplete,false,0,true);
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this.WHEEL_SPIN_MEDIA_ID,this.onMediaItemLoaded,dailyGemVarValue);
this._mediaHelpers.push(this._loadingMediaHelper);
}
public function destroy() : void
{
this.removeGeneralEventListeners();
DarkenManager.unDarken(this._spinWheelMC);
if(Boolean(this._spinWheelMC) && Boolean(this._guiLayer) && this._spinWheelMC.parent == this._guiLayer)
{
this._guiLayer.removeChild(this._spinWheelMC);
}
this._guiLayer = null;
this._mediaHelpers = null;
}
public function setupValuesAndSpin(value:int) : void
{
DarkenManager.showLoadingSpiral(false);
this._gems = this.convertToGemsValue(value >> 24);
this._multiplier = value >> 16 & 0xFF;
this._spinEndPoint = this.calculateSpinEndPoint(this._gems);
if(!this._isGift)
{
if(this._isDiamond)
{
gMainFrame.clientInfo.diamondCount += this._gems * this._multiplier;
}
else
{
gMainFrame.clientInfo.gemCount += this._gems * this._multiplier;
}
}
for(var i:int = 1; i < 4; i++)
{
if(this._multiplier < i)
{
this._spinWheelMC["x" + i + "_on"].visible = false;
}
else
{
this._spinWheelMC["x" + i + "_on"].visible = true;
}
}
if(this._isDiamond)
{
this._spinWheelMC.earnGifts(0);
this._spinWheelMC.earnDiamonds(this._gems * this._multiplier);
}
else if(this._isGift)
{
this._spinWheelMC.earnDiamonds(0);
this._spinWheelMC.earnGifts(1 * this._multiplier);
}
else
{
this._spinWheelMC.earnDiamonds(0);
this._spinWheelMC.earnGifts(0);
}
this._spinWheelMC.spin(this._spinEndPoint,this.onSpinComplete);
AJAudio.playDailySpinSpin();
}
private function onMediaItemLoaded(img:MovieClip) : void
{
var multiplier:int = 0;
var i:int = 0;
var currLoaderAppDomain:ApplicationDomain = null;
if(Boolean(img))
{
SBTracker.push();
SBTracker.trackPageview("game/play/popup/spinBonus");
this._spinWheelMC = MovieClip(img.getChildAt(0));
DarkenManager.showLoadingSpiral(false);
if(!AJAudio.hasLoadedDailySpinSfx)
{
currLoaderAppDomain = img.loaderInfo.applicationDomain;
AJAudio.loadSfx("DailySpinSpin",currLoaderAppDomain.getDefinition("DailySpinSpin") as Class,0.5);
AJAudio.loadSfx("DailySpinBub1",currLoaderAppDomain.getDefinition("DailySpinBub1") as Class,0.5);
AJAudio.loadSfx("DailySpinBub2",currLoaderAppDomain.getDefinition("DailySpinBub2") as Class,0.5);
AJAudio.loadSfx("DailySpinBub3",currLoaderAppDomain.getDefinition("DailySpinBub3") as Class,0.5);
AJAudio.hasLoadedDailySpinSfx = true;
}
this._spinWheelMC.spinTxtAnim.spinTxt.text = "";
this._spinWheelMC.bonusTxtAnim.bonusTxt.text = "";
this._spinWheelMC.totalTxtAnim.totalTxt.text = "";
if(gMainFrame.clientInfo.jamaaDate - (img.passback & 0xFFFF) == 1)
{
multiplier = Math.min((img.passback >> 16 & 0xFF) + 1,3);
}
else
{
multiplier = 1;
}
for(i = 1; i < 4; i++)
{
if(multiplier < i)
{
this._spinWheelMC["x" + i + "_on"].visible = false;
}
}
this._spinWheelMC.x = MainFrame.VIEW_WIDTH * 0.5;
this._spinWheelMC.y = MainFrame.VIEW_HEIGHT * 0.5;
this._guiLayer.addChild(this._spinWheelMC);
DarkenManager.darken(this._spinWheelMC);
this._mediaHelpers = [];
this.addGeneralEventListeners();
}
}
private function convertToGemsValue(value:int) : int
{
if(value < 4)
{
return (value + 1) * 25;
}
if(value == 4)
{
return 500;
}
if(value == 5)
{
this._isDiamond = true;
return 1;
}
if(value == 6)
{
this._isGift = true;
return 0;
}
return 25;
}
private function calculateSpinEndPoint(value:int) : int
{
var randomIndex:Number = Math.random();
randomIndex = int(this._wheelNumbers.length * randomIndex);
while(this._wheelNumbers[randomIndex] != value)
{
if(randomIndex + 1 >= this._wheelNumbers.length)
{
randomIndex = 0;
}
else
{
randomIndex++;
}
}
return randomIndex;
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onClose(evt:MouseEvent = null) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(this._gems > 0)
{
GuiManager.startGemsFlash();
SBTracker.trackPageview("game/play/popup/spinBonus/close/didSpin",-1,SBTracker.TYPE_EVENT);
}
else
{
SBTracker.trackPageview("game/play/popup/spinBonus/close/noSpin",-1,SBTracker.TYPE_EVENT);
}
SBTracker.pop();
if(this._callback != null)
{
this._callback();
this._callback = null;
}
else
{
this.destroy();
}
}
private function onSpinBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.trackPageview("game/play/popup/spinBonus/spin",-1,SBTracker.TYPE_EVENT);
this._spinWheelMC.spinBtn.mouse.visible = false;
this._spinWheelMC.spinBtn.down.visible = true;
this._spinWheelMC.spinBtn.down.gotoAndStop(3);
this._spinWheelMC.spinBtn.mouseEnabled = false;
this._spinWheelMC.spinBtn.mouseChildren = false;
this._spinWheelMC.spinBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSpinBtn);
this._spinWheelMC.bx.mouse.visible = false;
this._spinWheelMC.bx.down.visible = true;
this._spinWheelMC.bx.down.gotoAndStop(3);
this._spinWheelMC.bx.mouseEnabled = false;
this._spinWheelMC.bx.mouseChildren = false;
this._spinWheelMC.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_DAILY_GEM_BONUS,1);
DarkenManager.showLoadingSpiral(true);
}
private function onSpinComplete() : void
{
this._displayTimer.start();
}
private function onTimerComplete(te:TimerEvent) : void
{
if(this._spinWheelMC.spinTxtAnim.spinTxt.text == "")
{
this._spinWheelMC.spinTxtAnim.spinTxt.text = this._gems;
this._spinWheelMC.popupObject(0);
AJAudio.playDailySpinBub1();
}
else if(this._spinWheelMC.bonusTxtAnim.bonusTxt.text == "")
{
this._spinWheelMC.bonusTxtAnim.bonusTxt.text = this._multiplier;
this._displayTimer.delay = 750;
this._spinWheelMC.popupObject(1);
AJAudio.playDailySpinBub2();
}
else if(this._spinWheelMC.totalTxtAnim.totalTxt.text == "")
{
this._spinWheelMC.totalTxtAnim.totalTxt.text = Utility.convertNumberToString(this._gems * this._multiplier);
this._displayTimer.delay = 3000;
this._spinWheelMC.popupObject(2);
AJAudio.playDailySpinBub3();
this._spinWheelMC.bx.mouse.visible = true;
this._spinWheelMC.bx.down.visible = false;
this._spinWheelMC.bx.down.gotoAndStop(3);
this._spinWheelMC.bx.mouseEnabled = true;
this._spinWheelMC.bx.mouseChildren = true;
this._spinWheelMC.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
if(this._isGift)
{
GuiManager.initMessagePopups(true);
}
}
else
{
this._displayTimer.reset();
this._displayTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,this.onTimerComplete);
if(!this._isGift)
{
this.onClose();
}
}
}
private function addGeneralEventListeners() : void
{
this._spinWheelMC.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._spinWheelMC.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
this._spinWheelMC.spinBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSpinBtn,false,0,true);
}
private function removeGeneralEventListeners() : void
{
this._spinWheelMC.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._spinWheelMC.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._spinWheelMC.spinBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSpinBtn);
}
}
}
@@ -0,0 +1,190 @@
package gui
{
import avatar.AvatarManager;
import loader.DefPacksDefHelper;
import movie.MovieManager;
import quest.QuestManager;
import room.RoomManagerWorld;
public class GenericListGuiManager
{
public static var movieSelector:MovieManager;
private static var _shop:Shop;
public function GenericListGuiManager()
{
super();
}
public static function genericListVolumeClicked(glId:int, o:Object = null) : void
{
var glTypeId:int = int(gMainFrame.userInfo.getGenericListDefByDefId(glId).typeId);
switch(glTypeId)
{
case DefPacksDefHelper.DEF_ITEM:
case DefPacksDefHelper.DEF_DEN_ITEM:
case DefPacksDefHelper.DEF_CURRENCY_EXCHANGE:
case DefPacksDefHelper.DEF_DIAMOND:
if(o == null || !o.hasOwnProperty("volName") || QuestManager.onShopClick(o.volName))
{
launchStore(glId,glTypeId);
}
break;
case DefPacksDefHelper.DEF_DEN_ROOM:
GuiManager.openDenRoomSwitcher(false,null,true,-1,glId);
break;
case DefPacksDefHelper.DEF_STREAM:
DarkenManager.showLoadingSpiral(true);
GenericListXtCommManager.requestStreamList(glId,launchMovies,o);
break;
case DefPacksDefHelper.DEF_LOCALIZATION:
case DefPacksDefHelper.DEF_MEDIA:
case DefPacksDefHelper.DEF_FACT:
}
}
public static function launchMovies(glId:int, streamIds:Array, thumbIds:Array, baseTitles:Array, indivTitles:Array, statusIds:Array, subtitleIds:Array, helperObject:Object = null) : void
{
var shouldRepeat:Boolean = false;
if(streamIds.length > 1)
{
GenericListXtCommManager.filterList(DefPacksDefHelper.DEF_STREAM,streamIds,{
"thumbIds":thumbIds,
"baseTitles":baseTitles,
"indivTitles":indivTitles,
"statusIds":statusIds,
"subtitleIds":subtitleIds
});
if(Boolean(movieSelector) && Boolean(RoomManagerWorld.instance.theaterWindow))
{
DarkenManager.showLoadingSpiral(false);
movieSelector.toggleVisibility();
}
else
{
if(Boolean(movieSelector))
{
movieSelector.destroy();
movieSelector = null;
}
movieSelector = new MovieManager();
movieSelector.init(GuiManager.guiLayer,RoomManagerWorld.instance.theaterWindow,thumbIds,streamIds,baseTitles,indivTitles,statusIds,subtitleIds,MovieManager.VID_SELECTOR_MEDIA_ID,MovieManager.VID_PLAYER_MEDIA_ID,onMovieSelectorClose);
if(Boolean(helperObject))
{
movieSelector.setSkinFrame(frameIdForMsg(helperObject.msg));
if(helperObject.msg == "bb" || helperObject.msg == "tt")
{
movieSelector.setQuestionBtn();
}
if(Boolean(helperObject.titleTxt))
{
movieSelector.setTitleTxt(helperObject.titleTxt);
}
if(helperObject.msg.indexOf("autoplay") != -1)
{
movieSelector.chooseRandom(true,frameIdForMsg(helperObject.msg),helperObject.shouldRepeat != null ? Boolean(helperObject.shouldRepeat) : false);
}
if(helperObject.shouldRepeat != null)
{
movieSelector.setShouldRepeat(helperObject.shouldRepeat);
}
if(Boolean(helperObject.width) && Boolean(helperObject.height))
{
movieSelector.setDefaultWidthHeight(helperObject.width,helperObject.height);
}
}
}
}
else if(Boolean(helperObject))
{
shouldRepeat = true;
if(helperObject.shouldRepeat != null)
{
shouldRepeat = Boolean(helperObject.shouldRepeat);
}
if(Boolean(helperObject.width) && Boolean(helperObject.height))
{
GuiManager.initMoviePlayer(MovieManager.VID_PLAYER_MEDIA_ID,streamIds,baseTitles,subtitleIds,shouldRepeat,helperObject.width,helperObject.height);
}
else
{
GuiManager.initMoviePlayer(MovieManager.VID_PLAYER_MEDIA_ID,streamIds,baseTitles,subtitleIds,shouldRepeat);
}
if(Boolean(helperObject.msg))
{
GuiManager.setVideoPlayerSkin(frameIdForMsg(helperObject.msg));
}
}
else
{
GuiManager.initMoviePlayer(MovieManager.VID_PLAYER_MEDIA_ID,streamIds,baseTitles,subtitleIds,false);
}
}
public static function onRoomExit() : void
{
if(Boolean(movieSelector))
{
movieSelector.destroy();
movieSelector = null;
}
}
public static function isWorldShopOpen() : Boolean
{
return _shop != null;
}
private static function frameIdForMsg(msg:String) : int
{
msg = msg.toLowerCase();
if(msg == "bb" || msg == "bb_experiments")
{
return MovieManager.BRADY_BARR_SKIN;
}
if(msg == "tt" || msg == "tt_autoplay")
{
return MovieManager.TIERNEY_THYS_SKIN;
}
if(msg == "biggerframe")
{
return MovieManager.BIGGER_FRAME;
}
return MovieManager.NORMAL_SKIN;
}
private static function onMovieSelectorClose() : void
{
if(Boolean(movieSelector))
{
movieSelector.toggleVisibility();
}
}
private static function launchStore(glId:int, glTypeId:int) : void
{
if(Boolean(_shop))
{
_shop.destroy();
}
_shop = new Shop();
_shop.init(glId,glTypeId,AvatarManager.playerAvatar,GuiManager.guiLayer,true,onShopClose,MainFrame.VIEW_WIDTH * 0.5,MainFrame.VIEW_HEIGHT * 0.5);
}
private static function onShopClose(itemsPurchased:Boolean) : void
{
if(Boolean(_shop))
{
_shop.destroy();
_shop = null;
}
}
public function init() : void
{
}
}
}
@@ -0,0 +1,791 @@
package gui
{
import avatar.AvatarManager;
import avatar.UserInfo;
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBYesNoPopup;
import ecard.ECard;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.PetManager;
public class GiftPopup
{
public static const POPUP_TYPE_JAG:int = 0;
public static const POPUP_TYPE_PROMO:int = 1;
public static const POPUP_TYPE_PRIZE:int = 2;
public static const POPUP_TYPE_JB:int = 3;
public static const POPUP_TYPE_JAMAALIDAY_GIFT:int = 4;
public static const POPUP_TYPE_TOUCH_POOL:int = 5;
public static const POPUP_TYPE_HQ:int = 6;
public static const POPUP_TYPE_TREASURE:int = 7;
public static const POPUP_TYPE_ADVENTURES:int = 8;
public static const GIFT_TYPE_GEMS:int = 0;
public static const GIFT_TYPE_CLOTHING:int = 1;
public static const GIFT_TYPE_DEN_ACC:int = 2;
public static const GIFT_TYPE_DEN_ROOM:int = 3;
public static const GIFT_TYPE_AVT:int = 4;
public static const GIFT_TYPE_DEN_AUDIO:int = 5;
public static const GIFT_TYPE_PET:int = 6;
public static const GIFT_TYPE_ORBS:int = 7;
public static const GIFT_TYPE_DIAMOND:int = 8;
public static const BUTTONS_TYPE_KEEP_DISCARD:int = 0;
public static const BUTTONS_TYPE_OK:int = 1;
public static const BUTTONS_TYPE_CREATE:int = 2;
public static const BUTTONS_TYPE_TAKE_LEAVE:int = 3;
private const GIFT_POPUP_ID:int = 1084;
private var _guiLayer:DisplayObjectContainer;
private var _icon:Sprite;
private var _name:String;
private var _popupType:int;
private var _giftType:int;
private var _enviroType:int;
private var _denyForNonMem:Boolean;
private var _buttonsType:int;
private var _onCloseMsg:String;
private var _msgText:String;
private var _keepCallback:Function;
private var _rejectCallback:Function;
private var _closeCallback:Function;
private var _loadingMediaHelper:MediaHelper;
private var _popupContent:MovieClip;
private var _closeMsgOkPopup:SBOkPopup;
private var _recyclePopup:RecycleItems;
private var _giftDataArray:Array;
private var _isFromStartup:Boolean;
private var _popupActive:Boolean;
private var _giftDefIdOrAmount:String;
public function GiftPopup()
{
super();
}
public static function giftTypeForECardType(eCardType:int) : int
{
if(eCardType == ECard.TYPE_GEMS)
{
return GIFT_TYPE_GEMS;
}
if(eCardType == ECard.TYPE_CLOTHING)
{
return GIFT_TYPE_CLOTHING;
}
if(eCardType == ECard.TYPE_DEN_ACC)
{
return GIFT_TYPE_DEN_ACC;
}
if(eCardType == ECard.TYPE_DEN_ROOM)
{
return GIFT_TYPE_DEN_ROOM;
}
if(eCardType == ECard.TYPE_AVT)
{
return GIFT_TYPE_AVT;
}
if(eCardType == ECard.TYPE_DEN_AUDIO)
{
return GIFT_TYPE_DEN_AUDIO;
}
if(eCardType == ECard.TYPE_PET)
{
return GIFT_TYPE_PET;
}
if(eCardType == ECard.TYPE_DIAMOND)
{
return GIFT_TYPE_DIAMOND;
}
return -1;
}
public static function buttonsTypeForECardType(eCardType:int) : int
{
if(eCardType == ECard.TYPE_PET)
{
return BUTTONS_TYPE_CREATE;
}
if(eCardType == ECard.TYPE_GEMS || eCardType == ECard.TYPE_AVT || eCardType == ECard.TYPE_DIAMOND)
{
return BUTTONS_TYPE_OK;
}
return BUTTONS_TYPE_KEEP_DISCARD;
}
public function init(guiLayer:DisplayObjectContainer, icon:Sprite, name:String, giftDefIdOrAmount:int, popupType:int, giftType:int, keepCallback:Function = null, rejectCallback:Function = null, closeCallback:Function = null, denyForNonMem:Boolean = false, buttonsType:int = 0, enviroType:int = 0, onCloseMsg:String = null, msgText:String = null, giftDataArray:Array = null, isFromStartup:Boolean = false) : void
{
this._guiLayer = guiLayer;
this._icon = icon;
this._name = name;
this._enviroType = enviroType;
this._denyForNonMem = denyForNonMem;
this._buttonsType = buttonsType;
this._onCloseMsg = onCloseMsg;
this._giftDefIdOrAmount = giftDefIdOrAmount == 0 ? name : String(giftDefIdOrAmount);
this.translateNonItemNameForTracking();
this._popupType = popupType;
this._giftType = giftType;
this._keepCallback = keepCallback;
this._rejectCallback = rejectCallback;
this._closeCallback = closeCallback;
this._msgText = msgText;
this._giftDataArray = giftDataArray;
this._isFromStartup = isFromStartup;
DarkenManager.showLoadingSpiral(true);
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this.GIFT_POPUP_ID,this.onMediaItemLoaded,this._name);
}
public function destroy() : void
{
this._popupContent.removeEventListener(MouseEvent.MOUSE_DOWN,this.onGiftPopup);
if(Boolean(this._popupContent.buttons.keepBtn.visible))
{
this._guiLayer.stage.removeEventListener(KeyboardEvent.KEY_DOWN,this.keepKeyDown);
this._popupContent.buttons.keepBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.keepBtnDownHandler);
this._guiLayer.stage.removeEventListener(KeyboardEvent.KEY_DOWN,this.rejectKeyDown);
this._popupContent.buttons.discardBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.rejectBtnDownHandler);
}
if(Boolean(this._popupContent.buttons.okBtn.visible))
{
this._guiLayer.stage.removeEventListener(KeyboardEvent.KEY_DOWN,this.rejectFromOkKeyDown);
this._popupContent.buttons.okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.rejectFromOkButtonDownHandler);
}
if(Boolean(this._popupContent.bx.visible))
{
this._popupContent.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onXBtnDown);
}
this._guiLayer.removeChild(this._popupContent);
DarkenManager.unDarken(this._popupContent);
this._popupContent = null;
this._guiLayer = null;
this._icon = null;
this._keepCallback = null;
this._rejectCallback = null;
this._closeCallback = null;
}
public function close() : void
{
if(Boolean(this._onCloseMsg))
{
this._closeMsgOkPopup = new SBOkPopup(this._guiLayer,this._onCloseMsg,true,this.onCloseMsgOkBtnDown);
this._onCloseMsg = null;
return;
}
SBTracker.pop();
if(this._closeCallback != null)
{
this._closeCallback();
}
}
private function onMediaItemLoaded(img:MovieClip) : void
{
var appendMessage:String = null;
if(Boolean(img))
{
appendMessage = this._enviroType == Utility.ENVIRO_OCEAN ? "_Ocean" : "";
SBTracker.push();
SBTracker.trackPageview("game/play/popup/gift/" + this.popupTypeToString(this._popupType) + "/#" + this._giftDefIdOrAmount,-1,SBTracker.TYPE_EVENT);
this._popupContent = MovieClip(img.getChildAt(0));
this._popupContent.itemLayer.addChild(this._icon);
LocalizationManager.updateToFit(this._popupContent.buttons.giftNameTxt,img.passback);
this._popupContent.bx.visible = false;
if(!AJAudio.hasLoadedGiftUnwrapSfx)
{
AJAudio.loadSfx("GiftUnwrap",img.loaderInfo.applicationDomain.getDefinition("GiftUnwrap") as Class,0.6);
AJAudio.loadSfx("TreasureUnwrap",img.loaderInfo.applicationDomain.getDefinition("TreasureUnwrap") as Class,0.33);
AJAudio.hasLoadedGiftUnwrapSfx = true;
}
this._guiLayer.addChild(this._popupContent);
if(this._popupType == POPUP_TYPE_PROMO)
{
this._popupContent.buttons.treasureNameTxt.visible = false;
this._popupContent.buttons.treasureTxtBox.visible = false;
if(this._name.indexOf("Diamond") != -1)
{
LocalizationManager.translateId(this._popupContent.mailboxTitleTxt,11280);
}
else
{
LocalizationManager.translateId(this._popupContent.mailboxTitleTxt,11281);
}
this._popupContent.present.addEventListener(MouseEvent.MOUSE_DOWN,this.onPresentDownHandler,false,0,true);
this._popupContent.buttons.visible = false;
}
else if(this._popupType == POPUP_TYPE_HQ)
{
this._popupContent.buttons.treasureNameTxt.visible = false;
this._popupContent.buttons.treasureTxtBox.visible = false;
this._popupContent.present.addEventListener(MouseEvent.MOUSE_DOWN,this.onPresentDownHandler,false,0,true);
if(!this._isFromStartup)
{
this._popupContent.bx.visible = true;
this._popupContent.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onXBtnDown,false,0,true);
}
this._popupContent.gotoAndPlay("offMessage");
if(Boolean(this._msgText))
{
this._popupContent.messageTxt.text = this._msgText;
}
this._popupContent.buttons.visible = false;
}
else if(this._popupType == POPUP_TYPE_TREASURE)
{
this._popupContent.buttons.giftNameTxt.visible = false;
this._popupContent.buttons.giftTxtBox.visible = false;
this._popupContent.buttons.treasureNameTxt.text = img.passback;
this._popupContent.gotoAndStop("offTreasureMessage" + appendMessage);
this._popupContent.present.addEventListener(MouseEvent.MOUSE_DOWN,this.onPresentDownHandler,false,0,true);
this._popupContent.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onXBtnDown,false,0,true);
this._popupContent.buttons.visible = false;
}
else if(this._popupType == POPUP_TYPE_ADVENTURES)
{
this._popupContent.buttons.giftNameTxt.visible = false;
this._popupContent.buttons.giftTxtBox.visible = false;
this._popupContent.buttons.treasureNameTxt.text = img.passback;
this._popupContent.gotoAndPlay("onChooseTreasure" + appendMessage);
AJAudio.playTreasureUnwrap();
}
else
{
this._popupContent.buttons.treasureNameTxt.visible = false;
this._popupContent.buttons.treasureTxtBox.visible = false;
if(this._popupType == POPUP_TYPE_JAG || this._popupType == POPUP_TYPE_JB || this._popupType == POPUP_TYPE_TOUCH_POOL)
{
if(this._popupType == POPUP_TYPE_TOUCH_POOL)
{
LocalizationManager.translateId(this._popupContent.mailboxTitleTxt,11282);
}
else
{
LocalizationManager.translateId(this._popupContent.mailboxTitleTxt,11283);
}
this._popupContent.bx.visible = true;
this._popupContent.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onXBtnDown,false,0,true);
}
else if(this._popupType == POPUP_TYPE_JAMAALIDAY_GIFT)
{
LocalizationManager.translateId(this._popupContent.mailboxTitleTxt,11283);
}
else if(this._popupType == POPUP_TYPE_PRIZE)
{
LocalizationManager.translateId(this._popupContent.mailboxTitleTxt,11282);
}
this._popupContent.gotoAndStop("lastFrame");
AJAudio.playGiftUnwrap();
}
this._popupContent.addEventListener(MouseEvent.MOUSE_DOWN,this.onGiftPopup,false,0,true);
if(this._buttonsType == BUTTONS_TYPE_KEEP_DISCARD)
{
this._guiLayer.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.keepKeyDown,false,0,true);
this._popupContent.buttons.keepBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.keepBtnDownHandler,false,0,true);
this._guiLayer.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.rejectKeyDown,false,0,true);
this._popupContent.buttons.discardBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.rejectBtnDownHandler,false,0,true);
this._popupContent.buttons.okBtn.visible = false;
this._popupContent.buttons.createBtn.visible = false;
if(Boolean(this._popupContent.buttons.takeBtn))
{
this._popupContent.buttons.takeBtn.visible = false;
}
if(Boolean(this._popupContent.buttons.leaveBtn))
{
this._popupContent.buttons.leaveBtn.visible = false;
}
}
else if(this._buttonsType == BUTTONS_TYPE_OK)
{
this._guiLayer.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.rejectFromOkKeyDown,false,0,true);
this._popupContent.buttons.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.rejectFromOkButtonDownHandler,false,0,true);
this._popupContent.buttons.keepBtn.visible = false;
this._popupContent.buttons.discardBtn.visible = false;
this._popupContent.buttons.createBtn.visible = false;
if(Boolean(this._popupContent.buttons.takeBtn))
{
this._popupContent.buttons.takeBtn.visible = false;
}
if(Boolean(this._popupContent.buttons.leaveBtn))
{
this._popupContent.buttons.leaveBtn.visible = false;
}
}
else if(this._buttonsType == BUTTONS_TYPE_CREATE)
{
this._popupContent.buttons.createBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onCreateButton,false,0,true);
this._popupContent.buttons.createBtn.visible = true;
this._popupContent.buttons.keepBtn.visible = false;
this._popupContent.buttons.discardBtn.visible = false;
this._popupContent.buttons.okBtn.visible = false;
if(Boolean(this._popupContent.buttons.takeBtn))
{
this._popupContent.buttons.takeBtn.visible = false;
}
if(Boolean(this._popupContent.buttons.leaveBtn))
{
this._popupContent.buttons.leaveBtn.visible = false;
}
}
else if(this._buttonsType == BUTTONS_TYPE_TAKE_LEAVE)
{
this._guiLayer.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.keepKeyDown,false,0,true);
this._popupContent.buttons.takeBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.keepBtnDownHandler,false,0,true);
this._guiLayer.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.rejectKeyDown,false,0,true);
this._popupContent.buttons.leaveBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.rejectBtnDownHandler,false,0,true);
this._popupContent.buttons.okBtn.visible = false;
this._popupContent.buttons.createBtn.visible = false;
this._popupContent.buttons.keepBtn.visible = false;
this._popupContent.buttons.discardBtn.visible = false;
}
this._popupContent.x = MainFrame.VIEW_WIDTH * 0.5;
this._popupContent.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._popupContent);
}
}
private function keepKeyDown(event:KeyboardEvent) : void
{
if(this._popupActive == false)
{
switch(event.keyCode)
{
case Keyboard.ENTER:
case Keyboard.SPACE:
this.keepBtnDownHandler(event);
}
}
}
private function rejectKeyDown(event:KeyboardEvent) : void
{
if(this._popupActive == false)
{
switch(event.keyCode)
{
case Keyboard.BACKSPACE:
case Keyboard.DELETE:
case Keyboard.ESCAPE:
this.rejectBtnDownHandler(event);
}
}
}
private function rejectFromOkKeyDown(event:KeyboardEvent) : void
{
if(this._popupActive == false)
{
switch(event.keyCode)
{
case Keyboard.BACKSPACE:
case Keyboard.DELETE:
case Keyboard.ESCAPE:
this.rejectFromOkButtonDownHandler(event);
}
}
}
private function onGiftPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onXBtnDown(evt:MouseEvent) : void
{
evt.stopPropagation();
this.close();
}
private function onPresentDownHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
var appendMessage:String = this._enviroType == Utility.ENVIRO_OCEAN ? "_Ocean" : "";
this._popupContent.buttons.visible = true;
this._popupContent.present.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPresentDownHandler);
this._popupContent.gotoAndPlay(this._popupType == POPUP_TYPE_HQ ? "onMessage" : (this._popupType == POPUP_TYPE_TREASURE ? "onTreasureMessage" + appendMessage : "on"));
if(this._popupType == POPUP_TYPE_TREASURE)
{
AJAudio.playTreasureUnwrap();
}
else
{
AJAudio.playGiftUnwrap();
}
}
private function keepBtnDownHandler(evt:Event) : void
{
var inv:Array = null;
var invSize:int = 0;
var invMaxSize:int = 0;
var recycleId:int = 0;
var fullItems:Array = null;
var ui:UserInfo = null;
var i:int = 0;
if(Boolean(evt))
{
evt.stopPropagation();
}
if(this._denyForNonMem && !gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.JAG,"Receiving_Gift");
}
else
{
inv = [];
if(this._giftType == GIFT_TYPE_CLOTHING)
{
if(Boolean(gMainFrame.userInfo.playerAvatarInfo))
{
fullItems = gMainFrame.userInfo.playerAvatarInfo.getFullItems();
}
if(this._enviroType == Utility.ENVIRO_LAND)
{
if(fullItems.length > 0)
{
inv = Utility.clothingItemListByEnviroType(fullItems,Utility.ENVIRO_LAND);
}
recycleId = RecycleItems.RECYCLE_ACCESSORIES_LAND_ONLY;
}
else
{
if(fullItems.length > 0)
{
inv = Utility.clothingItemListByEnviroType(fullItems,Utility.ENVIRO_OCEAN);
}
recycleId = RecycleItems.RECYCLE_ACCESSORIES_OCEAN_ONLY;
}
if(Boolean(inv))
{
invSize = int(inv.length);
}
invMaxSize = Shop.maxItems;
}
else if(this._giftType == GIFT_TYPE_DEN_ACC)
{
if(this._enviroType == Utility.ENVIRO_LAND)
{
if(Boolean(gMainFrame.userInfo.playerUserInfo))
{
ui = gMainFrame.userInfo.playerUserInfo;
if(ui.denItemsFull.length > 0)
{
inv = Utility.denItemListByEnviroType(ui.denItemsFull,Utility.ENVIRO_LAND);
}
}
recycleId = RecycleItems.RECYCLE_DEN_ITEMS_LAND_ONLY;
}
else
{
if(Boolean(gMainFrame.userInfo.playerUserInfo) && gMainFrame.userInfo.playerUserInfo.denItemsFull.length > 0)
{
inv = Utility.denItemListByEnviroType(gMainFrame.userInfo.playerUserInfo.denItemsFull,Utility.ENVIRO_OCEAN);
}
recycleId = RecycleItems.RECYCLE_DEN_ITEMS_OCEAN_ONLY;
}
if(Boolean(inv))
{
invSize = int(inv.length);
}
invMaxSize = Shop.maxDenItems;
}
else if(this._giftType == GIFT_TYPE_DEN_AUDIO)
{
if(Boolean(gMainFrame.userInfo.playerUserInfo) && gMainFrame.userInfo.playerUserInfo.denItemsFull.length > 0)
{
inv = Utility.denItemListByEnviroType(gMainFrame.userInfo.playerUserInfo.denItemsFull,-1,true);
}
recycleId = RecycleItems.RECYCLE_DEN_AUDIO;
if(Boolean(inv))
{
invSize = int(inv.length);
}
invMaxSize = Shop.maxAudioItems;
}
else if(this._giftType == GIFT_TYPE_DEN_ROOM)
{
inv = DenSwitch.denList;
recycleId = DenSwitch.RECYCLE_DEN_ROOM;
if(Boolean(inv))
{
for(i = 0; i < inv.length; i++)
{
if(Boolean(inv[i]))
{
invSize++;
}
}
}
invMaxSize = SwitchManager.NUM_DEN_ROOM_SLOTS;
}
else
{
if(this._popupType == POPUP_TYPE_ADVENTURES)
{
if(this._giftType == GIFT_TYPE_GEMS || this._giftType == GIFT_TYPE_ORBS)
{
this.keepItem();
return;
}
}
trace("Invalid type for GiftPopup keep button. type=" + this._giftType);
}
if(Utility.canGift() || this._popupType != POPUP_TYPE_JAG)
{
if(invSize >= invMaxSize)
{
this._popupActive = true;
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdOnly(14746),true,this.confirmRecycleHandler,recycleId);
}
else
{
this.keepItem();
}
}
else
{
this._popupActive = true;
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdOnly(14747),true,this.okPopupComplete);
}
}
}
private function okPopupComplete(evt:MouseEvent) : void
{
this._popupActive = false;
SBOkPopup.destroyInParentChain(evt.target.parent);
}
private function rejectFromOkButtonDownHandler(evt:Event) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(this._giftType == GIFT_TYPE_GEMS || this._giftType == GIFT_TYPE_ORBS || this._giftType == GIFT_TYPE_DIAMOND)
{
GuiManager.startGemsFlash();
}
SBTracker.trackPageview("game/play/popup/gift/" + this.popupTypeToString(this._popupType) + "/#" + this._giftDefIdOrAmount + "/ok",-1,SBTracker.TYPE_EVENT);
if(this._rejectCallback != null)
{
this._rejectCallback();
}
else
{
this.close();
}
}
private function rejectBtnDownHandler(evt:Event) : void
{
var localizedMessage:String = null;
if(Boolean(evt))
{
evt.stopPropagation();
}
if(this._popupType != POPUP_TYPE_TREASURE)
{
if(this._popupType == POPUP_TYPE_PROMO)
{
localizedMessage = LocalizationManager.translateIdAndInsertOnly(14748,this._popupContent.mailboxTitleTxt.text.toLowerCase());
}
else if(this._popupType == POPUP_TYPE_HQ)
{
localizedMessage = LocalizationManager.translateIdOnly(14749);
}
else
{
localizedMessage = LocalizationManager.translateIdAndInsertOnly(14750,this._popupContent.mailboxTitleTxt.text.toLowerCase());
}
this._popupActive = true;
new SBYesNoPopup(this._guiLayer,localizedMessage,true,this.onConfirmReject);
}
else
{
this._popupActive = true;
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdOnly(14919),true,this.onConfirmReject);
}
}
private function onCreateButton(evt:MouseEvent) : void
{
PetManager.openPetFinder(this._name.toLowerCase().replace(/[\s\r\n]*/gim,""),this.onPetCreated,true,this._giftDataArray);
}
private function onPetCreated() : void
{
if(this._closeCallback != null)
{
this._closeCallback();
}
}
private function onConfirmReject(o:Object) : void
{
if(Boolean(o.status))
{
SBTracker.trackPageview("game/play/popup/gift/" + this.popupTypeToString(this._popupType) + "/#" + this._giftDefIdOrAmount + "/reject",-1,SBTracker.TYPE_EVENT);
if(this._rejectCallback != null)
{
this._rejectCallback();
}
else
{
this.close();
}
}
this._popupActive = false;
}
private function keepItem() : void
{
SBTracker.trackPageview("game/play/popup/gift/" + this.popupTypeToString(this._popupType) + "/#" + this._giftDefIdOrAmount + "/keep",-1,SBTracker.TYPE_EVENT);
if(this._keepCallback != null)
{
this._keepCallback();
}
else
{
this.close();
}
}
private function onCloseMsgOkBtnDown(evt:MouseEvent) : void
{
evt.stopPropagation();
this._closeMsgOkPopup.destroy();
this._closeMsgOkPopup = null;
this.close();
}
private function confirmRecycleHandler(o:Object) : void
{
var recycleType:int = 0;
if(Boolean(o.status))
{
recycleType = int(o.passback);
if(recycleType == DenSwitch.RECYCLE_DEN_ROOM)
{
GuiManager.openDenRoomSwitcher(true,this.onDenRoomRecycleClose);
}
else
{
this._recyclePopup = new RecycleItems();
this._recyclePopup.init(recycleType,this._guiLayer,true,this.onRecycleClose,MainFrame.VIEW_WIDTH * 0.5,MainFrame.VIEW_HEIGHT * 0.5,this._enviroType == AvatarManager.roomEnviroType);
}
}
this._popupActive = false;
}
private function onRecycleClose(itemRecycled:Boolean = false) : void
{
if(Boolean(this._recyclePopup))
{
this._recyclePopup.destroy();
this._recyclePopup = null;
}
if(itemRecycled)
{
this.keepItem();
}
}
private function onDenRoomRecycleClose(itemRecycled:Boolean = false) : void
{
GuiManager.onDenSwitchClose(true);
if(itemRecycled)
{
this.keepItem();
}
}
private function popupTypeToString(type:int) : String
{
switch(type)
{
case POPUP_TYPE_JAG:
return "JAG";
case POPUP_TYPE_PRIZE:
return "Prize";
case POPUP_TYPE_PROMO:
return "Promo";
case POPUP_TYPE_JB:
return "JB";
case POPUP_TYPE_TOUCH_POOL:
return "TouchPool";
default:
return "";
}
}
private function translateNonItemNameForTracking() : void
{
if(this._giftType == GIFT_TYPE_GEMS)
{
this._giftDefIdOrAmount += " gems";
}
else if(this._giftType == GIFT_TYPE_ORBS)
{
this._giftDefIdOrAmount += " orbs";
}
else if(this._giftType == GIFT_TYPE_DIAMOND)
{
this._giftDefIdOrAmount += " diamonds";
}
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,160 @@
package gui
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.filters.GlowFilter;
import flash.text.TextField;
import flash.ui.Keyboard;
public class GuiCheckBox
{
public var box:MovieClip;
public var grayBox:MovieClip;
public var check:MovieClip;
public var chkTxt:TextField;
private var _currCheckBox:MovieClip;
private var _checkCallback:Function;
private var _glow:GlowFilter;
public function GuiCheckBox(initAsset:MovieClip, initCheckCallback:Function = null)
{
super();
this._currCheckBox = initAsset;
this._checkCallback = initCheckCallback;
}
public function init(initChkTxt:TextField = null) : void
{
this.chkTxt = initChkTxt;
this.box = this._currCheckBox["_box"];
this.check = this.box["_check"];
this.grayBox = this._currCheckBox["_boxGray"];
if(Boolean(this.grayBox))
{
this.grayBox.visible = false;
}
if(!(Boolean(this.box) && Boolean(this.check)))
{
throw new Error("GuiCheckBox is missing parts or they are named incorrectly!");
}
this.box.stop();
this.check.stop();
this._currCheckBox.tabEnabled = true;
this._glow = new GlowFilter(5562619,1,6,6,2,2);
this._currCheckBox.addEventListener(KeyboardEvent.KEY_DOWN,this.checkBoxKeyDownHandler,false,0,true);
this._currCheckBox.addEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler,false,0,true);
this._currCheckBox.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
this._currCheckBox.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
if(this.chkTxt != null)
{
this.chkTxt.addEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler,false,0,true);
this.chkTxt.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
this.chkTxt.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
}
}
public function destroy() : void
{
this._currCheckBox.removeEventListener(KeyboardEvent.KEY_DOWN,this.checkBoxKeyDownHandler);
this._currCheckBox.removeEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler);
this._currCheckBox.removeEventListener(MouseEvent.ROLL_OVER,this.onRollOver);
this._currCheckBox.removeEventListener(MouseEvent.ROLL_OUT,this.onRollOut);
if(this.chkTxt != null)
{
this.chkTxt.removeEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler);
this.chkTxt.removeEventListener(MouseEvent.ROLL_OVER,this.onRollOver);
this.chkTxt.removeEventListener(MouseEvent.ROLL_OUT,this.onRollOut);
}
this._currCheckBox = null;
this._checkCallback = null;
}
public function get gray() : Boolean
{
if(Boolean(this.grayBox))
{
return this.grayBox.visible;
}
return false;
}
public function set gray(setGrayed:Boolean) : void
{
if(Boolean(this.grayBox))
{
this.grayBox.visible = setGrayed;
this.box.visible = !setGrayed;
}
}
public function get checked() : Boolean
{
return this.check.visible;
}
public function set checked(setChecked:Boolean) : void
{
this.check.visible = setChecked;
}
private function checkBoxKeyDownHandler(k:KeyboardEvent) : void
{
if(!this.gray)
{
if(k.keyCode == Keyboard.SPACE)
{
this.checked = !this.checked;
}
if(this._checkCallback != null)
{
this._checkCallback();
}
}
}
private function checkBoxClickHandler(m:MouseEvent) : void
{
if(!this.gray)
{
this.checked = !this.checked;
if(this._checkCallback != null)
{
this._checkCallback();
}
}
}
private function onRollOver(evt:MouseEvent) : void
{
if(!this.gray)
{
this.box.filters = [this._glow];
if(Boolean(this.chkTxt))
{
this.chkTxt.filters = [this._glow];
}
}
}
private function onRollOut(evt:MouseEvent) : void
{
if(!this.gray)
{
this.box.filters = null;
if(Boolean(this.chkTxt))
{
this.chkTxt.filters = null;
}
}
}
}
}
@@ -0,0 +1,189 @@
package gui
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.ui.Keyboard;
public class GuiDropdown
{
public var dropdownTxt:TextField;
public var dropdownBtn:MovieClip;
public var dropdown:MovieClip;
public var scrollContent:MovieClip;
public var scrollView:MovieClip;
public var highlight:MovieClip;
public var scrollbar:SBScrollbar;
public var selectedTxt:TextField;
public var selectedIdx:int;
public var scrollItems:Array;
public var blockItemDown:Boolean;
public var currDropDown:MovieClip;
public function GuiDropdown(initCurrDropDown:MovieClip)
{
var ido:DisplayObject = null;
super();
this.currDropDown = initCurrDropDown;
this.dropdownTxt = this.currDropDown.dropdown_txt;
this.dropdownBtn = this.currDropDown.dropdown_btn;
this.dropdown = this.currDropDown._dropdown;
this.scrollContent = this.dropdown.scroll_content;
this.highlight = this.scrollContent.dropdown_h;
this.scrollView = this.dropdown.scroll_view;
this.scrollItems = [];
for(var i:int = 0; i < this.scrollContent.numChildren; i++)
{
ido = this.scrollContent.getChildAt(i);
if(ido.name.indexOf("_item") == 0)
{
ido.addEventListener(MouseEvent.MOUSE_DOWN,this.itemMouseDownHandler,false,0,true);
this.scrollItems[int(ido.name.substr(5)) - 1] = ido;
}
}
}
public function init(gap:Number, defaultIdx:int = 0, defaultTxt:String = null) : void
{
this.dropdown.visible = false;
if(this.scrollContent.height > this.scrollView.height)
{
this.scrollbar = new SBScrollbar();
this.scrollbar.init(this.scrollContent,this.scrollView.width,this.scrollView.height,gap,"scrollbar2",this.scrollContent["_item2"].y - this.scrollContent["_item1"].y);
}
if(defaultIdx > 0)
{
if(Boolean(this.scrollbar))
{
this.scrollbar.scrollToElement(defaultIdx);
}
this.selectedIdx = defaultIdx;
this.selectedTxt = this.scrollItems[defaultIdx];
this.highlight.visible = true;
this.highlight.y = this.selectedTxt.y + this.highlight.height * 0.5;
}
if(Boolean(defaultTxt))
{
this.selectedIdx = -1;
this.dropdownTxt.text = defaultTxt;
}
else
{
this.selectedIdx = this.selectedIdx;
this.selectedTxt = this.scrollItems[defaultIdx];
this.dropdownTxt.text = this.selectedTxt.text;
}
this.scrollView.visible = false;
this.dropdownBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.dropdownBtnMouseDownHandler,false,0,true);
this.currDropDown.addEventListener(KeyboardEvent.KEY_DOWN,this.keyDownHandler,false,0,true);
}
public function destroy() : void
{
var ido:DisplayObject = null;
for(var i:int = 0; i < this.scrollContent.numChildren; i++)
{
ido = this.scrollContent.getChildAt(i);
if(ido.name.indexOf("_item") == 0)
{
ido.removeEventListener(MouseEvent.MOUSE_DOWN,this.itemMouseDownHandler);
}
}
this.scrollItems = null;
if(Boolean(this.scrollbar))
{
this.scrollbar.destroy();
this.scrollbar = null;
}
this.dropdownBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.dropdownBtnMouseDownHandler);
this.currDropDown.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownHandler);
}
public function reset(defaultIdx:int = 0, defaultText:String = null) : void
{
if(Boolean(this.scrollbar))
{
this.scrollbar.scrollToElement(defaultIdx);
}
if(Boolean(defaultIdx))
{
if(Boolean(this.scrollbar))
{
this.scrollbar.scrollToElement(defaultIdx);
}
this.selectedIdx = defaultIdx;
this.selectedTxt = this.scrollItems[defaultIdx];
this.highlight.visible = true;
this.highlight.y = this.selectedTxt.y + this.highlight.height * 0.5;
}
if(Boolean(defaultText))
{
this.selectedIdx = -1;
this.dropdownTxt.text = defaultText;
}
else
{
this.selectedIdx = this.selectedIdx;
this.selectedTxt = this.scrollItems[defaultIdx];
this.dropdownTxt.text = this.selectedTxt.text;
}
}
public function closeDropdownSilent() : void
{
this.focusOutHandler(null);
GuiSoundToggleButton(this.dropdownBtn).downToUpState();
}
private function keyDownHandler(k:KeyboardEvent) : void
{
if(k.keyCode == Keyboard.SPACE)
{
this.dropdownBtnMouseDownHandler(null);
}
}
private function dropdownBtnMouseDownHandler(m:MouseEvent) : void
{
this.dropdown.visible = !this.dropdown.visible;
}
private function focusOutHandler(f:FocusEvent) : void
{
if(this.dropdown.visible)
{
this.dropdown.visible = false;
}
}
private function itemMouseDownHandler(m:MouseEvent) : void
{
if(!this.blockItemDown)
{
this.selectedTxt = TextField(m.currentTarget);
this.selectedIdx = int(this.selectedTxt.name.substr(5)) - 1;
this.dropdownTxt.text = this.selectedTxt.text;
this.highlight.visible = true;
this.highlight.y = this.selectedTxt.y + this.highlight.height * 0.5;
this.dropdownBtn.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
this.dropdownBtn.dispatchEvent(new MouseEvent(MouseEvent.ROLL_OUT));
}
}
}
}
@@ -0,0 +1,97 @@
package gui
{
import flash.display.MovieClip;
public class GuiDropdownDay extends GuiDropdown
{
private var _numDaysShow:int = 31;
public function GuiDropdownDay(initCurrDropDown:MovieClip)
{
super(initCurrDropDown);
}
public function updateDaysShown(numDaysToShow:int) : void
{
var itemHeight:int = 0;
var scrollHeightDecrement:int = 0;
var defaultTxt:String = null;
if(Boolean(scrollItems) && Boolean(scrollItems.length > 0) && this._numDaysShow != numDaysToShow)
{
itemHeight = scrollContent["_item2"].y - scrollContent["_item1"].y;
scrollHeightDecrement = 0;
defaultTxt = null;
this._numDaysShow = numDaysToShow;
if(numDaysToShow == 30)
{
scrollHeightDecrement = itemHeight;
if(selectedIdx > 29)
{
selectedIdx = 29;
}
}
else if(numDaysToShow == 29)
{
scrollHeightDecrement = itemHeight * 2;
if(selectedIdx > 28)
{
selectedIdx = 28;
}
}
else if(numDaysToShow == 28)
{
scrollHeightDecrement = itemHeight * 3;
if(selectedIdx > 27)
{
selectedIdx = 27;
}
}
if(selectedIdx == -1)
{
selectedIdx = 0;
defaultTxt = "-";
}
this.rebuild(0.55,selectedIdx,defaultTxt,scrollHeightDecrement);
}
}
private function rebuild(gap:Number, defaultIdx:int, defaultTxt:String, scrollHeightDecrement:Number) : void
{
dropdown.visible = false;
if(Boolean(scrollbar))
{
scrollbar.destroy();
scrollbar = null;
}
if(scrollContent.height > scrollView.height)
{
scrollbar = new SBScrollbar();
scrollbar.init(scrollContent,scrollView.width,scrollView.height,gap,"scrollbar2",scrollContent["_item2"].y - scrollContent["_item1"].y,0,scrollHeightDecrement == -1 ? -1 : scrollContent.height - scrollHeightDecrement);
}
if(defaultIdx > 0)
{
if(Boolean(scrollbar))
{
scrollbar.scrollToElement(defaultIdx);
}
selectedIdx = defaultIdx;
selectedTxt = scrollItems[defaultIdx];
highlight.visible = true;
highlight.y = selectedTxt.y + highlight.height * 0.5;
}
if(Boolean(defaultTxt))
{
this.selectedIdx = -1;
dropdownTxt.text = defaultTxt;
}
else
{
this.selectedIdx = selectedIdx;
selectedTxt = scrollItems[defaultIdx];
dropdownTxt.text = selectedTxt.text;
}
}
}
}
@@ -0,0 +1,125 @@
package gui
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class GuiHelpTextBubble extends MovieClip
{
public var soundBtn:MovieClip;
public var txt:TextField;
public var tl:MovieClip;
public var tr:MovieClip;
public var bl:MovieClip;
public var bl2:MovieClip;
public var br:MovieClip;
public var bubble:MovieClip;
public var helpBubbleBG:MovieClip = null;
public var helpBubble:MovieClip = null;
public function GuiHelpTextBubble()
{
super();
this.soundBtn = this["soundBtn"];
this.txt = this["txt"];
this.tl = this["tl"];
this.tr = this["tr"];
this.bl = this["bl"];
this.bl2 = this["bl2"];
this.br = this["br"];
this.bubble = this["bubble"];
if(!this.soundBtn)
{
throw new Error("GuiHelpTextBubble MAIN BUTTONS is missing part or they are named incorrectly!");
}
if(!(Boolean(this.tl) && Boolean(this.tr) && Boolean(this.bl) && Boolean(this.bl2) && Boolean(this.br) && Boolean(this.bubble)))
{
throw new Error("GuiHelpTextBubble MAIN CONTENTS section is missing parts or they are named incorrectly!");
}
if(!this.txt)
{
throw new Error("GuiHelpTextBubble TEXT FIELDS section is missing parts or they are named incorrectly!");
}
}
public function init(init_x:Number = undefined, init_y:Number = undefined) : void
{
visible = false;
this.txt.autoSize = TextFieldAutoSize.CENTER;
}
public function setText(text:String) : void
{
this.txt.text = text;
}
public function setPos(x:int, y:int) : void
{
this.x = x;
this.y = y;
}
public function bringToFront() : void
{
parent.setChildIndex(this,parent.numChildren - 1);
}
public function setTails(top:Boolean = false, left:Boolean = false, twoTails:Boolean = false) : void
{
if(twoTails)
{
this.tl.visible = false;
this.tr.visible = false;
this.bl.visible = false;
this.br.visible = false;
this.bl2.visible = true;
}
else if(top)
{
if(left)
{
this.tl.visible = true;
this.tr.visible = false;
this.bl.visible = false;
this.br.visible = false;
this.bl2.visible = false;
}
else
{
this.tl.visible = false;
this.tr.visible = true;
this.bl.visible = false;
this.br.visible = false;
this.bl2.visible = false;
}
}
else if(left)
{
this.tl.visible = false;
this.tr.visible = false;
this.bl.visible = true;
this.br.visible = false;
this.bl2.visible = false;
}
else
{
this.tl.visible = false;
this.tr.visible = false;
this.bl.visible = false;
this.br.visible = true;
this.bl2.visible = false;
}
}
}
}
@@ -0,0 +1,185 @@
package gui
{
import flash.display.MovieClip;
import flash.text.TextField;
public class GuiHud extends MovieClip
{
public var charWindow:MovieClip;
public var charNameTxt:TextField;
public var safeChatTreeWindow:MovieClip;
public var swapBtn:MovieClip;
public var actionsWindow:MovieClip;
public var emotesWindow:MovieClip;
public var chatBar:MovieClip;
public var sendChatBtn:MovieClip;
public var ansChatBtn:MovieClip;
public var chatTxt:TextField;
public var chatHist:MovieClip;
public var chatHistUpDownBtn:MovieClip;
public var chatHistTxt:TextField;
public var chatRepeatBtn:MovieClip;
public var chatRepeatWindow:MovieClip;
public var editCharBtn:MovieClip;
public var actionsBtn:MovieClip;
public var safeChatBtn:MovieClip;
public var emotesBtn:MovieClip;
public var denBtn:MovieClip;
public var worldMapBtn:MovieClip;
public var soundBtn:MovieClip;
public var furnBtn:MovieClip;
public var eCardBtn:MovieClip;
public var buddyListBtn:MovieClip;
public var newsBtn:MovieClip;
public var awardsBtn:MovieClip;
public var gemsBtn:MovieClip;
public var reportBtn:MovieClip;
public var mySettingsBtn:MovieClip;
public var zoneName:MovieClip;
public var zoneNameTxt:TextField;
public var eCardCount:MovieClip;
public var eCardCountTxt:TextField;
public var partyBtn:MovieClip;
public var playerWallBtn:MovieClip;
public var combatCardDeckBtn:MovieClip;
public var questExitBtn:MovieClip;
public var questPlayersBtn:MovieClip;
public var questObjectiveTxt:TextField;
public var mainBlock:MovieClip;
public var gemsBtnBlock:MovieClip;
public var charWindowBlock:MovieClip;
private var append:String;
public function GuiHud()
{
super();
this.init();
}
public function init(inGame:Boolean = false) : void
{
this.append = currentFrameLabel == "quest" ? "Quest" : "";
this.charWindow = this["char"];
this.charNameTxt = this["text01_charName"];
this.safeChatTreeWindow = this["safeChatTree" + this.append];
this.actionsWindow = this["actionWindow" + this.append];
this.emotesWindow = this["emoteWindow" + this.append];
this.chatBar = this["hud01_chat" + this.append];
this.sendChatBtn = this.chatBar != null ? this.chatBar.but01_send : null;
this.ansChatBtn = this.chatBar != null ? this.chatBar.but01_ans : null;
this.chatTxt = this.chatBar != null ? this.chatBar.text01_chat : null;
this.chatHist = this["chat" + this.append];
this.chatHistUpDownBtn = this.chatHist != null ? this.chatHist.chatHistoryBG.chatHistBox.hud01_chatHistory.chatUpDown : null;
this.chatHistTxt = this.chatHist != null ? this.chatHist.chatHistoryBG["chatHistoryTxtCont" + this.append].text01_chatHistory : null;
this.chatRepeatBtn = this["chatRepeat" + this.append];
this.chatRepeatWindow = this["chatRepeatWindow" + this.append];
this.swapBtn = this["swap"];
this.actionsBtn = this["anim" + this.append];
this.safeChatBtn = this["speedChat" + this.append];
this.emotesBtn = this["emote" + this.append];
this.denBtn = this["home"];
this.worldMapBtn = this["world"];
this.soundBtn = this["sound_btn" + this.append];
this.furnBtn = this["furnBtn"];
this.eCardBtn = this["mail"];
this.buddyListBtn = this["buddyList"];
this.newsBtn = this["news"];
this.awardsBtn = this["trophy"];
this.gemsBtn = this["money"];
this.reportBtn = this["report"];
this.mySettingsBtn = this["mySettings"];
this.zoneName = this["zoneName"];
this.zoneNameTxt = this.zoneName != null ? this.zoneName.mouse.name_txt : null;
this.eCardCount = this.eCardBtn != null ? this.eCardBtn.newEcardCount : null;
this.eCardCountTxt = this.eCardCount != null ? this.eCardCount.eCardCountTxt : null;
this.mainBlock = this["mainBlock"];
this.gemsBtnBlock = this["gemsBtnBlock"];
this.charWindowBlock = this["charWindowBlock"];
this.partyBtn = this["party"];
this.playerWallBtn = this["playerWall"];
this.combatCardDeckBtn = this["cardDeck_btn"];
this.questExitBtn = this["questingExit_btn" + this.append];
this.questPlayersBtn = this["questPlayersBtn"];
if(this["objBar"] != null)
{
this.questObjectiveTxt = this["objBar"].objTxt;
}
if(!inGame)
{
if(!(Boolean(this.eCardBtn) && Boolean(this.buddyListBtn) && Boolean(this.newsBtn) && Boolean(this.awardsBtn) && Boolean(this.gemsBtn) && Boolean(this.zoneName) && Boolean(this.mySettingsBtn) && Boolean(this.reportBtn) && Boolean(this.playerWallBtn)))
{
throw new Error("GuiHud TOP BAR section is missing parts or they are named incorrectly!");
}
if(!(this.swapBtn && this.actionsBtn && this.safeChatBtn && this.emotesBtn && this.denBtn && this.worldMapBtn && this.soundBtn && this.charNameTxt && Boolean(this.eCardCount) && this.eCardCountTxt))
{
throw new Error("GuiHud MAIN BUTTONS section is missing parts or they are named incorrectly!");
}
if(!(Boolean(this.actionsWindow) && Boolean(this.safeChatTreeWindow) && Boolean(this.emotesWindow) && Boolean(this.charWindow)))
{
throw new Error("GuiHud WINDOWS section is missing parts or they are named incorrectly!");
}
if(!(Boolean(this.zoneName) && Boolean(this.zoneName.mouse.mid) && Boolean(this.zoneName.mouse.left) && Boolean(this.zoneName.mouse.right)))
{
throw new Error("GuiHud ZONE NAME section is missing parts or they are named incorrectly!");
}
if(!(Boolean(this.chatBar) && Boolean(this.sendChatBtn) && Boolean(this.ansChatBtn) && this.chatTxt))
{
throw new Error("GuiHud CHAT BAR section is missing parts or they are named incorrectly!");
}
if(!(this.chatHist && this.chatHistUpDownBtn && this.chatHistTxt && Boolean(this.chatRepeatBtn) && this.chatRepeatWindow))
{
throw new Error("GuiHud CHAT HISTORY section is missing parts or they are named incorrectly!");
}
if(!(Boolean(this.mainBlock) && Boolean(this.gemsBtnBlock) && Boolean(this.charWindowBlock)))
{
throw new Error("GuiHud BLOCK section is missing parts or they are named incorrectly!");
}
}
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,12 @@
package gui
{
public class GuiNameTypeScreen
{
public function GuiNameTypeScreen()
{
super();
}
}
}
@@ -0,0 +1,106 @@
package gui
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class GuiRadioButtonGroup
{
public var radioButtons:Array;
public var currRadioButton:MovieClip;
private var _selectedRadioButton:DisplayObject;
public function GuiRadioButtonGroup(initCurrRadioButton:MovieClip)
{
var rbdo:DisplayObject = null;
var rbdobc:DisplayObject = null;
super();
this.currRadioButton = initCurrRadioButton;
if(this.currRadioButton.numChildren <= 1)
{
throw new Error("GuiRadioButtonGroup requires two or more radio buttons!");
}
this.radioButtons = [];
var irb:int = 0;
while(irb < this.currRadioButton.numChildren)
{
rbdo = this.currRadioButton.getChildAt(irb);
this.radioButtons.push(rbdo);
if(rbdo is MovieClip)
{
MovieClip(rbdo).stop();
}
rbdo.addEventListener(MouseEvent.CLICK,this.checkBoxClickHandler,false,0,true);
rbdobc = rbdo["_circle"];
rbdobc.visible = false;
if(rbdobc is MovieClip)
{
MovieClip(rbdobc).stop();
}
irb++;
}
}
public function destroy() : void
{
var rbdo:DisplayObject = null;
var irb:int = 0;
while(irb < this.currRadioButton.numChildren)
{
rbdo = this.currRadioButton.getChildAt(irb);
rbdo.removeEventListener(MouseEvent.CLICK,this.checkBoxClickHandler);
irb++;
}
this.radioButtons = null;
}
public function get selected() : int
{
return this.radioButtons.indexOf(this._selectedRadioButton);
}
public function set selected(setSelected:int) : void
{
var ssi:int = 0;
var rbLength:int = int(this.radioButtons.length);
if(setSelected == this.selected || setSelected < 0 || setSelected >= rbLength)
{
return;
}
while(ssi < rbLength)
{
if(ssi != setSelected)
{
this.radioButtons[ssi]["_circle"].visible = false;
}
ssi++;
}
this.setSelectedRadioButton(this.radioButtons[setSelected]);
}
public function reset() : void
{
for(var i:int = 0; i < this.radioButtons.length; i++)
{
this.radioButtons[i]["_circle"].visible = false;
}
this._selectedRadioButton = null;
}
private function setSelectedRadioButton(newSelected:DisplayObject) : void
{
this._selectedRadioButton = newSelected;
this._selectedRadioButton["_circle"].visible = true;
}
private function checkBoxClickHandler(m:MouseEvent) : void
{
this.selected = this.radioButtons.indexOf(m.currentTarget);
m.currentTarget.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
}
}
}
@@ -0,0 +1,123 @@
package gui
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.filters.GlowFilter;
import flash.text.TextField;
public class GuiRadioButtonSingle
{
public var currRadioButton:MovieClip;
public var bg:MovieClip;
public var chkTxt:TextField;
public var circle:MovieClip;
public var grayBg:MovieClip;
private var _selectedRadioButton:DisplayObject;
private var _glow:GlowFilter;
public function GuiRadioButtonSingle(initCurrRadioButton:MovieClip, initChkTxt:TextField = null)
{
super();
this.currRadioButton = initCurrRadioButton;
this.chkTxt = initChkTxt;
this.bg = this.currRadioButton["bg"];
this.circle = this.currRadioButton["_circle"];
this.grayBg = this.currRadioButton["bgGray"];
this.gray = false;
this.circle.visible = false;
this._glow = new GlowFilter(5562619,1,6,6,2,2);
this.currRadioButton.addEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler,false,0,true);
this.currRadioButton.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
this.currRadioButton.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
if(Boolean(this.chkTxt))
{
this.chkTxt.addEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler,false,0,true);
this.chkTxt.addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
this.chkTxt.addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
}
}
public function destroy() : void
{
this.currRadioButton.removeEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler);
this.currRadioButton.removeEventListener(MouseEvent.ROLL_OVER,this.onRollOver);
this.currRadioButton.removeEventListener(MouseEvent.ROLL_OUT,this.onRollOut);
if(Boolean(this.chkTxt))
{
this.chkTxt.removeEventListener(MouseEvent.MOUSE_DOWN,this.checkBoxClickHandler);
this.chkTxt.removeEventListener(MouseEvent.ROLL_OVER,this.onRollOver);
this.chkTxt.removeEventListener(MouseEvent.ROLL_OUT,this.onRollOut);
}
}
public function get gray() : Boolean
{
if(Boolean(this.grayBg))
{
return this.grayBg.visible;
}
return false;
}
public function set gray(setGrayed:Boolean) : void
{
if(Boolean(this.grayBg))
{
this.grayBg.visible = setGrayed;
this.bg.visible = !setGrayed;
this.circle.visible = !setGrayed;
}
}
public function get selected() : Boolean
{
return this.circle.visible;
}
public function set selected(setChecked:Boolean) : void
{
this.circle.visible = setChecked;
}
private function checkBoxClickHandler(m:MouseEvent) : void
{
if(!this.gray)
{
this.selected = !this.selected;
}
}
private function onRollOver(evt:MouseEvent) : void
{
if(!this.gray)
{
this.bg.filters = [this._glow];
if(Boolean(this.chkTxt))
{
this.chkTxt.filters = [this._glow];
}
}
}
private function onRollOut(evt:MouseEvent) : void
{
if(!this.gray)
{
this.bg.filters = null;
if(Boolean(this.chkTxt))
{
this.chkTxt.filters = null;
}
}
}
}
}
@@ -0,0 +1,28 @@
package gui
{
public class GuiSoundBtnSubMenu extends GuiSoundButton
{
public function GuiSoundBtnSubMenu()
{
super();
}
override public function playClickSound() : void
{
if(Boolean(AJAudio))
{
AJAudio.playSubMenuBtnClick();
}
}
override public function playRolloverSound() : void
{
if(Boolean(AJAudio))
{
AJAudio.playSubMenuBtnRollover();
}
}
}
}
@@ -0,0 +1,307 @@
package gui
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class GuiSoundButton extends MovieClip
{
public var mouse:MovieClip;
public var down:MovieClip;
public var gray:MovieClip;
public var glowArrow:MovieClip;
public var glow:MovieClip;
public var hasGrayState:Boolean = false;
public var isGray:Boolean = false;
public var soundsEnabled:Boolean = true;
public var hazMouse:Boolean = false;
public var hasGlowArrowState:Boolean;
public var isGlowArrow:Boolean;
private var _mouseVisibleOnEnableGray:Boolean = true;
private var _toolTip:ToolTipPopup;
private var _useTimer:Boolean = true;
public function GuiSoundButton()
{
super();
this.mouse = this["mouse"];
this.down = this["down"];
this.gray = this["gray"];
this.glowArrow = this["glowArrow"];
this.glow = this["glow"];
if(!this.mouse)
{
throw new Error("GuiSoundButton is missing parts or they are named incorrectly!");
}
this.mouse.stop();
this.mouse.visible = true;
if(Boolean(this.down))
{
this.down.stop();
this.down.visible = false;
}
if(Boolean(this.gray))
{
this.hasGrayState = true;
this.gray.visible = false;
}
if(Boolean(this.glowArrow))
{
this.hasGlowArrowState = true;
this.glowArrow.visible = false;
}
if(Boolean(this.glow))
{
this.glow.visible = false;
}
addEventListener(MouseEvent.MOUSE_DOWN,this.btnDownHandler,false,1,true);
addEventListener(MouseEvent.ROLL_OVER,this.btnOverHandler,false,1,true);
addEventListener(MouseEvent.ROLL_OUT,this.btnOutHandler,false,1,true);
}
public function initToolTip(layer:DisplayObjectContainer, msg:String, xPos:int, yPos:int, shouldUseTimer:Boolean = true) : void
{
if(!this._toolTip)
{
this._toolTip = GETDEFINITIONBYNAME("Tooltip");
}
this._toolTip.init(layer,msg,this.x + xPos,this.y + yPos,shouldUseTimer);
}
public function activateGrayState(yes:Boolean) : void
{
if(yes)
{
if(this.hasGrayState && !this.isGray)
{
this.btnOutHandler(null);
this.isGray = this.gray.visible = true;
this._mouseVisibleOnEnableGray = this.mouse.visible;
this.mouse.visible = false;
if(Boolean(this.down))
{
this.down.visible = false;
}
removeEventListener(MouseEvent.ROLL_OVER,this.btnOverHandler);
removeEventListener(MouseEvent.ROLL_OUT,this.btnOutHandler);
removeEventListener(MouseEvent.MOUSE_DOWN,this.btnDownHandler);
}
}
else if(this.hasGrayState && this.isGray)
{
this.isGray = this.gray.visible = false;
if(this._mouseVisibleOnEnableGray)
{
this.mouse.visible = true;
}
else
{
this.mouse.visible = false;
}
if(Boolean(this.down))
{
this.down.visible = !this.mouse.visible;
}
addEventListener(MouseEvent.ROLL_OVER,this.btnOverHandler,false,1,true);
addEventListener(MouseEvent.ROLL_OUT,this.btnOutHandler,false,1,true);
addEventListener(MouseEvent.MOUSE_DOWN,this.btnDownHandler,false,1,true);
}
}
public function activateGlowArrowState(yes:Boolean) : void
{
if(yes)
{
if(this.hasGlowArrowState)
{
this.isGlowArrow = true;
this.glowArrow.visible = true;
}
}
else if(this.hasGlowArrowState)
{
this.isGlowArrow = false;
this.glowArrow.visible = false;
}
}
public function setButtonState(state:int) : void
{
this.activateGlowArrowState(false);
this.activateGrayState(false);
switch(state)
{
case 0:
if(Boolean(this.glow))
{
this.glow.visible = false;
}
this.activateGrayState(true);
break;
case 1:
break;
case 2:
this.activateGlowArrowState(true);
}
}
public function btnOverHandler(m:MouseEvent) : void
{
this.hazMouse = true;
if(this.mouse.visible)
{
if(this.mouse.hasEventListener(Event.ENTER_FRAME))
{
this.mouse.removeEventListener(Event.ENTER_FRAME,this.pbFrameHandler);
}
this.mouse.gotoAndPlay(1);
if(this.soundsEnabled && m != null)
{
this.playRolloverSound();
}
if(Boolean(this._toolTip) && this._toolTip.enabled)
{
this._toolTip.startTimer(m);
this._toolTip.bringToolToFront();
}
}
}
public function btnOutHandler(m:MouseEvent) : void
{
this.hazMouse = false;
if(this.mouse.visible)
{
if(this.mouse.currentFrame > 1)
{
this.playBackwards(this.mouse);
}
else
{
this.mouse.stop();
}
if(Boolean(this._toolTip) && Boolean(this._toolTip.toolTipTimer) && this._toolTip.isTimerRunning())
{
this._toolTip.resetTimerAndSetVisibility();
}
else if(Boolean(this._toolTip))
{
this._toolTip.visible = false;
}
}
}
public function btnDownHandler(m:MouseEvent) : void
{
if(this.isGray)
{
if(Boolean(m))
{
m.stopPropagation();
}
return;
}
if(Boolean(this.down) && !this.down.visible)
{
this.down.visible = true;
this.mouse.visible = false;
}
else
{
this.mouse.visible = true;
this.mouse.gotoAndPlay(1);
if(Boolean(this.down))
{
this.down.visible = false;
}
}
if(this.soundsEnabled && m != null)
{
this.playClickSound();
}
if(Boolean(this._toolTip) && Boolean(this._toolTip.toolTipTimer) && this._toolTip.isTimerRunning())
{
this._toolTip.resetTimerAndSetVisibility();
}
else if(Boolean(this._toolTip))
{
this._toolTip.visible = false;
}
this.downToUpState();
}
public function setTimer(bool:Boolean) : void
{
this._useTimer = bool;
}
private function playBackwards(mc:MovieClip) : void
{
mc.addEventListener(Event.ENTER_FRAME,this.pbFrameHandler,false,0,true);
}
private function pbFrameHandler(e:Event) : void
{
var mch:MovieClip = null;
if(Boolean(e.target as MovieClip))
{
mch = MovieClip(e.target);
if(mch.currentFrame == 1)
{
mch.removeEventListener(Event.ENTER_FRAME,this.pbFrameHandler);
return;
}
mch.prevFrame();
}
}
public function downToUpState() : void
{
if(Boolean(this.down))
{
this.down.visible = false;
}
this.mouse.visible = true;
this.mouse.gotoAndStop(1);
if(this.hazMouse)
{
this.btnOverHandler(null);
}
}
public function upToDownState() : void
{
if(Boolean(this.down) && !this.down.visible)
{
this.down.visible = true;
this.mouse.visible = false;
}
}
public function playClickSound() : void
{
AJAudio.playHudBtnClick();
}
public function playRolloverSound() : void
{
AJAudio.playHudBtnRollover();
}
}
}
@@ -0,0 +1,453 @@
package gui
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class GuiSoundToggleButton extends MovieClip
{
public var mouse:MovieClip;
public var down:MovieClip;
public var gray:MovieClip;
public var glowArrow:MovieClip;
public var glow:MovieClip;
public var hasGrayState:Boolean = false;
public var isGray:Boolean = false;
public var soundsEnabled:Boolean = true;
public var clickQueued:Boolean = false;
public var hazMouse:Boolean = false;
public var hasGlowArrowState:Boolean;
public var isGlowArrow:Boolean;
private var _mouseVisibleOnEnableGray:Boolean = true;
private var _pulseForward:Boolean = true;
private var _pulseExtraFrames:int = 0;
private var _repetitions:int = 0;
private var _toolTip:ToolTipPopup;
private var _useTimer:Boolean = true;
public function GuiSoundToggleButton()
{
super();
this.mouse = this["mouse"];
this.down = this["down"];
this.gray = this["gray"];
this.glowArrow = this["glowArrow"];
this.glow = this["glow"];
if(!this.mouse)
{
throw new Error("GuiSoundToggleButton is missing parts or they are named incorrectly!");
}
this.mouse.stop();
this.mouse.visible = true;
if(Boolean(this.down))
{
this.down.stop();
this.down.visible = false;
}
if(Boolean(this.gray))
{
this.hasGrayState = true;
this.gray.visible = false;
}
if(Boolean(this.glowArrow))
{
this.hasGlowArrowState = true;
this.glowArrow.visible = false;
}
if(Boolean(this.glow))
{
this.glow.visible = false;
}
addEventListener(MouseEvent.MOUSE_DOWN,this.btnDownHandler,false,1,true);
addEventListener(MouseEvent.ROLL_OVER,this.btnOverHandler,false,1,true);
addEventListener(MouseEvent.ROLL_OUT,this.btnOutHandler,false,1,true);
}
public function initToolTip(layer:DisplayObjectContainer, msg:String, xPos:int, yPos:int, shouldUseTimer:Boolean = true) : void
{
if(!this._toolTip)
{
this._toolTip = GETDEFINITIONBYNAME("Tooltip");
}
this._toolTip.init(layer,msg,this.x + xPos,this.y + yPos,shouldUseTimer);
}
public function activateGrayState(yes:Boolean) : void
{
if(yes)
{
if(this.hasGrayState && !this.isGray)
{
this.isGray = this.gray.visible = true;
this._mouseVisibleOnEnableGray = this.mouse.visible;
this.mouse.visible = false;
if(Boolean(this.down))
{
this.down.visible = false;
}
removeEventListener(MouseEvent.ROLL_OVER,this.btnOverHandler);
removeEventListener(MouseEvent.ROLL_OUT,this.btnOutHandler);
removeEventListener(MouseEvent.MOUSE_DOWN,this.btnDownHandler);
}
}
else if(this.hasGrayState && this.isGray)
{
this.isGray = this.gray.visible = false;
if(this._mouseVisibleOnEnableGray)
{
this.mouse.visible = true;
}
else
{
this.mouse.visible = false;
}
if(Boolean(this.down))
{
this.down.visible = !this.mouse.visible;
}
addEventListener(MouseEvent.ROLL_OVER,this.btnOverHandler,false,1,true);
addEventListener(MouseEvent.ROLL_OUT,this.btnOutHandler,false,1,true);
addEventListener(MouseEvent.MOUSE_DOWN,this.btnDownHandler,false,1,true);
}
}
public function activateGlowArrowState(yes:Boolean) : void
{
if(yes)
{
if(this.hasGlowArrowState)
{
this.isGlowArrow = true;
this.glowArrow.visible = true;
}
}
else if(this.hasGlowArrowState)
{
this.isGlowArrow = false;
this.glowArrow.visible = false;
}
}
public function setButtonState(state:int) : void
{
this.activateGlowArrowState(false);
this.activateGrayState(false);
switch(state)
{
case 0:
if(Boolean(this.glow))
{
this.glow.visible = false;
}
this.activateGrayState(true);
break;
case 1:
break;
case 2:
this.activateGlowArrowState(true);
}
}
public function pulseButton(status:Boolean, repetitions:int = -1) : void
{
if(status)
{
this.mouse.addEventListener(Event.ENTER_FRAME,this.pulseFrameHandler,false,0,true);
this._repetitions = repetitions;
}
else
{
this.mouse.removeEventListener(Event.ENTER_FRAME,this.pulseFrameHandler);
this._repetitions = 0;
}
}
private function pulseFrameHandler(evt:Event) : void
{
var mch:MovieClip = MovieClip(evt.target);
if(this._repetitions > 0)
{
if(this._pulseForward && mch.currentFrame <= mch.totalFrames - 1)
{
if(this._pulseExtraFrames > 10)
{
mch.nextFrame();
}
else
{
++this._pulseExtraFrames;
}
if(mch.currentFrame == mch.totalFrames)
{
--this._repetitions;
this._pulseForward = false;
this._pulseExtraFrames = 0;
}
}
else if(this._pulseExtraFrames >= 10)
{
mch.prevFrame();
if(mch.currentFrame == 1)
{
--this._repetitions;
this._pulseForward = true;
this._pulseExtraFrames = 0;
}
}
else
{
++this._pulseExtraFrames;
}
}
else if(this._repetitions == -1)
{
if(this._pulseForward && mch.currentFrame <= mch.totalFrames - 1)
{
if(this._pulseExtraFrames > 10)
{
mch.nextFrame();
}
else
{
++this._pulseExtraFrames;
}
if(mch.currentFrame == mch.totalFrames)
{
this._pulseForward = false;
this._pulseExtraFrames = 0;
}
}
else if(this._pulseExtraFrames >= 10)
{
mch.prevFrame();
if(mch.currentFrame == 1)
{
this._pulseForward = true;
this._pulseExtraFrames = 0;
}
}
else
{
++this._pulseExtraFrames;
}
}
else
{
this.mouse.removeEventListener(Event.ENTER_FRAME,this.pulseFrameHandler);
}
}
private function btnOverHandler(m:MouseEvent) : void
{
this.hazMouse = true;
if(this.mouse.visible)
{
if(this.mouse.hasEventListener(Event.ENTER_FRAME))
{
this.mouse.removeEventListener(Event.ENTER_FRAME,this.pbFrameHandler);
}
this.mouse.gotoAndPlay(1);
if(this.soundsEnabled && m != null)
{
this.playRolloverSound();
}
if(Boolean(this._toolTip) && this._toolTip.enabled)
{
this._toolTip.startTimer(m);
this._toolTip.bringToolToFront();
}
}
}
private function btnOutHandler(m:MouseEvent) : void
{
this.hazMouse = false;
if(this.mouse.visible)
{
if(this.mouse.currentFrame > 1)
{
this.playBackwards(this.mouse);
}
else
{
this.mouse.stop();
}
if(Boolean(this._toolTip) && Boolean(this._toolTip.toolTipTimer) && this._toolTip.isTimerRunning())
{
this._toolTip.resetTimerAndSetVisibility();
}
else if(Boolean(this._toolTip))
{
this._toolTip.visible = false;
}
}
}
private function btnDownHandler(m:MouseEvent) : void
{
if(this.isGray)
{
if(Boolean(m))
{
m.stopPropagation();
}
return;
}
if(Boolean(this.down) && !this.down.visible)
{
this.down.visible = true;
this.mouse.visible = false;
}
else
{
this.mouse.visible = true;
this.mouse.gotoAndPlay(1);
if(Boolean(this.down))
{
this.down.visible = false;
}
}
if(this.soundsEnabled && m != null)
{
this.playClickSound();
}
if(Boolean(this._toolTip) && Boolean(this._toolTip.toolTipTimer) && this._toolTip.isTimerRunning())
{
this._toolTip.resetTimerAndSetVisibility();
}
else if(Boolean(this._toolTip))
{
this._toolTip.visible = false;
}
}
public function setTimer(bool:Boolean) : void
{
this._useTimer = bool;
}
private function selWatcher(e:Event) : void
{
var mu:MovieClip = null;
if(Boolean(e.target as MovieClip))
{
mu = MovieClip(e.target);
if(mu.currentFrame == mu.totalFrames)
{
if(this.hazMouse)
{
this.mouse.gotoAndPlay(1);
}
else
{
this.mouse.gotoAndStop(1);
}
this.mouse.visible = true;
mu.gotoAndStop(1);
mu.visible = false;
mu.removeEventListener(Event.ENTER_FRAME,this.selWatcher);
}
}
}
private function queueClick(mc:MovieClip) : void
{
this.clickQueued = true;
mc.addEventListener(Event.ENTER_FRAME,this.qcFrameHandler,false,0,true);
}
private function queueClickCallback() : void
{
if(!this.down.visible)
{
this.down.visible = true;
this.mouse.visible = false;
}
this.down.gotoAndPlay(1);
}
private function qcFrameHandler(e:Event) : void
{
var mch:MovieClip = null;
if(this.clickQueued && Boolean(e.target as MovieClip))
{
mch = MovieClip(e.target);
if(mch.currentFrame == mch.totalFrames)
{
this.clickQueued = false;
this.queueClickCallback();
mch.removeEventListener(Event.ENTER_FRAME,this.qcFrameHandler);
}
}
}
private function playBackwards(mc:MovieClip) : void
{
mc.addEventListener(Event.ENTER_FRAME,this.pbFrameHandler,false,0,true);
}
private function pbFrameHandler(e:Event) : void
{
var mch:MovieClip = null;
if(Boolean(e.target as MovieClip))
{
mch = MovieClip(e.target);
if(mch.currentFrame == 1)
{
mch.removeEventListener(Event.ENTER_FRAME,this.pbFrameHandler);
return;
}
mch.prevFrame();
}
}
public function downToUpState() : void
{
if(Boolean(this.down))
{
this.down.visible = false;
}
this.mouse.visible = true;
this.mouse.gotoAndStop(1);
}
public function upToDownState() : void
{
if(Boolean(this.down) && !this.down.visible)
{
this.down.visible = true;
this.mouse.visible = false;
}
}
public function playClickSound() : void
{
AJAudio.playHudBtnClick();
}
public function playRolloverSound() : void
{
AJAudio.playHudBtnRollover();
}
}
}
@@ -0,0 +1,88 @@
package gui
{
import flash.display.MovieClip;
public class GuiStatusIcon
{
public function GuiStatusIcon()
{
super();
}
public static function initClip(statusIcon:MovieClip, trackingObject:Object = null) : void
{
statusIcon.visible = false;
statusIcon["_x"].visible = false;
statusIcon["_wait"].visible = true;
statusIcon["_check"].visible = false;
if(Boolean(trackingObject))
{
trackingObject.xTracking = false;
trackingObject.waitTracking = true;
trackingObject.checkTracking = false;
}
}
public static function initClipOff(statusIcon:MovieClip, trackingObject:Object = null) : void
{
statusIcon.visible = false;
statusIcon["_x"].visible = false;
statusIcon["_wait"].visible = false;
statusIcon["_check"].visible = false;
if(Boolean(trackingObject))
{
trackingObject.xTracking = false;
trackingObject.waitTracking = false;
trackingObject.checkTracking = false;
}
}
public static function setVisBasedOnTrackers(statusIcon:MovieClip, trackingObject:Object = null) : void
{
statusIcon["_x"].visible = trackingObject.xTracking;
statusIcon["_wait"].visible = trackingObject.waitTracking;
statusIcon["_check"].visible = trackingObject.checkTracking;
}
public static function showX(statusIcon:MovieClip, trackingObject:Object = null) : void
{
statusIcon["_x"].visible = true;
statusIcon["_wait"].visible = false;
statusIcon["_check"].visible = false;
if(Boolean(trackingObject))
{
trackingObject.xTracking = true;
trackingObject.waitTracking = false;
trackingObject.checkTracking = false;
}
}
public static function showWait(statusIcon:MovieClip, trackingObject:Object = null) : void
{
statusIcon["_x"].visible = false;
statusIcon["_wait"].visible = true;
statusIcon["_check"].visible = false;
if(Boolean(trackingObject))
{
trackingObject.xTracking = false;
trackingObject.waitTracking = true;
trackingObject.checkTracking = false;
}
}
public static function showCheck(statusIcon:MovieClip, trackingObject:Object = null) : void
{
statusIcon["_x"].visible = false;
statusIcon["_wait"].visible = false;
statusIcon["_check"].visible = true;
if(Boolean(trackingObject))
{
trackingObject.xTracking = false;
trackingObject.waitTracking = false;
trackingObject.checkTracking = true;
}
}
}
}
@@ -0,0 +1,230 @@
package gui
{
import achievement.AchievementXtCommManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;
import loader.MediaHelper;
import localization.LocalizationManager;
import movie.MovieManager;
public class ImageDisplayPopup
{
private const POPUP_MEDIA_ID:int = 2418;
private const IMAGES_LIST_ID:int = 182;
private var _guiLayer:DisplayLayer;
private var _popupMediaHelper:MediaHelper;
private var _popup:MovieClip;
private var _loadingSpiral:LoadingSpiral;
private var _imageIds:Array;
private var _mediaIndex:int;
private var _imageMediaHelper:MediaHelper;
private var _itemWindow:MovieClip;
private var _locStrs:Array;
private var _closeCallback:Function;
private var _tutorialStreamId:int;
private var _tutorialSubtitleId:int;
private var _tutorialText:String;
private var _userVarIdToCheck:int;
private var _videoGenericListId:int;
public function ImageDisplayPopup(closeCallback:Function, videoGenericListId:int, userVarIdToCheck:int)
{
super();
DarkenManager.showLoadingSpiral(true);
this._closeCallback = closeCallback;
this._guiLayer = GuiManager.guiLayer;
this._userVarIdToCheck = userVarIdToCheck;
this._videoGenericListId = videoGenericListId;
this._popupMediaHelper = new MediaHelper();
this._popupMediaHelper.init(this.POPUP_MEDIA_ID,this.onMediaLoaded);
}
public function destroy() : void
{
DarkenManager.unDarken(this._popup);
this._guiLayer.removeChild(this._popup);
if(Boolean(this._popupMediaHelper))
{
this._popupMediaHelper.destroy();
this._popupMediaHelper = null;
}
if(Boolean(this._imageMediaHelper))
{
this._imageMediaHelper.destroy();
this._imageMediaHelper = null;
}
if(Boolean(this._loadingSpiral))
{
this._loadingSpiral.destroy();
this._loadingSpiral = null;
}
this.removeEventListeners();
this._popup = null;
this._closeCallback = null;
}
private function onMediaLoaded(img:MovieClip) : void
{
this._popup = img.getChildAt(0) as MovieClip;
this._popup.info.visible = false;
this._popup.darkBg.visible = false;
this._itemWindow = this._popup.greatNatureProject.itemWindow;
this._loadingSpiral = new LoadingSpiral(this._itemWindow);
this._imageMediaHelper = new MediaHelper();
this._popup.x = MainFrame.VIEW_WIDTH * 0.5;
this._popup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._popup.greatNatureProject.artistName.autoSize = TextFieldAutoSize.RIGHT;
GenericListXtCommManager.requestStreamList(this._videoGenericListId,this.onTutorialGLReceived);
GenericListXtCommManager.requestGenericList(this.IMAGES_LIST_ID,this.onImagesListReceived);
this.addEventListeners();
DarkenManager.showLoadingSpiral(false);
this._guiLayer.addChild(this._popup);
DarkenManager.darken(this._popup);
}
private function onImagesListReceived(glId:int, mediaIds:Array, locStrs:Array) : void
{
this._imageIds = mediaIds;
this._locStrs = locStrs;
this.loadImage(null);
}
private function onTutorialGLReceived(glId:int, streamIds:Array, thumbIds:Array, baseTitles:Array, indivTitles:Array, statusIds:Array, baseSubtitles:Array) : void
{
this._tutorialStreamId = streamIds[0];
this._tutorialText = baseTitles[0];
this._tutorialSubtitleId = baseSubtitles[0];
if(gMainFrame.userInfo.userVarCache.getUserVarValueById(this._userVarIdToCheck) < 0)
{
this.onInfo(null);
AchievementXtCommManager.requestSetUserVar(this._userVarIdToCheck,1);
}
}
private function loadImage(evt:MouseEvent) : void
{
if(Boolean(this._popup))
{
this._loadingSpiral.visible = true;
if(Boolean(evt))
{
if(evt.currentTarget == this._popup.greatNatureProject.lArrow)
{
if(--this._mediaIndex < 0)
{
this._mediaIndex = this._imageIds.length - 1;
}
}
else if(evt.currentTarget == this._popup.greatNatureProject.rArrow)
{
if(++this._mediaIndex > this._imageIds.length - 1)
{
this._mediaIndex = 0;
}
}
}
this._popup.greatNatureProject.lArrow.activateGrayState(true);
this._popup.greatNatureProject.rArrow.activateGrayState(true);
LocalizationManager.translateId(this._popup.greatNatureProject.artistName,this._locStrs[this._mediaIndex]);
this._popup.greatNatureProject.photoCredit.x = this._popup.greatNatureProject.artistName.x - this._popup.greatNatureProject.photoCredit.width - 2;
this._imageMediaHelper.init(this._imageIds[this._mediaIndex],this.onImageLoaded);
}
}
private function onImageLoaded(img:MovieClip) : void
{
if(Boolean(this._popup))
{
while(this._itemWindow.numChildren > 0)
{
this._itemWindow.removeChildAt(0);
}
this._itemWindow.addChild(img);
this._loadingSpiral.visible = false;
this._popup.greatNatureProject.lArrow.activateGrayState(false);
this._popup.greatNatureProject.rArrow.activateGrayState(false);
}
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onArrow(evt:MouseEvent) : void
{
evt.stopPropagation();
this.loadImage(evt);
}
private function onInfo(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
DarkenManager.showLoadingSpiral(true);
GuiManager.initMoviePlayer(MovieManager.VID_PLAYER_MEDIA_ID,[this._tutorialStreamId],[this._tutorialText],[this._tutorialSubtitleId],false);
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget == this._popup.info.xBtn)
{
this._popup.darkBg.visible = false;
this._popup.info.visible = false;
}
else if(evt.currentTarget == this._popup.greatNatureProject.xBtn)
{
if(this._closeCallback != null)
{
this._closeCallback();
}
else
{
this.destroy();
}
}
}
private function addEventListeners() : void
{
this._popup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._popup.greatNatureProject.lArrow.addEventListener(MouseEvent.MOUSE_DOWN,this.onArrow,false,0,true);
this._popup.greatNatureProject.rArrow.addEventListener(MouseEvent.MOUSE_DOWN,this.onArrow,false,0,true);
this._popup.greatNatureProject.infoBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onInfo,false,0,true);
this._popup.greatNatureProject.xBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
this._popup.info.xBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
private function removeEventListeners() : void
{
this._popup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._popup.greatNatureProject.lArrow.removeEventListener(MouseEvent.MOUSE_DOWN,this.onArrow);
this._popup.greatNatureProject.rArrow.removeEventListener(MouseEvent.MOUSE_DOWN,this.onArrow);
this._popup.greatNatureProject.infoBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onInfo);
this._popup.greatNatureProject.xBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._popup.info.xBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
}
}
@@ -0,0 +1,417 @@
package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import localization.LocalizationManager;
public class ImagePoll
{
private static var _guiLayer:DisplayLayer;
private static var _mediaHelper:MediaHelper;
private static var _imgPopup:MovieClip;
private static var _pollTab:MovieClip;
private static var _closeCallback:Function;
private static var _spirals:Array;
private static var _mediaIds:Array;
private static var _randOptionLookup:Array;
private static var _locStrings:Array;
private static var _mediaHolder:Array;
private static var _checkedItems:Array;
private static var _itemImages:Array;
private static var _numAllowedVotes:int;
private static var _pollUserVardId:int;
private static var _numImageWindow:int;
private static var _pollPopupMediaId:int;
public static const TSHIRT_VAR_ID:int = 312;
public static const DEN_ITEM_VOTING_VAR_ID:int = 374;
public static const TSHIRT_IMAGES_MEDIA_ID:int = 76;
public static const POLL_MEDIA_ID:int = 1355;
public static const DEN_POLL_MEDIA_ID:int = 2926;
public function ImagePoll()
{
super();
}
public static function displayPoll(pollUserVarId:int, pollPopupMediaId:int, pollMediaListId:int, numImageWindows:int, numAllowedVotes:int, pollTab:MovieClip = null, closeCallback:Function = null) : void
{
if(gMainFrame.userInfo.userVarCache.getUserVarValueById(pollUserVarId) < 0)
{
DarkenManager.showLoadingSpiral(true);
_spirals = [];
_checkedItems = [];
_guiLayer = GuiManager.guiLayer;
_pollPopupMediaId = pollPopupMediaId;
_numImageWindow = numImageWindows;
_numAllowedVotes = numAllowedVotes;
_pollUserVardId = pollUserVarId;
_pollTab = pollTab;
_closeCallback = closeCallback;
if(pollMediaListId != 0)
{
GenericListXtCommManager.requestGenericList(pollMediaListId,onMediaListReceived);
}
else
{
onMediaListReceived(0,null,null);
}
}
else
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18821));
}
}
public static function destroy(isDueToAVote:Boolean) : void
{
for(var i:int = 0; i < _mediaHolder.length; i++)
{
if(Boolean(_mediaHolder[i]))
{
_mediaHolder[i].destroy();
}
if(Boolean(_spirals[i]))
{
_spirals[i].destroy();
}
}
removeListeners();
DarkenManager.unDarken(_imgPopup);
_guiLayer.removeChild(_imgPopup);
if(isDueToAVote)
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18821));
}
}
private static function onMediaListReceived(glId:int, mediaIds:Array, locStrs:Array) : void
{
if(Boolean(_mediaIds))
{
_mediaIds = mediaIds;
_randOptionLookup = [0,1,2,3,4,5,6,7,8,9];
_locStrings = locStrs;
_mediaIds = shuffleArray(_mediaIds);
}
_mediaHelper = new MediaHelper();
_mediaHelper.init(_pollPopupMediaId,onMediaReceived,true);
}
private static function onMediaReceived(mc:MovieClip) : void
{
var currItem:Object = null;
var i:int = 0;
var currImage:Object = null;
if(Boolean(mc))
{
if(mc.mediaHelper.id == _pollPopupMediaId)
{
DarkenManager.showLoadingSpiral(false);
_imgPopup = MovieClip(mc.getChildAt(0));
_imgPopup.x = MainFrame.VIEW_WIDTH * 0.5;
_imgPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
_imgPopup.imageViewerPopup.visible = false;
_imgPopup.scrim.visible = false;
if(Boolean(_imgPopup.doneBtn.hasGrayState))
{
_imgPopup.doneBtn.activateGrayState(true);
}
_mediaHelper.destroy();
_mediaHelper = null;
_mediaHolder = [];
_itemImages = [];
for(i = 0; i < _numImageWindow; i++)
{
currItem = _imgPopup["pollItem" + i];
currItem.index = i;
currItem.ItemHL.itemSelectedHL.visible = false;
currItem.ItemHL.mouseOverHL.gotoAndStop("out");
currItem.checkbox.checkmark.visible = false;
currItem.checkbox.mouse.visible = false;
if(Boolean(_mediaIds))
{
_spirals[i] = new LoadingSpiral(currItem.itemBlock);
_mediaHelper = new MediaHelper();
_mediaHelper.init(_mediaIds[i],onMediaReceived,i);
_mediaHolder.push(_mediaHelper);
_mediaHelper = new MediaHelper();
_mediaHelper.init(_mediaIds[i],onMediaReceived,i + 10);
_mediaHolder.push(_mediaHelper);
}
}
_guiLayer.addChild(_imgPopup);
DarkenManager.darken(_imgPopup);
addListeners();
}
else
{
currImage = mc.getChildAt(0);
_itemImages[mc.passback] = currImage;
if(mc.passback < _numImageWindow)
{
_spirals[mc.passback].destroy();
_imgPopup["pollItem" + mc.passback].itemBlock.addChild(currImage);
}
}
}
}
private static function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private static function onClose(evt:MouseEvent) : void
{
var bitsSet:int = 0;
var i:int = 0;
evt.stopPropagation();
if(!evt.currentTarget.isGray)
{
if(evt.currentTarget.name == "doneBtn")
{
for(i = 0; i < _checkedItems.length; i++)
{
if(_checkedItems[i] != null)
{
if(Boolean(_randOptionLookup))
{
bitsSet |= 1 << _randOptionLookup[_checkedItems[i]];
}
else
{
bitsSet |= 1 << _checkedItems[i];
}
}
}
AchievementXtCommManager.requestSetUserVar(_pollUserVardId,bitsSet);
if(_closeCallback != null)
{
_closeCallback(_pollTab);
_closeCallback = null;
}
}
else if(_closeCallback != null)
{
SBTracker.pop();
}
destroy(evt.currentTarget.name == "doneBtn");
}
}
private static function onItemOut(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.ItemHL.mouseOverHL.currentFrameLabel != "out")
{
evt.currentTarget.ItemHL.mouseOverHL.gotoAndStop("out");
}
}
private static function onItemOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.ItemHL.mouseOverHL.currentFrameLabel != "over")
{
evt.currentTarget.ItemHL.mouseOverHL.gotoAndStop("over");
}
}
private static function onCheckOut(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.mouse.visible = !evt.currentTarget.mouse.visible;
}
private static function onCheckOver(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.mouse.visible = !evt.currentTarget.mouse.visible;
}
private static function onCheckOrVote(evt:MouseEvent) : void
{
var currIndex:int = 0;
var addCheckBox:Boolean = false;
var unselectIndex:int = 0;
evt.stopPropagation();
if(evt.currentTarget.name == "checkbox")
{
evt.currentTarget.checkmark.visible = addCheckBox = !evt.currentTarget.checkmark.visible;
currIndex = int(evt.currentTarget.parent.index);
}
else
{
currIndex = int(evt.currentTarget.parent.currPollIndex);
_imgPopup["pollItem" + currIndex].checkbox.checkmark.visible = addCheckBox = !_imgPopup["pollItem" + currIndex].checkbox.checkmark.visible;
}
if(addCheckBox)
{
_checkedItems.push(currIndex);
if(_checkedItems.length > _numAllowedVotes)
{
unselectIndex = int(_checkedItems[0]);
_checkedItems.shift();
_imgPopup["pollItem" + unselectIndex].checkbox.checkmark.visible = false;
_imgPopup["pollItem" + unselectIndex].ItemHL.itemSelectedHL.visible = false;
}
if(_checkedItems.length > 0)
{
if(Boolean(_imgPopup.doneBtn.hasGrayState) && Boolean(_imgPopup.doneBtn.isGray))
{
_imgPopup.doneBtn.activateGrayState(false);
}
}
}
else
{
_checkedItems.splice(_checkedItems.indexOf(currIndex),1);
if(Boolean(_imgPopup.doneBtn.hasGrayState) && Boolean(!_imgPopup.doneBtn.isGray) && _checkedItems.length == 0)
{
_imgPopup.doneBtn.activateGrayState(true);
}
}
_imgPopup["pollItem" + currIndex].ItemHL.itemSelectedHL.visible = addCheckBox;
if(evt.currentTarget.name != "checkbox")
{
_imgPopup.imageViewerPopup.visible = false;
_imgPopup.scrim.visible = false;
}
}
private static function onItemZoom(evt:MouseEvent) : void
{
var imgToAdd:MovieClip = null;
evt.stopPropagation();
_imgPopup.imageViewerPopup.visible = true;
_imgPopup.scrim.visible = true;
if(_imgPopup.imageViewerPopup.currentLabels.length < 1)
{
while(_imgPopup.imageViewerPopup.itemBlock.numChildren > 0)
{
_imgPopup.imageViewerPopup.itemBlock.removeChildAt(0);
}
}
var currIndex:int = evt.currentTarget.name == "zoomBtn" ? int(evt.currentTarget.parent.index) : int(evt.currentTarget.index);
if(Boolean(_itemImages))
{
imgToAdd = _itemImages[currIndex + 10];
if(imgToAdd != null)
{
imgToAdd.gotoAndStop("large");
_imgPopup.imageViewerPopup.itemBlock.addChild(imgToAdd);
}
}
if(Boolean(_locStrings))
{
_imgPopup.imageViewerPopup.titleTxt.text = _locStrings[_randOptionLookup[currIndex]];
}
if(_imgPopup.imageViewerPopup.currentLabels.length > 1)
{
_imgPopup.imageViewerPopup.gotoAndStop("pollItem" + currIndex);
_imgPopup.imageViewerPopup.titleTxt.text = _imgPopup["pollItem" + currIndex].titleTxt.text;
}
_imgPopup.imageViewerPopup.currPollIndex = currIndex;
}
private static function onCloseViewer(evt:MouseEvent) : void
{
evt.stopPropagation();
_imgPopup.imageViewerPopup.visible = false;
_imgPopup.scrim.visible = false;
}
private static function shuffleArray(a:Array) : Array
{
var element:String = null;
var i:int = 0;
var rand:int = 0;
var save:int = 0;
var length:int = int(a.length);
var shuffled:Array = a.slice();
while(i < length)
{
element = shuffled[i];
rand = Math.floor(Math.random() * length);
if(i != rand)
{
shuffled[i] = shuffled[rand];
shuffled[rand] = element;
save = int(_randOptionLookup[i]);
_randOptionLookup[i] = _randOptionLookup[rand];
_randOptionLookup[rand] = save;
}
i++;
}
return shuffled;
}
private static function addListeners() : void
{
var currItem:Object = null;
_imgPopup.addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
_imgPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,onClose,false,0,true);
_imgPopup.doneBtn.addEventListener(MouseEvent.MOUSE_DOWN,onClose,false,0,true);
for(var i:int = 0; i < _numImageWindow; i++)
{
currItem = _imgPopup["pollItem" + i];
currItem.addEventListener(MouseEvent.MOUSE_OUT,onItemOut,false,0,true);
currItem.addEventListener(MouseEvent.MOUSE_OVER,onItemOver,false,0,true);
currItem.addEventListener(MouseEvent.MOUSE_DOWN,onItemZoom,false,0,true);
currItem.zoomBtn.addEventListener(MouseEvent.MOUSE_DOWN,onItemZoom,false,0,true);
currItem.checkbox.addEventListener(MouseEvent.ROLL_OVER,onCheckOver,false,0,true);
currItem.checkbox.addEventListener(MouseEvent.ROLL_OUT,onCheckOut,false,0,true);
currItem.checkbox.addEventListener(MouseEvent.MOUSE_DOWN,onCheckOrVote,false,0,true);
}
_imgPopup.imageViewerPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,onCloseViewer,false,0,true);
_imgPopup.imageViewerPopup.voteBtn.addEventListener(MouseEvent.MOUSE_DOWN,onCheckOrVote,false,0,true);
}
private static function removeListeners() : void
{
var currItem:Object = null;
_imgPopup.removeEventListener(MouseEvent.MOUSE_DOWN,onPopup);
_imgPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,onClose);
_imgPopup.doneBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onClose);
for(var i:int = 0; i < _numImageWindow; i++)
{
currItem = _imgPopup["pollItem" + i];
currItem.removeEventListener(MouseEvent.MOUSE_OUT,onItemOut);
currItem.removeEventListener(MouseEvent.MOUSE_OVER,onItemOver);
currItem.removeEventListener(MouseEvent.MOUSE_DOWN,onItemZoom);
currItem.zoomBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onItemZoom);
currItem.checkbox.removeEventListener(MouseEvent.ROLL_OVER,onCheckOver);
currItem.checkbox.removeEventListener(MouseEvent.ROLL_OUT,onCheckOut);
currItem.checkbox.removeEventListener(MouseEvent.MOUSE_DOWN,onCheckOrVote);
}
_imgPopup.imageViewerPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,onCloseViewer);
_imgPopup.imageViewerPopup.voteBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onCheckOrVote);
}
}
}
@@ -0,0 +1,334 @@
package gui
{
import com.sbi.popup.SBPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import localization.LocalizationManager;
public class InstructionScreenBuilder
{
public static var guiLayer:DisplayLayer;
public static var instrScreenContent:MovieClip;
public static var instrInfo:Object;
public static var instrObjs:Object;
public static var numScreens:uint;
public static var currScreen:uint;
public static var instrPopup:SBPopup;
private static var _joinGamePopup:SBPopup;
private static var _killJoinGamePopup:Boolean;
private static var _startGameFunction:Function;
public function InstructionScreenBuilder()
{
super();
}
public static function init(initGuiLayer:DisplayLayer) : void
{
guiLayer = initGuiLayer;
instrScreenContent = GETDEFINITIONBYNAME("InstructionsContent");
instrScreenContent.backBtn.addEventListener(MouseEvent.MOUSE_DOWN,backHandler,false,0,true);
instrScreenContent.backToMainBtn.addEventListener(MouseEvent.MOUSE_DOWN,backBtnHandlerOnFirstScreen,false,0,true);
instrScreenContent.nextBtn.addEventListener(MouseEvent.MOUSE_DOWN,nextHandler,false,0,true);
instrObjs = new Object();
var instrObj:Object = instrObjs["Pachinko"] = new Object();
instrObj.name = 11284;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11285;
instrObj.instrTxts[1] = 11286;
instrObj = instrObjs["MiniGame_Memory"] = new Object();
instrObj.name = 11287;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11288;
instrObj.instrTxts[1] = 11289;
instrObj = instrObjs["MoatMadness"] = new Object();
instrObj.name = 11290;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11291;
instrObj.instrTxts[1] = 11292;
instrObj = instrObjs["ParachuteGlider"] = new Object();
instrObj.name = 11293;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11294;
instrObj.instrTxts[1] = 11295;
instrObj = instrObjs["QuestParachuteGlider"] = new Object();
instrObj.name = 11293;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11294;
instrObj.instrTxts[1] = 11295;
instrObj = instrObjs["Trivia"] = new Object();
instrObj.name = 11299;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11297;
instrObj.instrTxts[1] = 11298;
instrObj = instrObjs["PhantomFighter"] = new Object();
instrObj.name = 11300;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11301;
instrObj.instrTxts[1] = 11302;
instrObj = instrObjs["SpiderShooter"] = new Object();
instrObj.name = 11303;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11304;
instrObj.instrTxts[1] = 11305;
instrObj = instrObjs["RiverRace"] = new Object();
instrObj.name = 11306;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11307;
instrObj.instrTxts[1] = 11308;
instrObj = instrObjs["WindRider"] = new Object();
instrObj.name = 11309;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11310;
instrObj.instrTxts[1] = 11311;
instrObj = instrObjs["DistanceChallenge"] = new Object();
instrObj.name = 11312;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11313;
instrObj.instrTxts[1] = 11314;
instrObj = instrObjs["Twister"] = new Object();
instrObj.name = 11315;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11316;
instrObj.instrTxts[1] = 11317;
instrObj = instrObjs["MicroMiraSays"] = new Object();
instrObj.name = 11318;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11319;
instrObj.instrTxts[1] = 11320;
instrObj = instrObjs["GemBreaker"] = new Object();
instrObj.name = 11321;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11322;
instrObj.instrTxts[1] = 11323;
instrObj = instrObjs["SuperSort"] = new Object();
instrObj.name = 11324;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11325;
instrObj.instrTxts[1] = 11326;
instrObj = instrObjs["TowerDefense"] = new Object();
instrObj.name = 11327;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11328;
instrObj.instrTxts[1] = 11329;
instrObj = instrObjs["FortSmasher"] = new Object();
instrObj.name = 11330;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11331;
instrObj.instrTxts[1] = 11332;
instrObj = instrObjs["PillBugs"] = new Object();
instrObj.name = 11333;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11334;
instrObj.instrTxts[1] = 11335;
instrObj = instrObjs["FeedingFrenzy"] = new Object();
instrObj.name = 11336;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11337;
instrObj.instrTxts[1] = 11338;
instrObj = instrObjs["PhantomsTreasure"] = new Object();
instrObj.name = 11339;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11340;
instrObj.instrTxts[1] = 11341;
instrObj = instrObjs["FashionShow"] = new Object();
instrObj.name = 11342;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11343;
instrObj.instrTxts[1] = 11344;
instrObj = instrObjs["Adventure"] = new Object();
instrObj.name = "Adventure";
instrObj.instrTxts = [];
instrObj.instrTxts[0] = "\nHOW TO PLAY\n\n TBD.";
instrObj.instrTxts[1] = "\nHINT!\n\n Just Play!";
instrObj = instrObjs["HorseRace"] = new Object();
instrObj.name = 11348;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11349;
instrObj.instrTxts[1] = 11350;
instrObj = instrObjs["FallingPhantoms"] = new Object();
instrObj.name = 11351;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11352;
instrObj.instrTxts[1] = 11353;
instrObj = instrObjs["HedgeHog"] = new Object();
instrObj.name = 11354;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11355;
instrObj.instrTxts[1] = 11356;
instrObj = instrObjs["DolphinRace"] = new Object();
instrObj.name = 11357;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 11358;
instrObj.instrTxts[1] = 11359;
instrObj = instrObjs["EagleFlap"] = new Object();
instrObj.name = 15735;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 15740;
instrObj.instrTxts[1] = 15741;
instrObj = instrObjs["SpotOn"] = new Object();
instrObj.name = 19654;
instrObj.instrTxts = [];
instrObj.instrTxts[0] = 19686;
instrObj.instrTxts[1] = 19687;
}
public static function destroy() : void
{
instrScreenContent.backBtn.removeEventListener(MouseEvent.MOUSE_DOWN,backHandler);
instrScreenContent.nextBtn.removeEventListener(MouseEvent.MOUSE_DOWN,nextHandler);
instrScreenContent = null;
}
public static function getCurrentScreen() : uint
{
return currScreen;
}
public static function build(gameName:String, joinGamePopup:SBPopup, startGame:Function) : void
{
_joinGamePopup = joinGamePopup;
_killJoinGamePopup = true;
if(startGame != null)
{
_startGameFunction = startGame;
}
instrScreenContent.startBtn.visible = false;
if(Boolean(instrPopup))
{
guiLayer.setChildIndex(instrPopup,guiLayer.numChildren - 1);
return;
}
instrInfo = instrObjs[gameName];
if(instrInfo == null)
{
throw new Error("InstructionScreenBuilder could not find instrObjs[\"" + gameName + "\"]!");
}
instrInfo.displayName = gameName;
numScreens = instrInfo.instrTxts.length;
currScreen = 0;
updateInstrScreen();
instrPopup = new SBPopup(guiLayer,GETDEFINITIONBYNAME("InstructionsSkin"),instrScreenContent,true,true,true,false,true);
instrPopup.closeCallback = closeHandler;
}
private static function startGameHandler(m:MouseEvent) : void
{
if(Boolean(m))
{
m.stopPropagation();
}
if(_startGameFunction != null)
{
closeHandler();
_startGameFunction(null);
}
}
public static function closeHandler() : void
{
if(_killJoinGamePopup)
{
_joinGamePopup.destroy();
_joinGamePopup = null;
_killJoinGamePopup = false;
}
instrPopup.destroy();
instrPopup = null;
}
public static function backHandler(m:MouseEvent) : void
{
if(currScreen > 0)
{
--currScreen;
updateInstrScreen();
return;
}
throw new Error("Tried to go back on first instr screen!");
}
public static function nextHandler(m:MouseEvent) : void
{
if(currScreen < numScreens - 1)
{
++currScreen;
updateInstrScreen();
return;
}
throw new Error("Tried to go next on last instr screen!");
}
public static function updateInstrScreen() : void
{
LocalizationManager.translateId(instrScreenContent.gameName.gameNameTxt,instrObjs[instrInfo.displayName].name);
LocalizationManager.translateId(instrScreenContent.gameInstr.gameInstrTxt,instrInfo.instrTxts[currScreen]);
for(var hac:int = 0; hac < instrScreenContent.instrImg.numChildren; hac++)
{
instrScreenContent.instrImg.getChildAt(hac).visible = false;
}
if(Boolean(instrScreenContent.instrImg[instrInfo.name + currScreen]))
{
instrScreenContent.instrImg[instrInfo.name + currScreen].visible = true;
}
if(currScreen == 0)
{
if(numScreens > 1)
{
instrScreenContent.nextBtn.visible = true;
instrScreenContent.nextTxt.visible = true;
}
else
{
instrScreenContent.nextBtn.visible = false;
instrScreenContent.nextTxt.visible = false;
}
instrScreenContent.backToMainBtn.visible = true;
instrScreenContent.backBtn.visible = false;
}
else if(currScreen == numScreens - 1)
{
instrScreenContent.backBtn.visible = true;
instrScreenContent.backTxt.visible = true;
instrScreenContent.nextBtn.visible = false;
instrScreenContent.nextTxt.visible = false;
instrScreenContent.backToMainBtn.visible = false;
}
else
{
instrScreenContent.backBtn.visible = true;
instrScreenContent.backTxt.visible = true;
instrScreenContent.nextBtn.visible = true;
instrScreenContent.nextTxt.visible = true;
instrScreenContent.backToMainBtn.visible = false;
}
instrScreenContent.page.pageTxt.text = currScreen + 1 + " / " + numScreens;
instrScreenContent.nextTxt.visible = false;
instrScreenContent.backTxt.visible = false;
}
private static function backBtnHandlerOnFirstScreen(m:MouseEvent) : void
{
if(Boolean(m))
{
m.stopPropagation();
}
_killJoinGamePopup = false;
_joinGamePopup.visible = true;
instrPopup.soundEnabled = false;
instrPopup.destroy();
instrPopup = null;
}
}
}
@@ -0,0 +1,172 @@
package gui
{
import avatar.AvatarInfo;
import avatar.AvatarManager;
import avatar.UserCommXtCommManager;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import localization.LocalizationManager;
import pet.PetManager;
import quest.QuestManager;
import quest.QuestXtCommManager;
import room.RoomXtCommManager;
public class ItemWindowAdventure extends ItemWindowBase
{
private var _scriptDef:Object;
public function ItemWindowAdventure(windowLoaded:Function, currItem:MovieClip, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._scriptDef = QuestXtCommManager.getScriptDef(customParams.scriptIds[index]);
super(this._scriptDef.bannerMediaRefId,windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override protected function setChildrenAndInitialConditions() : void
{
var ai:AvatarInfo = null;
_window.txt.mouseEnabled = false;
_window.txt.mouseChildren = false;
LocalizationManager.translateId(_window.txt.titleTxt,this._scriptDef.titleStrId);
if(Boolean(_window["memLock"]))
{
_window["memLock"].visible = this._scriptDef.membersOnly;
_window["memLock"].mouseEnabled = false;
_window["memLock"].mouseChildren = false;
ai = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,gMainFrame.userInfo.myPerUserAvId);
if(Boolean(ai))
{
if(ai.questLevel < this._scriptDef.levelMin)
{
_window.tag.visible = false;
}
}
}
if(this._scriptDef.defId == 21)
{
_window.tag.visible = false;
}
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null && !(_memberOnlyDown != null && !gMainFrame.userInfo.isMember))
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
if(_memberOnlyDown != null && !gMainFrame.userInfo.isMember)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
public function performContinueChecks() : Object
{
var ai:AvatarInfo = null;
var myPet:Object = null;
if(QuestManager.isInPrivateAdventureState)
{
QuestManager.showLeaveQuestLobbyPopup(this.performContinueChecks);
return null;
}
if(AvatarManager.isMyUserInCustomPVPState())
{
UserCommXtCommManager.sendCustomPVPMessage(false,0);
}
if(!RoomXtCommManager.isSwitching)
{
if(Boolean(this._scriptDef.membersOnly) && !gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.ADVENTURES,"adventure/" + this._scriptDef.defId);
return null;
}
ai = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,gMainFrame.userInfo.myPerUserAvId);
if(Boolean(ai))
{
if(Boolean(this._scriptDef.playAsPet))
{
myPet = PetManager.myActivePet;
if(!Boolean(myPet))
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19656));
return null;
}
if(!PetManager.canPetGoInEnviroType(myPet.type,this._scriptDef.avatarType))
{
switch(this._scriptDef.avatarType)
{
case 1:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19648));
break;
case 2:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19649));
break;
case 4:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19650));
break;
case 5:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(19655));
}
return null;
}
}
else
{
if(Boolean(AvatarManager.playerAvatar) && !AvatarManager.isValidEnviro(this._scriptDef.avatarType))
{
switch(this._scriptDef.avatarType)
{
case 1:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(15706));
break;
case 2:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18476));
break;
case 4:
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18475));
break;
case 5:
}
return null;
}
if(ai.questLevel < this._scriptDef.levelMin)
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14697,this._scriptDef.levelMin));
return null;
}
if(this._scriptDef.avatarLimit == 1 && Boolean(_window.tag.visible))
{
return {
"func":QuestXtCommManager.sendQuestCreateJoinPublic,
"defId":this._scriptDef.defId
};
}
}
if(Boolean(_window.tag.visible))
{
return {
"func":AdventureExpertPopup.init,
"defId":this._scriptDef.defId
};
}
return null;
}
return null;
}
return null;
}
}
}
@@ -0,0 +1,450 @@
package gui
{
import avatar.Avatar;
import avatar.AvatarInfo;
import avatar.AvatarSwitch;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class ItemWindowAnimal extends ItemWindowBase
{
private const COST_OF_NEW_ANIMAL:int = 1000;
private const SLOTS_PER_NONMEMBER:int = 2;
private var _isChoosing:Boolean;
private var _isAnimal:Boolean;
private var _recyclingOnly:Boolean;
private var _addGrayChild:Boolean;
private var _isChoosingOcean:Boolean;
private var _ai:AvatarInfo;
private var _nameBarData:int;
public function ItemWindowAnimal(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._isChoosing = customParams.isChoosing;
this._isAnimal = customParams.isAnimal;
this._recyclingOnly = customParams.recylingOnly;
this._isChoosingOcean = customParams.isChoosingOcean;
this._nameBarData = customParams.nameBarData;
super("amlCont",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get aml() : MovieClip
{
return _window.aml;
}
public function get makeNew() : MovieClip
{
return _window.makeNew;
}
public function get recycle() : MovieClip
{
return _window.recycle;
}
public function get den() : MovieClip
{
return _window.den;
}
public function get lock() : MovieClip
{
return _window.lock;
}
public function get gray() : MovieClip
{
return _window.gray;
}
public function get checkbox() : MovieClip
{
return _window.checkbox;
}
public function get buyDen() : MovieClip
{
return _window.buyDen;
}
public function set currItem(currItem:Object) : void
{
_currItem = currItem;
}
public function get level() : int
{
return Boolean(this._ai) ? this._ai.questLevel : 0;
}
public function resetWindow(removeIndex:int) : void
{
if(this._isAnimal)
{
_window.makeNew.visible = true;
_window.priceTag.visible = false;
_window.buy.visible = false;
_window.lock.visible = false;
_window.aml.visible = false;
_window.aml.sel.visible = false;
_window.recycle.visible = false;
_window.gray.visible = false;
_window.lock.visible = false;
_window.makeNew.newAmlBtn.gray.visible = false;
_window.xpShape.visible = false;
--AvatarSwitch.numOpenNonMemberSlots;
_isCurrItemLoaded = false;
this.loadCurrItem();
}
else
{
if(removeIndex > 0)
{
while(_window.den.itemBlock.numChildren > 0)
{
_window.den.itemBlock.removeChildAt(0);
}
}
_window.buyDen.visible = true;
_window.den.visible = false;
_window.priceTag.visible = false;
_window.buy.visible = false;
_window.lock.visible = false;
_window.aml.visible = false;
_window.aml.sel.visible = false;
_window.recycle.visible = false;
_window.gray.visible = false;
}
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
var _numTotalSlots:int = 0;
var myAvatar:Avatar = null;
var numNonMemberAvatars:int = 0;
var numNonMemberOceanAvatars:int = 0;
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(this._isAnimal)
{
if(!_isCurrItemLoaded)
{
_numTotalSlots = SwitchManager.NUM_AVATAR_SLOTS;
_window.gray.grayDen.visible = false;
_window.aml.bg.visible = true;
_window.aml.gray.visible = false;
_window.aml.nameTxt.visible = true;
_window.priceTag.txt.text = this.COST_OF_NEW_ANIMAL;
_window.aml.visible = true;
myAvatar = AvatarSwitch.avatars[_index];
numNonMemberAvatars = AvatarSwitch.numNonMemberAvatars;
numNonMemberOceanAvatars = AvatarSwitch.numNonMemberOceanAvatars;
if(myAvatar != null)
{
if(AvatarSwitch.isSlotAvailable(_index) || this._isChoosing)
{
_window.priceTag.visible = false;
_window.buy.visible = false;
_window.makeNew.visible = false;
_window.lock.visible = false;
_window.aml.visible = true;
_window.aml.sel.visible = false;
_window.aml.nameTxt.text = myAvatar.avName;
if(this._isChoosing)
{
_window.checkbox.visible = true;
_window.checkbox.check.visible = false;
_window.aml.bg.visible = false;
_window.aml.gray.visible = true;
if(numNonMemberAvatars > 0 && numNonMemberAvatars < 3)
{
if(!AvatarSwitch.isMemberOnlyAvatar(_index))
{
_window.checkbox.check.visible = false;
}
}
if(numNonMemberAvatars - numNonMemberOceanAvatars < 1 || numNonMemberAvatars <= _numTotalSlots && AvatarSwitch.isMemberOnlyAvatar(_index))
{
_window.aml.visible = false;
_window.gray.visible = true;
_window.lock.visible = true;
_window.checkbox.visible = false;
_window.gray.nameTxt.text = myAvatar.avName;
this._addGrayChild = true;
}
}
else if(!this._isChoosingOcean)
{
_window.recycle.visible = false;
}
if(_index == AvatarSwitch.activeAvatarIdx)
{
_window.aml.sel.visible = true;
}
while(_window.xpShape.numChildren > 0)
{
_window.xpShape.removeChildAt(0);
}
this._ai = gMainFrame.userInfo.getAvatarInfoByUserNameThenPerUserAvId(myAvatar.userName,myAvatar.perUserAvId);
if(Boolean(this._ai) && this._ai.questLevel > 0)
{
this.loadQuestShape();
}
if(this._isChoosing)
{
if(!gMainFrame.userInfo.isMember && !AvatarSwitch.isMemberOnlyAvatar(_index))
{
++AvatarSwitch.numOpenNonMemberSlots;
}
}
else
{
++AvatarSwitch.numOpenNonMemberSlots;
}
}
else
{
_window.aml.visible = false;
_window.gray.visible = true;
_window.gray.nameTxt.text = myAvatar.avName;
this._addGrayChild = true;
_window.gray.amlMask.amlBox.addChild(_currItem);
}
if(Utility.isOcean(_currItem.avatarData.enviroTypeFlag))
{
if(Utility.isLand(_currItem.avatarData.enviroTypeFlag))
{
if(Boolean(_window.aml.visible))
{
if(Boolean(_window.aml.gray.visible))
{
_window.aml.gray.gotoAndStop(3);
}
else
{
_window.aml.bg.gotoAndStop(3);
}
}
else
{
_window.gray.grayAml.gotoAndStop(3);
}
}
else if(Boolean(_window.aml.visible))
{
if(Boolean(_window.aml.gray.visible))
{
_window.aml.gray.gotoAndStop(2);
}
else
{
_window.aml.bg.gotoAndStop(2);
}
}
else
{
_window.gray.grayAml.gotoAndStop(2);
}
}
}
else
{
if(!gMainFrame.userInfo.isMember)
{
if(AvatarSwitch.numOpenNonMemberSlots < this.SLOTS_PER_NONMEMBER || this._isChoosing && numNonMemberAvatars - numNonMemberOceanAvatars < 1)
{
++AvatarSwitch.numOpenNonMemberSlots;
_window.makeNew.visible = true;
_window.lock.visible = false;
}
else
{
_window.makeNew.visible = false;
_window.lock.visible = true;
}
}
else
{
_window.makeNew.visible = true;
_window.lock.visible = false;
}
_window.priceTag.visible = false;
_window.buy.visible = false;
_window.aml.visible = false;
_window.aml.sel.visible = false;
_window.recycle.visible = false;
if(this._isChoosing && AvatarSwitch.numNonMemberAvatars > 1 && numNonMemberAvatars - numNonMemberOceanAvatars > 0)
{
_window.makeNew.newAmlBtn.gray.visible = true;
}
else
{
_window.makeNew.newAmlBtn.gray.visible = false;
}
_isCurrItemLoaded = true;
}
}
}
else if(_currItem != null)
{
if(!_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
_window.den.sel.visible = false;
if(gMainFrame.userInfo.isMember)
{
_window.den.visible = true;
_window.den.txt.text = _currItem.name;
}
else if(Boolean(_currItem.isMemberOnly))
{
this._addGrayChild = true;
_window.den.visible = false;
_window.gray.visible = true;
_window.gray.nameTxt.text = _currItem.name;
}
else
{
_window.den.visible = true;
_window.den.txt.text = _currItem.name;
}
if(Boolean(_currItem.isLand))
{
_window.den.greenBG.visible = true;
}
else
{
_window.den.greenBG.visible = false;
}
if(_index == DenSwitch.activeDenIdx)
{
_window.den.sel.visible = true;
}
_window.buyDen.visible = false;
if(this._recyclingOnly)
{
_window.recycle.visible = true;
}
else
{
_window.recycle.visible = false;
}
}
}
else
{
_window.den.visible = false;
_window.buyDen.visible = true;
}
if(Boolean(_currItem) && Boolean(!_isCurrItemLoaded) && this._isAnimal)
{
_isCurrItemLoaded = true;
if(_iconLayerName != "" && _currItem.hasOwnProperty(_iconLayerName))
{
if(this._addGrayChild)
{
_window.gray.amlMask.amlBox.addChild(_currItem[_iconLayerName]);
}
else
{
_window.aml.amlMask.amlBox.addChild(_currItem[_iconLayerName]);
}
}
else if(this._addGrayChild)
{
_window.gray.amlMask.amlBox.addChild(_currItem);
}
else
{
_window.aml.amlMask.amlBox.addChild(_currItem);
}
}
}
private function loadQuestShape() : void
{
var currFrameName:String = _window.xpShape.currentLabels[Utility.getColorId(this._nameBarData) - 1].name;
_window.xpShape.visible = true;
if(currFrameName == "black")
{
_window.xpShape.gotoAndStop(2);
_window.xpShape.gotoAndStop(currFrameName);
}
if(_window.xpShape.currentFrameLabel != currFrameName)
{
_window.xpShape.gotoAndStop(currFrameName);
}
Utility.createXpShape(this._ai.questLevel,true,_window.xpShape[currFrameName].mouse.up.icon,null,this._nameBarData);
}
override public function destroy() : void
{
AvatarSwitch.numOpenNonMemberSlots = 0;
super.destroy();
}
override protected function setChildrenAndInitialConditions() : void
{
_window.priceTag.visible = false;
_window.priceTag.txt.textColor = "0x386630";
_window.buy.visible = false;
_window.makeNew.visible = false;
_window.lock.visible = false;
_window.recycle.visible = false;
_window.den.visible = false;
_window.buyDen.visible = false;
_window.xpShape.visible = false;
if(this._isAnimal)
{
_window.aml.visible = true;
_window.aml.bg.visible = false;
_window.aml.gray.visible = true;
_window.aml.sel.visible = false;
_window.aml.nameTxt.visible = false;
}
else
{
_window.aml.visible = false;
}
_window.gray.visible = false;
_window.buyDen.buyBtn.gray.visible = false;
_window.buy.buyAmlBtn.gray.visible = false;
_window.makeNew.newAmlBtn.gray.visible = false;
_window.checkbox.visible = false;
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
if(_memberOnlyDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
}
}
@@ -0,0 +1,80 @@
package gui
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import loader.MediaHelper;
public class ItemWindowAvatarIcon extends ItemWindowBase
{
private var _currColor:String;
private var _mediaHelper:MediaHelper;
private var _currIconId:int;
public function ItemWindowAvatarIcon(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._currColor = customParams.currColor;
this._currIconId = int(currItem);
super(1734,windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function updateColor(newColor:String) : void
{
this._currColor = newColor;
if(Boolean(_window))
{
_window.gotoAndStop(this._currColor);
}
}
public function get currIconId() : int
{
return this._currIconId;
}
public function get currWindow() : MovieClip
{
return _window;
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
if(_currItem is int)
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(int(_currItem),this.onCurrItemLoaded);
}
else if(Boolean(_currItem) && !_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
if(_iconLayerName != "" && _currItem.hasOwnProperty(_iconLayerName))
{
_window.itemWindow.addChild(_currItem[_iconLayerName]);
}
else
{
_window.itemWindow.addChild(DisplayObject(_currItem));
}
}
}
override protected function setChildrenAndInitialConditions() : void
{
_window.gotoAndStop(this._currColor);
}
private function onCurrItemLoaded(img:MovieClip) : void
{
if(Boolean(img))
{
_currItem = img.getChildAt(0);
this.loadCurrItem();
}
}
}
}
@@ -0,0 +1,126 @@
package gui
{
import avatar.AvatarUtility;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.filters.ColorMatrixFilter;
import loader.MediaHelper;
import localization.LocalizationManager;
public class ItemWindowAvatarSelect extends ItemWindowBase
{
private var _mediaHelper:MediaHelper;
private var _currIconId:int;
private var _forCreation:Boolean;
private var _avType:int;
private var _avDef:Object;
public function ItemWindowAvatarSelect(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._currIconId = int(currItem);
this._forCreation = customParams.forCreation == null ? false : Boolean(customParams.forCreation);
this._avType = customParams.avTypes[index];
this._avDef = AvatarUtility.avatarDefInfo[AvatarUtility.findAvatarIndexByType(this._avType)];
super(1810,windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get currIconId() : int
{
return this._currIconId;
}
public function get currWindow() : MovieClip
{
return _window;
}
public function deselect() : void
{
if(_window.currentFrameLabel != "up")
{
_window.gotoAndStop("up");
}
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
var matrix:Array = null;
if(Boolean(_window))
{
if(_currItem is int)
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(int(_currItem),this.onCurrItemLoaded);
}
else if(Boolean(_currItem) && !_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
if(!gMainFrame.userInfo.isMember)
{
if(Boolean(this._avDef.isMemberOnly))
{
_window.memberLock.visible = true;
}
}
if(!this._forCreation && Utility.isOcean(this._avDef.enviroFlag))
{
_window.ocean.visible = true;
}
if(AvatarUtility.isEndangered(this._avDef.availability))
{
if(this._avType == 13 || this._avType == 16 || this._avType == 26)
{
LocalizationManager.translateId(_window.endangered.txt,11177);
}
else if(this._avType == 6)
{
LocalizationManager.translateId(_window.endangered.txt,14226);
}
_window.endangered.visible = true;
}
if(AvatarUtility.isExtinct(this._avDef.availability))
{
matrix = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0];
_currItem.filters = [new ColorMatrixFilter(matrix)];
}
if(_iconLayerName != "" && _currItem.hasOwnProperty(_iconLayerName))
{
_window.itemWindow.addChild(_currItem[_iconLayerName]);
}
else
{
_window.itemWindow.addChild(DisplayObject(_currItem));
}
}
}
}
override protected function setChildrenAndInitialConditions() : void
{
_window.memberLock.visible = false;
_window.endangered.visible = false;
_window.ocean.visible = false;
if(this._forCreation)
{
this.loadCurrItem();
}
}
private function onCurrItemLoaded(img:MovieClip) : void
{
if(Boolean(img))
{
_currItem = img.getChildAt(0);
this.loadCurrItem();
}
}
}
}
@@ -0,0 +1,103 @@
package gui
{
import avatar.AvatarInfo;
import flash.display.DisplayObject;
import flash.display.MovieClip;
public class ItemWindowAvtPetSml extends ItemWindowBase
{
private var _isPet:Boolean;
private var _ai:AvatarInfo;
private var _isMember:Boolean;
private var _nameBarData:int;
private var _currFrameName:String;
public function ItemWindowAvtPetSml(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._isPet = customParams != null ? Boolean(customParams.isPet) : false;
this._isMember = customParams != null ? Boolean(customParams.isMember) : false;
this._nameBarData = customParams != null ? int(customParams.nameBarData) : 0;
if(!this._isPet)
{
this._ai = gMainFrame.userInfo.getAvatarInfoByUserNameThenPerUserAvId(currItem.userName,currItem.perUserAvId);
}
super("charBtnSmlCont",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get sel() : MovieClip
{
return _window.sel;
}
public function get isPet() : Boolean
{
return this._isPet;
}
public function get charLayer() : MovieClip
{
return _window.charLayer;
}
public function get xpShape() : MovieClip
{
return _window.xpShape;
}
override public function gotoAndStop(frame:Object, scene:String = null) : void
{
_window.gotoAndStop(frame,scene);
if(Boolean(this._currFrameName))
{
if(frame == "over")
{
this.xpShape[this._currFrameName].mouse.gotoAndPlay(1);
}
else
{
this.xpShape[this._currFrameName].mouse.gotoAndStop(1);
}
}
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem) && !_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
_window.charLayer.addChild(DisplayObject(_currItem));
if(Boolean(this._ai) && this._ai.questLevel > 0)
{
this._currFrameName = this.xpShape.currentLabels[Utility.getColorId(this._nameBarData) - 1].name;
if(this.xpShape.currentFrameLabel != this._currFrameName)
{
this.xpShape.gotoAndStop(this._currFrameName);
}
Utility.createXpShape(this._ai.questLevel,this._isMember,this.xpShape[this._currFrameName].mouse.up.icon,this.xpShape[this._currFrameName].mouse.mouse.icon,int.MAX_VALUE);
}
}
}
override protected function setChildrenAndInitialConditions() : void
{
var tempItem:Object = null;
_window.sel.visible = false;
if(this._isPet)
{
tempItem = _currItem;
tempItem.x = this.width * 0.5;
tempItem.y = this.height * 0.8;
tempItem.scaleX = tempItem.scaleY = 1.1;
_currItem = tempItem;
}
}
}
}
@@ -0,0 +1,236 @@
package gui
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
public class ItemWindowBase extends MovieClip
{
protected var _window:MovieClip;
protected var _currItem:Object;
protected var _mouseDown:Function;
protected var _mouseOver:Function;
protected var _mouseOut:Function;
protected var _memberOnlyDown:Function;
protected var _index:int;
protected var _spiral:LoadingSpiral;
protected var _windowLoadedCallback:Function;
protected var _iconLayerName:String;
protected var _isCurrItemLoaded:Boolean;
protected var _itemYLocation:int;
protected var _itemXLocation:int;
protected var _useToolTip:Boolean;
protected var _windowGenerator:WindowGenerator;
private var _windowMediaHelper:MediaHelper;
private var _memberOnlyTrackingName:String;
public function ItemWindowBase(windowClassOrId:*, windowLoadedCallback:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function, mouseOver:Function, mouseOut:Function, memberOnlyDown:Function, useToolTip:Boolean = false)
{
var split:Array = null;
super();
this._currItem = currItem;
this._iconLayerName = iconLayerName;
this._mouseDown = mouseDown;
this._mouseOver = mouseOver;
this._mouseOut = mouseOut;
this._memberOnlyDown = memberOnlyDown;
this._index = index;
this._windowLoadedCallback = windowLoadedCallback;
this._useToolTip = useToolTip;
if(windowClassOrId is String)
{
split = String(windowClassOrId).split("|");
this._window = GETDEFINITIONBYNAME(split[0],split.length > 1 ? false : true);
addChild(this._window);
this.addEventListeners();
this.setChildrenAndInitialConditions();
this.onWindowLoadCallback();
}
else
{
if(!(windowClassOrId is int))
{
throw new Error("windowClassOrId is not of type string or int. WindowClassOrId = " + windowClassOrId);
}
this._windowMediaHelper = new MediaHelper();
this._windowMediaHelper.init(windowClassOrId,this.onWindowLoaded);
}
}
public function destroy() : void
{
this.removeEventListeners();
if(Boolean(this._spiral))
{
this._spiral.destroy();
}
if(Boolean(this._windowMediaHelper))
{
this._windowMediaHelper.destroy();
}
if(Boolean(this._window) && this._window.parent == this)
{
removeChild(this._window);
}
if(Boolean(this._currItem) && this._currItem.hasOwnProperty("destroy"))
{
this._currItem.destroy();
}
this._windowGenerator = null;
this._window = null;
this._windowLoadedCallback = null;
this._currItem = null;
this._mouseDown = null;
this._mouseOver = null;
this._mouseOut = null;
}
public function get index() : int
{
return this._index;
}
public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
this._itemYLocation = currYLocation;
this._itemXLocation = currXLocation;
if(Boolean(this._currItem) && !this._isCurrItemLoaded)
{
this._isCurrItemLoaded = true;
if(this._iconLayerName != "" && this._currItem.hasOwnProperty(this._iconLayerName))
{
this._window.addChild(this._currItem[this._iconLayerName]);
}
else
{
this._window.addChild(DisplayObject(this._currItem));
}
}
}
protected function onWindowLoaded(mc:MovieClip) : void
{
if(Boolean(mc))
{
this._window = MovieClip(mc.getChildAt(0));
addChild(this._window);
this.setChildrenAndInitialConditions();
this.onWindowLoadCallback();
this.addEventListeners();
this._windowMediaHelper.destroy();
this._windowMediaHelper = null;
}
}
protected function onWindowLoadCallback() : void
{
if(this._windowLoadedCallback != null)
{
this._windowLoadedCallback(this);
}
}
protected function setChildrenAndInitialConditions() : void
{
}
protected function onWindowRollOver(evt:MouseEvent) : void
{
if(this._useToolTip && this.parent != null)
{
if(this._windowGenerator == null)
{
this._windowGenerator = WindowGenerator(this.parent.parent);
}
this._windowGenerator.toolTip.init(this._windowGenerator.parent.parent,this._currItem.name,this.x + this._windowGenerator.boxWidth * 0.5 + this._windowGenerator.parent.x + this._itemXLocation,this.y + this._windowGenerator.boxHeight - this._itemYLocation + this._windowGenerator.parent.y - 5);
this._windowGenerator.toolTip.startTimer(evt);
}
}
protected function onWindowRollOut(evt:MouseEvent) : void
{
if(this._useToolTip && this.parent != null)
{
this._windowGenerator.toolTip.resetTimerAndSetVisibility();
}
}
protected function addEventListeners() : void
{
if(Boolean(this._window) && Boolean(this._currItem))
{
if(this._mouseDown != null && !(this._memberOnlyDown != null && !gMainFrame.userInfo.isMember))
{
addEventListener(MouseEvent.MOUSE_DOWN,this._mouseDown,false,0,true);
}
if(this._mouseOver != null)
{
if(this._useToolTip)
{
addEventListener(MouseEvent.ROLL_OVER,this.onWindowRollOver,false,0,true);
}
addEventListener(MouseEvent.ROLL_OVER,this._mouseOver,false,0,true);
}
if(this._mouseOut != null)
{
if(this._useToolTip)
{
addEventListener(MouseEvent.ROLL_OUT,this.onWindowRollOut,false,0,true);
}
addEventListener(MouseEvent.ROLL_OUT,this._mouseOut,false,0,true);
}
if(this._memberOnlyDown != null && !gMainFrame.userInfo.isMember)
{
addEventListener(MouseEvent.MOUSE_DOWN,this._memberOnlyDown,false,0,true);
}
}
}
protected function removeEventListeners() : void
{
if(this._mouseDown != null)
{
removeEventListener(MouseEvent.MOUSE_DOWN,this._mouseDown);
}
if(this._mouseOver != null)
{
if(this._useToolTip)
{
removeEventListener(MouseEvent.ROLL_OVER,this.onWindowRollOut);
}
removeEventListener(MouseEvent.ROLL_OVER,this._mouseOver);
}
if(this._mouseOut != null)
{
if(this._useToolTip)
{
removeEventListener(MouseEvent.ROLL_OUT,this.onWindowRollOut);
}
removeEventListener(MouseEvent.ROLL_OUT,this._mouseOut);
}
if(this._memberOnlyDown != null)
{
removeEventListener(MouseEvent.MOUSE_DOWN,this._memberOnlyDown);
}
}
}
}
@@ -0,0 +1,95 @@
package gui
{
import flash.events.MouseEvent;
import localization.LocalizationManager;
import movie.MovieNode;
public class ItemWindowChapterSelect extends ItemWindowBase
{
private var _currMovieNodeDef:MovieNode;
private var _isGray:Boolean;
private var _baseDefId:int;
public function ItemWindowChapterSelect(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super(2162,windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
this._currMovieNodeDef = MovieNode(currItem);
this._baseDefId = customParams.baseDefId;
}
public function getMovieNodeDef() : MovieNode
{
return this._currMovieNodeDef;
}
public function activateGrayState(b:Boolean) : void
{
this._isGray = b;
_window.activateGrayState(b);
}
public function get isGray() : Boolean
{
return this._isGray;
}
override protected function setChildrenAndInitialConditions() : void
{
var shouldStillShowGift:Boolean = false;
if(this._currMovieNodeDef.defId != this._baseDefId && !gMainFrame.userInfo.userVarCache.isBitSet(this._currMovieNodeDef.userVarId,this._currMovieNodeDef.bitIndex))
{
if(this._currMovieNodeDef.bitIndex > 0 && Boolean(gMainFrame.userInfo.userVarCache.isBitSet(this._currMovieNodeDef.userVarId,this._currMovieNodeDef.bitIndex - 1)))
{
this.activateGrayState(false);
shouldStillShowGift = true;
}
else
{
this.activateGrayState(true);
}
}
if(this._currMovieNodeDef.thisChapterHasGift && (shouldStillShowGift || this._isGray))
{
_window.btnCont.showGift(true);
}
else
{
_window.btnCont.showGift(false);
}
var text:String = LocalizationManager.translateIdOnly(this._currMovieNodeDef.streamTitleId);
if(this._isGray)
{
text = text.slice(0,text.indexOf(":"));
}
LocalizationManager.updateToFit(_window.btnCont.mouse.up.txt,text);
LocalizationManager.updateToFit(_window.btnCont.gray.txt,text);
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
if(_memberOnlyDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
}
}
@@ -0,0 +1,187 @@
package gui
{
import avatar.Avatar;
import avatar.AvatarInfo;
import avatar.AvatarManager;
import avatar.AvatarUtility;
import avatar.AvatarView;
import avatar.AvatarXtCommManager;
import avatar.UserInfo;
import com.sbi.graphics.LayerAnim;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Point;
import localization.LocalizationManager;
import pet.GuiPet;
import quest.QuestXtCommManager;
public class ItemWindowCustPlayers extends ItemWindowBase
{
private var _onBxBtn:Function;
private var _currUserName:String;
private var _ai:AvatarInfo;
private var _scriptDefId:int;
public function ItemWindowCustPlayers(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._onBxBtn = customParams.onBxBtn;
this._scriptDefId = customParams.scriptDefId;
super(2301,windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override protected function setChildrenAndInitialConditions() : void
{
_window.bx.visible = false;
super.setChildrenAndInitialConditions();
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
var joinedAvatarInfo:AvatarInfo = null;
while(_window.char.charLayer.numChildren > 0)
{
_window.char.charLayer.removeChildAt(0);
}
_window.char.gotoAndPlay("waiting");
LocalizationManager.translateId(_window.nameBar.firstName_txt,11101);
_window.nameBar.lastName_txt.text = "";
_window.char.gotoAndPlay("up");
var joinedAvatarRef:Avatar = AvatarManager.getAvatarBySfsUserId(int(_currItem));
if(Boolean(joinedAvatarRef))
{
joinedAvatarInfo = gMainFrame.userInfo.getAvatarInfoByUserName(joinedAvatarRef.userName);
}
if(joinedAvatarRef == null || joinedAvatarInfo == null)
{
AvatarXtCommManager.requestAvatarGetBySfsId(int(_currItem),this.onAvatarGetReceived);
}
else
{
this.setupAvatar(joinedAvatarRef,joinedAvatarInfo.currPet);
}
}
override protected function addEventListeners() : void
{
_window.bx.addEventListener(MouseEvent.MOUSE_DOWN,this._onBxBtn,false,0,true);
super.addEventListeners();
}
override protected function removeEventListeners() : void
{
_window.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this._onBxBtn);
super.removeEventListeners();
}
public function showXBtn(show:Boolean) : void
{
_window.bx.visible = show;
}
public function get userName() : String
{
return this._currUserName;
}
public function get char() : MovieClip
{
return _window.char;
}
private function setupAvatar(avt:Avatar, currPet:Object) : void
{
var bigPet:GuiPet = null;
var avtView:AvatarView = null;
var offset:Point = null;
var avName:String = null;
var space:int = 0;
var firstName:String = null;
var lastName:String = null;
var scriptDef:Object = QuestXtCommManager.getScriptDef(this._scriptDefId);
if(Boolean(scriptDef.playAsPet))
{
bigPet = new GuiPet(0,currPet.lBits,currPet.uBits,currPet.eBits,currPet.type,currPet.name,this.onBigPetLoaded);
_window.char.charLayer.addChild(bigPet);
_window.nameBar.firstName_txt.text = bigPet.petName;
}
else
{
avtView = new AvatarView();
avtView.init(avt);
avtView.playAnim(LayerAnim.AN_HUD_AVT);
avtView.scaleX = 0.7;
avtView.scaleY = 0.7;
offset = AvatarUtility.getAvatarMinigameLobbyOffset(avtView.avTypeId);
avtView.x = offset.x;
avtView.y = offset.y + 5;
_window.char.charLayer.addChild(avtView);
avName = avt.avName;
space = avName.indexOf(" ");
if(space != -1)
{
firstName = avName.substr(0,space);
lastName = avName.substr(space + 1,avName.length);
}
else
{
firstName = avName;
}
_window.nameBar.firstName_txt.text = firstName;
if(Boolean(lastName))
{
_window.nameBar.lastName_txt.text = lastName;
}
}
this._currUserName = avt.userName;
this._ai = gMainFrame.userInfo.getAvatarInfoByUserNameThenPerUserAvId(avt.userName,avt.perUserAvId);
var ui:UserInfo = gMainFrame.userInfo.getUserInfoByUserName(avt.userName);
if(Boolean(this._ai) && Boolean(ui) && this._ai.questLevel > 0)
{
this.loadQuestShape(ui.nameBarData);
}
}
private function onAvatarGetReceived(userName:String, status:Boolean, onlineStatus:int, sfsUserId:int) : void
{
var avInfo:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUserName(userName);
if(!avInfo)
{
throw new Error("onAvatarSFSGetReceived and avInfo is null");
}
var perUserAvId:int = avInfo.perUserAvId;
var avt:Avatar = AvatarManager.getAvatarByUserName(userName);
if(avt == null)
{
avt = AvatarUtility.generateNew(perUserAvId,null,userName,-1,0);
}
this.setupAvatar(avt,avInfo.currPet);
}
private function onBigPetLoaded(content:MovieClip, guiPet:GuiPet) : void
{
guiPet.scaleX = guiPet.scaleY = 1.5;
guiPet.y += 30;
}
private function loadQuestShape(nameBarData:int) : void
{
var currFrameName:String = _window.xpShape.currentLabels[Utility.getColorId(nameBarData) - 1].name;
_window.xpShape.visible = true;
if(currFrameName == "black")
{
_window.xpShape.gotoAndStop(2);
_window.xpShape.gotoAndStop(currFrameName);
}
if(_window.xpShape.currentFrameLabel != currFrameName)
{
_window.xpShape.gotoAndStop(currFrameName);
}
Utility.createXpShape(this._ai.questLevel,true,_window.xpShape[currFrameName].mouse.up.icon,null,nameBarData);
}
}
}
@@ -0,0 +1,62 @@
package gui
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class ItemWindowGame extends ItemWindowBase
{
public function ItemWindowGame(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super("gameBtnCont",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get itemLayer() : MovieClip
{
return _window.itemLayer;
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem) && !_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
if(_iconLayerName != "" && _currItem.hasOwnProperty(_iconLayerName))
{
_window.itemLayer.addChild(_currItem[_iconLayerName]);
}
else
{
_window.itemLayer.addChild(DisplayObject(_currItem));
}
}
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
if(_memberOnlyDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
}
}
@@ -0,0 +1,56 @@
package gui
{
import avatar.AvatarInfo;
public class ItemWindowHeart extends ItemWindowBase
{
private var _frameName:String = "fullHeart";
private var _hpPercentage:Number;
private var _isEmptyHeart:Boolean;
private var _numTotalHearts:Number;
public function ItemWindowHeart(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._hpPercentage = customParams.hpPercentage;
var ai:AvatarInfo = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,gMainFrame.userInfo.myPerUserAvId);
this._numTotalHearts = ai.healthBase * 0.5;
var numHeartsPerPercentage:Number = 100 / this._numTotalHearts;
var numHearts:Number = Math.min(this._numTotalHearts,this._hpPercentage / numHeartsPerPercentage);
var numHeartsCeil:int = Math.ceil(numHearts);
if(index + 1 == numHeartsCeil)
{
if(numHeartsCeil - numHearts >= 0.5 && this._numTotalHearts == numHearts)
{
this._frameName = "halfHeart";
}
else
{
this._frameName = numHeartsCeil - numHearts >= 0.5 ? "halfEmpty" : "fullHeart";
}
}
else if(index + 1 > numHeartsCeil && numHeartsCeil < this._numTotalHearts)
{
this._isEmptyHeart = true;
if(index + 1 == Math.ceil(this._numTotalHearts) && numHeartsCeil - numHearts >= 0.5)
{
this._frameName = "halfCont";
}
else
{
this._frameName = "emptyHeart";
}
}
super("questHudHeart",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function updateFrame() : void
{
_window.gotoAndStop(this._frameName);
}
}
}
@@ -0,0 +1,80 @@
package gui
{
import avatar.AvatarManager;
import avatar.NameBar;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import localization.LocalizationManager;
public class ItemWindowNameBar extends ItemWindowBase
{
private var _isMember:Boolean;
private var _nameBarData:Object;
private var _userName:String;
private var _avName:String;
private var _isBuddy:Boolean;
private var _isBlocked:Boolean;
public function ItemWindowNameBar(windowLoaded:Function, currItem:MovieClip, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._isMember = customParams[index].isMember;
this._nameBarData = customParams[index].nameBarData;
this._userName = customParams[index].userName;
this._avName = customParams[index].avName;
this._isBuddy = customParams[index].isBuddy;
this._isBlocked = customParams[index].isBlocked;
super(this._isMember ? "memberNameBar" : "FreeNameBar",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get userName() : String
{
return this._userName;
}
public function updateToBeCentered(totalWidth:int) : void
{
_window.x += (totalWidth - _window.width) * 0.5;
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
}
override protected function setChildrenAndInitialConditions() : void
{
if(this._isMember)
{
_window.nubData = AvatarManager.playerAvatarWorldView.nubData;
_window.setNubType(this._isBuddy ? NameBar.BUDDY : NameBar.NON_BUDDY);
_window.setColorAndBadge(this._nameBarData);
}
else
{
_window.iconIds = AvatarManager.playerAvatarWorldView.nameBarIconIds;
_window.nubData = AvatarManager.playerAvatarWorldView.nubData;
}
_window.isBlocked = this._isBlocked;
_window.setAvName(LocalizationManager.translateAvatarName(this._avName));
_window.x += _window.width * 0.5;
_window.y += _window.height * 0.5;
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
}
}
}
}
@@ -0,0 +1,121 @@
package gui
{
import flash.display.MovieClip;
import loader.MediaHelper;
public class ItemWindowNameBarIcon extends ItemWindowBase
{
private var _currFrameLabel:String;
private var _loadIcons:Boolean;
private var _icon1:MovieClip;
private var _icon2:MovieClip;
private var _iconsMediaHelper:MediaHelper;
private var _callbackFunction:Function;
private var _triedToLoadCurrItem:Boolean;
public function ItemWindowNameBarIcon(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._currFrameLabel = customParams.currFrameLabel;
this._loadIcons = customParams.loadIcons;
this._callbackFunction = customParams.callbackFunction;
super("selNub",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get mouse() : MovieClip
{
return _window.mouse;
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem && !_isCurrItemLoaded) && Boolean(!this._loadIcons) && _window.hasOwnProperty("mouse"))
{
_isCurrItemLoaded = true;
_window.mouse.gotoAndStop(1);
_window.mouse.mouse.icon.addChild(_currItem.iconMouse);
_window.mouse.up.icon.addChild(_currItem.iconUp);
}
else
{
this._triedToLoadCurrItem = true;
}
}
override protected function setChildrenAndInitialConditions() : void
{
if(Boolean(_currItem))
{
_window.scaleX = 1.5;
_window.scaleY = 1.5;
_window.gotoAndStop(this._currFrameLabel);
_window = _window[this._currFrameLabel];
_window.y += _window.height * 0.5;
while(_window.mouse.mouse.icon.numChildren > 0)
{
_window.mouse.mouse.icon.removeChildAt(0);
}
while(_window.mouse.up.icon.numChildren > 0)
{
_window.mouse.up.icon.removeChildAt(0);
}
if(this._loadIcons)
{
_window.mouse.gotoAndStop(1);
this.loadIcon();
}
}
else
{
_window.visible = false;
}
}
private function loadIcon() : void
{
this._iconsMediaHelper = new MediaHelper();
this._iconsMediaHelper.init(int(_currItem),this.onIconsLoaded);
}
private function onIconsLoaded(mc:MovieClip) : void
{
if(Boolean(mc) && Boolean(_window))
{
if(this._icon1 == null)
{
this._icon1 = mc;
this._iconsMediaHelper = new MediaHelper();
this._iconsMediaHelper.init(int(_currItem),this.onIconsLoaded);
}
else
{
this._loadIcons = false;
this._icon2 = mc;
_currItem = {
"iconMouse":this._icon1,
"iconUp":this._icon2
};
this._callbackFunction(this._icon1,this._icon2,_index);
this._icon1 = null;
this._icon2 = null;
this._callbackFunction = null;
this._iconsMediaHelper.destroy();
this._iconsMediaHelper = null;
if(this._triedToLoadCurrItem)
{
this.loadCurrItem();
}
}
}
}
}
}
@@ -0,0 +1,350 @@
package gui
{
import avatar.AvatarManager;
import den.DenItem;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import item.Item;
import pet.PetManager;
public class ItemWindowOriginal extends ItemWindowBase
{
private var _isAvatarEditor:Boolean;
private var _isTradeList:Boolean;
private var _isChoosingForTradeList:Boolean;
private var _generatorIndex:int;
private var _giftItemIdx:int;
private var _isDownGift:Boolean;
private var _isPetItem:Boolean;
private var _isActivePet:Boolean;
private var _isAudio:Boolean;
private var _isLastPlacedAudio:Boolean;
private var _isTradeManager:Boolean;
private var _isECard:Boolean;
private var _isViewingATradeList:Boolean;
private var _isRecycling:Boolean;
private var _loadImmediately:Boolean;
public function ItemWindowOriginal(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
var indexArrayLength:int = 0;
var indexCount:int = index;
this._generatorIndex = index;
if(customParams != null)
{
this._loadImmediately = customParams.loadImmediately;
this._isRecycling = customParams.isRecycling;
this._isViewingATradeList = customParams.isViewingATradeList;
this._isECard = customParams.isECard;
this._isAvatarEditor = customParams.isAvatarEditor;
this._isTradeManager = customParams.isTradeManager;
this._isAudio = customParams.isAudio;
this._isPetItem = customParams.isPetItem;
this._giftItemIdx = customParams.giftItemIdx;
this._isTradeList = customParams.isTradeList;
this._isChoosingForTradeList = customParams.isChoosingForTradeList;
if(customParams.indexArray != null)
{
indexArrayLength = int(customParams.indexArray.length);
indexCount = indexArrayLength - 1 > index ? int(customParams.indexArray[index]) : int(customParams.indexArray[indexArrayLength - 1] - index + index);
}
}
super("itemWindow",windowLoaded,currItem,iconLayerName,indexCount,mouseDown,mouseOver,mouseOut,memberOnlyDown,true);
}
public function get removeBtn() : MovieClip
{
return _window.removeBtn;
}
public function get addBtn() : MovieClip
{
return _window.addBtn;
}
public function get cir() : MovieClip
{
return _window.cir;
}
public function get gift() : MovieClip
{
return _window.gift;
}
public function get isDownGift() : Boolean
{
return this._isDownGift;
}
public function get isActivePet() : Boolean
{
return this._isActivePet;
}
public function get isLastPlacedAudio() : Boolean
{
return this._isLastPlacedAudio;
}
public function get isAudio() : Boolean
{
return this._isAudio;
}
override public function get numChildren() : int
{
return _window.numChildren;
}
override public function getChildAt(index:int) : DisplayObject
{
return _window.getChildAt(index);
}
public function resetDownGift() : void
{
_window.gift.visible = false;
this._isDownGift = false;
}
public function set currDownGift(o:Object) : void
{
this._isDownGift = true;
_window.gift.visible = true;
}
public function resetAudioDown() : void
{
this._isLastPlacedAudio = false;
_window.cir.gotoAndStop("up");
}
public function setAudioDown() : void
{
this._isLastPlacedAudio = true;
_window.cir.gotoAndStop("down");
}
public function get defId() : int
{
if(Boolean(_currItem))
{
if(_currItem is Item)
{
return _currItem.defId;
}
return _currItem.itemDefId;
}
return -1;
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
var tempItem:Object = null;
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem) && !_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
if(_iconLayerName != "" && _currItem.hasOwnProperty(_iconLayerName))
{
_window.iconLayer.addChild(_currItem[_iconLayerName]);
}
else
{
_window.iconLayer.addChild(DisplayObject(_currItem));
}
if(this._isTradeManager)
{
if(_currItem is Item)
{
tempItem = _currItem;
_currItem = new Item();
_currItem.init(tempItem.defId,tempItem.invIdx,tempItem.color,tempItem.getInUse(AvatarManager.playerAvatar.perUserAvId));
}
else
{
tempItem = _currItem;
_currItem = new DenItem();
_currItem.init(tempItem.itemDefId,tempItem.invIdx,tempItem.categoryId,tempItem.version,tempItem.refId);
_currItem.name = tempItem.name;
}
}
if(Boolean(_currItem.isMemberOnly))
{
if(!gMainFrame.userInfo.isMember)
{
_window.lock.visible = true;
if(!this.isSpecialList())
{
_window.gray.visible = true;
}
}
else
{
_window.lockOpen.visible = true;
}
}
if(Boolean(_currItem.isOcean))
{
_window.ocean.visible = true;
}
if(Boolean(_currItem.isRare))
{
_window.rare.visible = true;
}
if(this._isTradeList || this._isTradeManager)
{
_window.removeBtn.visible = true;
}
if(this._isPetItem && _currItem.invIdx == PetManager.myActivePetInvId)
{
_window.cir.gotoAndStop("green");
this._isActivePet = true;
}
if(_currItem is Item)
{
if(Boolean(_currItem.getInUse(gMainFrame.userInfo.myPerUserAvId)))
{
_window.cir.gotoAndStop("down");
}
}
else if(_currItem is DenItem)
{
if(_currItem.categoryId != 0 && !this._isActivePet)
{
this._isLastPlacedAudio = true;
_window.cir.gotoAndStop("down");
}
}
if(this._isECard)
{
if(this._giftItemIdx == _currItem.invIdx)
{
this.gift.visible = true;
this._isDownGift = true;
}
}
}
}
override protected function setChildrenAndInitialConditions() : void
{
_window.lock.visible = false;
_window.lockOpen.visible = false;
_window.gray.visible = false;
_window.gift.visible = false;
_window.addBtn.visible = false;
_window.removeBtn.visible = false;
_window.ocean.visible = false;
_window.rare.visible = false;
_window.avtSpecific.visible = false;
_window.avtSpecificIcon.visible = false;
_window.avtSpecificHighlight.visible = false;
if(Boolean(_currItem))
{
if(!_spiral)
{
_spiral = new LoadingSpiral(_window.iconLayer);
}
else
{
_spiral.setNewParent(_window.iconLayer);
}
if(!_currItem.isIconLoaded)
{
_currItem.imageLoadedCallback = _spiral.destroy();
}
else
{
_spiral.destroy();
}
if(this._loadImmediately)
{
this.loadCurrItem();
}
}
else if(this._isTradeList || this._isTradeManager)
{
_window.addBtn.visible = true;
}
}
override protected function onWindowLoadCallback() : void
{
if(_windowLoadedCallback != null)
{
_windowLoadedCallback(this,this._generatorIndex);
}
}
override protected function addEventListeners() : void
{
if(Boolean(_window) && Boolean(_currItem))
{
if(_mouseDown != null && !(_currItem.isMemberOnly && _memberOnlyDown != null && !gMainFrame.userInfo.isMember && !this.isSpecialList()))
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
if(_useToolTip)
{
addEventListener(MouseEvent.ROLL_OVER,onWindowRollOver,false,0,true);
}
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
if(_useToolTip)
{
addEventListener(MouseEvent.ROLL_OUT,onWindowRollOut,false,0,true);
}
}
if(Boolean(_memberOnlyDown != null && _currItem.isMemberOnly) && Boolean(!gMainFrame.userInfo.isMember) && !this.isSpecialList())
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
else if(this._isTradeList || this._isTradeManager)
{
if(_mouseDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
}
}
private function isSpecialList() : Boolean
{
return this._isTradeList || this._isTradeManager || this._isChoosingForTradeList || this._isViewingATradeList || this._isECard || this._isRecycling;
}
}
}
@@ -0,0 +1,87 @@
package gui
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import localization.LocalizationManager;
public class ItemWindowParty extends ItemWindowBase
{
private var _defId:int;
public function ItemWindowParty(windowLoaded:Function, currItem:MovieClip, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super(customParams.mediaRefId[index],windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override protected function setChildrenAndInitialConditions() : void
{
_window.anims.mouseEnabled = false;
_window.anims.mouseChildren = false;
_window.txt.mouseEnabled = false;
_window.txt.mouseChildren = false;
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null && !(_memberOnlyDown != null && !gMainFrame.userInfo.isMember))
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
if(_memberOnlyDown != null && !gMainFrame.userInfo.isMember)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
public function setupTextAndAnims(secToStart:int, printTime:String) : void
{
if(secToStart > 0)
{
_window.goBtn.visible = false;
_window.txt.timeTxt.text = printTime;
}
else
{
_window.goBtn.visible = true;
_window.txt.timeTxt.visible = false;
_window.anims.animate();
}
}
public function get txt() : MovieClip
{
return _window.txt;
}
public function set titleText(id:int) : void
{
if(Boolean(_window.txt.hasOwnProperty("titleTxt")))
{
LocalizationManager.translateId(_window.txt.titleTxt,id);
}
}
public function set defId(value:int) : void
{
this._defId = value;
}
public function get defId() : int
{
return this._defId;
}
}
}
@@ -0,0 +1,170 @@
package gui
{
import avatar.AvatarManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import pet.GuiPet;
import pet.PetManager;
public class ItemWindowPets extends ItemWindowBase
{
private var _isRecycling:Boolean;
private var _currGuiPet:GuiPet;
public function ItemWindowPets(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._isRecycling = customParams.isRecycling;
super("itemWindowPets",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown,true);
}
public function get cir() : MovieClip
{
return _window.cir;
}
public function get gray() : MovieClip
{
return _window.gray;
}
public function get cageIcon() : MovieClip
{
return _window.cageIcon;
}
public function get newPetIcon() : MovieClip
{
return _window.newPet;
}
public function get hasPet() : Boolean
{
return _currItem;
}
override public function destroy() : void
{
if(Boolean(this._currGuiPet))
{
this._currGuiPet.destroy();
this._currGuiPet = null;
}
super.destroy();
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
var currPet:Object = null;
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem) && !_isCurrItemLoaded)
{
currPet = PetManager.getPetDef(_currItem.defId);
this._currGuiPet = new GuiPet(_currItem.idx,_currItem.lBits,_currItem.uBits,_currItem.eBits,_currItem.type,_currItem.name,null);
_window.cageIcon.visible = this._isRecycling;
_window.ocean.visible = this._currGuiPet.canGoInOcean();
if(!gMainFrame.userInfo.isMember)
{
_window.lockOpen.visible = false;
if(Boolean(currPet.isMember))
{
_window.gray.visible = true;
_window.lock.visible = true;
}
else
{
_window.lock.visible = false;
_window.gray.visible = false;
}
}
else
{
_window.lock.visible = false;
_window.gray.visible = false;
if(Boolean(currPet.isMember))
{
_window.lockOpen.visible = true;
}
else
{
_window.lockOpen.visible = false;
}
}
_window.newPet.visible = false;
if(!PetManager.canCurrAvatarUsePet(AvatarManager.playerAvatar.enviroTypeFlag,currPet.type))
{
_window.gray.visible = true;
}
else if(PetManager.myActivePetInvId == this._currGuiPet.idx)
{
_window.cir.gotoAndStop("down");
}
this._currGuiPet.scaleX = this._currGuiPet.scaleY = 2;
_isCurrItemLoaded = true;
_window.iconLayer.addChild(this._currGuiPet);
}
if(Boolean(_spiral))
{
_spiral.destroy();
}
}
override protected function setChildrenAndInitialConditions() : void
{
_spiral = new LoadingSpiral(_window.iconLayer);
_window.lockOpen.visible = false;
_window.lock.visible = false;
_window.gray.visible = false;
_window.ocean.visible = false;
_window.cageIcon.visible = false;
_window.newPet.gray.visible = false;
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null && !(_memberOnlyDown != null && !gMainFrame.userInfo.isMember))
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null && Boolean(_currItem))
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
if(_useToolTip)
{
addEventListener(MouseEvent.ROLL_OVER,this.onWindowRollOver,false,0,true);
}
}
if(_mouseOut != null && Boolean(_currItem))
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
if(_useToolTip)
{
addEventListener(MouseEvent.ROLL_OUT,onWindowRollOut,false,0,true);
}
}
if(_memberOnlyDown != null && !gMainFrame.userInfo.isMember)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
override protected function onWindowRollOver(evt:MouseEvent) : void
{
if(_useToolTip && this.parent != null)
{
if(_windowGenerator == null)
{
_windowGenerator = WindowGenerator(this.parent.parent);
}
_windowGenerator.toolTip.init(_windowGenerator.parent.parent,this._currGuiPet.petName,this.x + _windowGenerator.boxWidth * 0.5 + _windowGenerator.parent.x + _itemXLocation,this.y + _windowGenerator.boxHeight - _itemYLocation + _windowGenerator.parent.y - 5);
_windowGenerator.toolTip.startTimer(evt);
}
}
}
}
@@ -0,0 +1,177 @@
package gui
{
import com.sbi.corelib.input.SBTextField;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;
import loader.MediaHelper;
import localization.LocalizationManager;
public class ItemWindowPost extends ItemWindowBase
{
private var _iconMediaHelper:MediaHelper;
private var _onReportDown:Function;
private var _onDeleteDown:Function;
private var _smileyText:SBTextField;
private var _isMyPost:Boolean;
public function ItemWindowPost(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
this._onReportDown = customParams.reportMsgBtnMouseDown;
this._onDeleteDown = customParams.deleteMsgBtnMouseDown;
this._isMyPost = customParams.isMyPost;
tabEnabled = false;
super(1501,windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
public function get msgId() : String
{
return _currItem.msgId;
}
override public function destroy() : void
{
this.removeEventListeners();
if(Boolean(this._iconMediaHelper))
{
this._iconMediaHelper.destroy();
this._iconMediaHelper = null;
}
this._onReportDown = null;
this._onDeleteDown = null;
if(Boolean(this._smileyText))
{
this._smileyText.destroy();
this._smileyText = null;
}
_window = null;
_windowLoadedCallback = null;
_currItem = null;
_mouseDown = null;
_mouseOver = null;
_mouseOut = null;
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem) && !_isCurrItemLoaded)
{
if(!_spiral)
{
_spiral = new LoadingSpiral(_window.iconLayer);
}
else
{
_spiral.setNewParent(_window.iconLayer);
}
this._smileyText = new SBTextField(null,_window.messageTxt,_window.textItemHolder,true);
this._smileyText.text = _currItem.message;
this._smileyText.mouseChildren = false;
this._smileyText.mouseEnabled = false;
this._smileyText.selectable = false;
_window.deleteMessageBtn.parent.setChildIndex(_window.deleteMessageBtn,_window.deleteMessageBtn.parent.numChildren - 1);
_window.reportMessageBtn.parent.setChildIndex(_window.reportMessageBtn,_window.reportMessageBtn.parent.numChildren - 1);
if(!this._isMyPost)
{
_window.reportMessageBtn.x += _window.reportMessageBtn.width;
}
_isCurrItemLoaded = true;
this._iconMediaHelper = new MediaHelper();
this._iconMediaHelper.init(_currItem.iconId,this.onIconLoaded);
}
}
override protected function setChildrenAndInitialConditions() : void
{
var time:Object = null;
if(Boolean(_currItem))
{
_window.reportMessageBtn.visible = false;
_window.deleteMessageBtn.visible = false;
_window.pattern.gotoAndStop("pattern" + _currItem.patternId);
_window.gotoAndStop(_currItem.color);
_window.messageTxt.text = "";
_window.messageTxt.selectable = false;
_window.nameTxt.text = _currItem.senderUserName;
_window.timeTxt.autoSize = TextFieldAutoSize.RIGHT;
time = Utility.calculateTime((new Date().valueOf() - _currItem.postTime) / 1000);
LocalizationManager.translateIdAndInsert(_window.timeTxt,11360,Utility.calculatePrintTime(time.mins,time.hours,false,time.days));
if(Boolean(_currItem.isBuddy))
{
_window.friendIcon.visible = true;
_window.nameTxt.x += _window.friendIcon.width;
}
else
{
_window.friendIcon.visible = false;
}
}
}
override protected function addEventListeners() : void
{
if(this._isMyPost)
{
_window.deleteMessageBtn.addEventListener(MouseEvent.MOUSE_DOWN,this._onDeleteDown,false,0,true);
}
_window.reportMessageBtn.addEventListener(MouseEvent.MOUSE_DOWN,this._onReportDown,false,0,true);
addEventListener(MouseEvent.ROLL_OVER,this.onPostDown,false,0,true);
addEventListener(MouseEvent.ROLL_OUT,this.onPostDown,false,0,true);
}
override protected function removeEventListeners() : void
{
if(this._isMyPost)
{
_window.deleteMessageBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this._onDeleteDown);
}
_window.reportMessageBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this._onReportDown);
removeEventListener(MouseEvent.ROLL_OVER,this.onPostDown);
removeEventListener(MouseEvent.ROLL_OUT,this.onPostDown);
}
private function onPostDown(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(_window))
{
if(_window.messageHighlight.currentFrameLabel != "on")
{
_window.messageHighlight.gotoAndStop("on");
_window.reportMessageBtn.visible = true;
if(this._isMyPost)
{
_window.deleteMessageBtn.visible = true;
}
}
else
{
_window.messageHighlight.gotoAndStop("off");
_window.reportMessageBtn.visible = false;
if(this._isMyPost)
{
_window.deleteMessageBtn.visible = false;
}
}
}
}
private function onIconLoaded(mc:MovieClip) : void
{
if(Boolean(mc))
{
_spiral.destroy();
_spiral = null;
_window.itemWindow.addChild(mc);
}
}
}
}
@@ -0,0 +1,111 @@
package gui
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
public class ItemWindowServer extends ItemWindowBase
{
public function ItemWindowServer(windowLoaded:Function, currItem:MovieClip, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super("serverBarSml",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override protected function setChildrenAndInitialConditions() : void
{
_window.txt.mouseEnabled = false;
_window.buddy.mouseEnabled = false;
_window.g1.mouseEnabled = false;
_window.g2.mouseEnabled = false;
_window.g3.mouseEnabled = false;
_window.o1.mouseEnabled = false;
_window.o2.mouseEnabled = false;
_window.o3.mouseEnabled = false;
_window.full.mouseEnabled = false;
_window.full.mouseChildren = false;
}
public function get full() : Boolean
{
return _window.full.visible;
}
public function set text(value:String) : void
{
_window.txt.text = value;
}
public function get textField() : TextField
{
return _window.txt;
}
public function set buddy(value:Boolean) : void
{
_window.buddy.visible = value;
}
public function set flag(value:int) : void
{
_window.flag.gotoAndStop(value);
}
public function set population(value:String) : void
{
switch(value)
{
case "0":
_window.full.visible = false;
_window.o1.visible = false;
_window.o2.visible = false;
_window.o3.visible = false;
break;
case "1":
_window.o1.visible = true;
_window.o2.visible = false;
_window.o3.visible = false;
_window.full.visible = false;
break;
case "2":
_window.o1.visible = true;
_window.o2.visible = true;
_window.o3.visible = false;
_window.full.visible = false;
break;
case "3":
_window.o1.visible = true;
_window.o2.visible = true;
_window.o3.visible = true;
_window.full.visible = false;
break;
case "4":
_window.full.visible = true;
}
}
override protected function addEventListeners() : void
{
if(Boolean(_window))
{
if(_mouseDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_mouseDown,false,0,true);
}
if(_mouseOver != null)
{
addEventListener(MouseEvent.ROLL_OVER,_mouseOver,false,0,true);
}
if(_mouseOut != null)
{
addEventListener(MouseEvent.ROLL_OUT,_mouseOut,false,0,true);
}
if(_memberOnlyDown != null)
{
addEventListener(MouseEvent.MOUSE_DOWN,_memberOnlyDown,false,0,true);
}
}
}
}
}
@@ -0,0 +1,42 @@
package gui
{
import ecard.ECardImageBase;
public class ItemWindowStamp extends ItemWindowBase
{
private var stampImageBase:ECardImageBase;
public function ItemWindowStamp(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super("StampBtn",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem) && !_isCurrItemLoaded)
{
_isCurrItemLoaded = true;
this.stampImageBase = new ECardImageBase();
this.stampImageBase.init(int(_currItem),this.onImageLoaded);
}
}
private function onImageLoaded() : void
{
if(_iconLayerName != "" && this.stampImageBase.hasOwnProperty(_iconLayerName))
{
_window.imgLayer.addChild(this.stampImageBase[_iconLayerName]);
}
this.stampImageBase[_iconLayerName].scaleX = 0.6;
this.stampImageBase[_iconLayerName].scaleY = 0.6;
}
override protected function setChildrenAndInitialConditions() : void
{
}
}
}
@@ -0,0 +1,35 @@
package gui
{
import flash.text.TextField;
public class ItemWindowTextBar extends ItemWindowBase
{
public function ItemWindowTextBar(windowLoaded:Function, currItem:String, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super("userDenBtnCont",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
_itemYLocation = currYLocation;
_itemXLocation = currXLocation;
if(Boolean(_currItem))
{
_window.txt.text = _currItem;
}
}
public function get txt() : TextField
{
return _window.txt;
}
public function setText(updateText:String) : void
{
_currItem = updateText;
_window.txt.text = updateText;
}
}
}
@@ -0,0 +1,87 @@
package gui
{
import flash.events.MouseEvent;
public class ItemWindowTextNode extends ItemWindowBase
{
private var _originalText:String;
public function ItemWindowTextNode(windowLoaded:Function, currItem:String, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super("chatTextNode",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation:int = 0) : void
{
}
override protected function setChildrenAndInitialConditions() : void
{
if(Boolean(_currItem))
{
this.setupText();
}
addEventListener(MouseEvent.ROLL_OVER,this.onRollOver,false,0,true);
addEventListener(MouseEvent.ROLL_OUT,this.onRollOut,false,0,true);
}
override protected function removeEventListeners() : void
{
removeEventListener(MouseEvent.ROLL_OVER,this.onRollOver);
removeEventListener(MouseEvent.ROLL_OUT,this.onRollOut);
super.removeEventListeners();
}
public function get text() : String
{
return this._originalText;
}
public function updateToBeCentered(totalWidth:int) : void
{
_window.x += (totalWidth - _window.width) * 0.5;
}
private function setupText() : void
{
var i:int = 0;
var currString:String = null;
_window.txt.text = _currItem;
this._originalText = String(_currItem);
if(_window.txt.textWidth > _window.txt.width)
{
_window.txt.text = "";
i = 0;
currString = "";
while(_window.txt.textWidth < _window.txt.width)
{
currString += String(_currItem).charAt(i);
_window.txt.text = currString + "...";
i++;
}
_window.txt.text = currString.slice(0,currString.length - 1) + "...";
}
}
private function onRollOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(_window) && _window.currentFrameLabel != "on")
{
_window.gotoAndStop("on");
AJAudio.playSubMenuBtnRollover();
}
}
private function onRollOut(evt:MouseEvent) : void
{
evt.stopPropagation();
if(Boolean(_window) && _window.currentFrameLabel != "off")
{
_window.gotoAndStop("off");
}
}
}
}
@@ -0,0 +1,337 @@
package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.corelib.audio.SBAudio;
import den.DenXtCommManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import gamePlayFlow.GamePlay;
import localization.LocalizationManager;
import room.RoomManagerWorld;
public class ItemWindowToggle extends ItemWindowBase
{
private var _lock:MovieClip;
public function ItemWindowToggle(windowLoaded:Function, currItem:Object, iconLayerName:String, index:int, mouseDown:Function = null, mouseOver:Function = null, mouseOut:Function = null, memberOnlyDown:Function = null, customParams:Object = null)
{
super("mySettingsToggle|false",windowLoaded,currItem,iconLayerName,index,mouseDown,mouseOver,mouseOut,memberOnlyDown);
}
override public function loadCurrItem(currYLocation:int = 0, currXLocation: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.goNowBtn.down.txt.text = ServerSelector.getShardName(RoomManagerWorld.instance.shardId);
_window.goNowBtn.mouse.mouse.txt.text = ServerSelector.getShardName(RoomManagerWorld.instance.shardId);
_window.goNowBtn.mouse.up.txt.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(Utility.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(Utility.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 "doorBell":
if(Utility.isSettingOn(MySettings.SETTINGS_DOOR_BELL))
{
_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 "intro":
}
LocalizationManager.translateId(_window.labelTxt,_currItem.labelTxt);
}
private function handleMouseDown(evt:MouseEvent) : void
{
var settingUV:int = 0;
var setValue:int = 0;
evt.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_TOGGLE_BTN)
{
switch(_currItem.frame)
{
case "lock":
this._lock = MovieClip(evt.currentTarget);
GuiManager.onToggleDenLock(this.onDenLockUnlock);
break;
case "music":
SBAudio.toggleMuteAll();
GuiManager.toggleMuteVideo();
if(SBAudio.isMusicMuted || SBAudio.areSoundsMuted)
{
evt.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
GuiManager.depressSoundButton(true);
}
else
{
evt.currentTarget.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
GuiManager.depressSoundButton(false);
}
break;
case "buddyRequest":
case "gameInvites":
case "doorBell":
settingUV = int(gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_SETTINGS));
setValue = -1;
if(_currItem.frame == "buddyRequest")
{
setValue = MySettings.SETTINGS_BUDDY_REQUESTS;
}
else if(_currItem.frame == "gameInvites")
{
setValue = MySettings.SETTINGS_GAME_INVITES;
}
else if(_currItem.frame == "doorBell")
{
setValue = MySettings.SETTINGS_DOOR_BELL;
}
if(setValue != -1)
{
if(settingUV == -1)
{
if(setValue == MySettings.SETTINGS_DOOR_BELL)
{
evt.currentTarget.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
}
else
{
evt.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
}
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,setValue);
}
else if(evt.currentTarget.currentFrameLabel == "on" || evt.currentTarget.currentFrameLabel == "startingOn")
{
evt.currentTarget.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
if(setValue == MySettings.SETTINGS_DOOR_BELL)
{
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,setValue,null,false);
}
else
{
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,setValue);
}
}
else
{
evt.currentTarget.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
if(setValue == MySettings.SETTINGS_DOOR_BELL)
{
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,setValue);
}
else
{
AchievementXtCommManager.requestSetUserVar(AchievementXtCommManager.UV_SETTINGS,setValue,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(evt.currentTarget.mouse.currentFrame == 3)
{
evt.currentTarget.mouseEnabled = false;
evt.currentTarget.mouseChildren = false;
}
if(evt.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)
{
switch(_currItem.frame)
{
case "world":
ServerSelector.init(GuiManager.guiLayer,null,GamePlay(gMainFrame.gamePlay).joinChosenShardIdNode);
break;
case "intro":
GuiManager.startFFM();
}
}
}
private function handleMouseOut(evt:MouseEvent) : void
{
evt.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_TOGGLE_BTN)
{
if(evt.currentTarget.toggleBG.currentFrameLabel != "up")
{
evt.currentTarget.toggleBG.gotoAndStop("up");
}
if(evt.currentTarget.toggleKnob.currentFrameLabel != "up")
{
evt.currentTarget.toggleKnob.gotoAndStop("up");
}
}
}
private function handleMouseOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_TOGGLE_BTN)
{
if(evt.currentTarget.toggleBG.currentFrameLabel != "over")
{
evt.currentTarget.toggleBG.gotoAndStop("over");
}
if(evt.currentTarget.toggleKnob.currentFrameLabel != "over")
{
evt.currentTarget.toggleKnob.gotoAndStop("over");
}
}
}
private function onDenLockUnlock(needsToSendRequest:Boolean = true) : void
{
if(needsToSendRequest)
{
gMainFrame.userInfo.isMyDenPrivate = !gMainFrame.userInfo.isMyDenPrivate;
DenXtCommManager.requestSetDenPrivacy(gMainFrame.userInfo.isMyDenPrivate,true);
GuiManager.refreshDenLockSettings();
}
if(gMainFrame.userInfo.isMyDenPrivate)
{
this._lock.gotoAndPlay("off");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("off");
}
else
{
this._lock.gotoAndPlay("on");
_window.icon["" + _window.icon.currentFrameLabel].gotoAndPlay("on");
}
}
}
}
@@ -0,0 +1,139 @@
package gui
{
public class JBManager
{
private static var _defPages:Array;
private static var _unseenPagesIds:Array;
private static var _currRoomJBItems:Array;
private static var _numUnclaimedGifts:int;
private static var _hasLoadedDefs:Boolean;
private static var _numUnseenPages:int;
private static const JB_FACT_LIST_ID:int = 54;
private static const JB_PAGE_BIT_IDX:int = 29;
private static const JB_KEEP_GIFT:int = 31;
private static const JB_DISCARD_GIFT:int = 30;
public function JBManager()
{
super();
}
public static function init() : void
{
_defPages = [];
_unseenPagesIds = [];
GenericListXtCommManager.requestGenericList(JB_FACT_LIST_ID,onFactListReceived);
}
public static function get numUnseenPages() : int
{
return _numUnseenPages;
}
public static function get numUnclaimedGifts() : int
{
return _numUnclaimedGifts;
}
public static function set numUnclaimedGifts(value:int) : void
{
_numUnclaimedGifts = value;
}
public static function removeUnseenPage(pageUserVarId:int) : void
{
--_numUnseenPages;
delete _unseenPagesIds[pageUserVarId];
}
public static function checkUnseenPage(currRoomJBItems:Array) : void
{
var currJBItem:Object = null;
var currUnseenId:int = 0;
if(Boolean(currRoomJBItems) && currRoomJBItems.length > 0)
{
if(_hasLoadedDefs)
{
if(_unseenPagesIds.length > 0)
{
_currRoomJBItems = null;
for each(currJBItem in currRoomJBItems)
{
for each(currUnseenId in _unseenPagesIds)
{
if(currUnseenId == currJBItem.refId)
{
GuiManager.showJBGlow(true);
break;
}
}
}
}
}
else
{
_currRoomJBItems = currRoomJBItems;
}
}
}
private static function onFactListReceived(factDefs:Array) : void
{
var page:Array = null;
var currDef:Object = null;
var numBitsSet:int = 0;
_hasLoadedDefs = true;
var defsLength:int = int(factDefs.length);
var bitIndex:int = 0;
for(var i:int = 0; i < defsLength; i++)
{
currDef = factDefs[i];
if(!_defPages[currDef.userVarId])
{
_defPages[currDef.userVarId] = [];
if(!gMainFrame.userInfo.userVarCache.isBitSet(currDef.userVarId,JB_PAGE_BIT_IDX))
{
++_numUnseenPages;
_unseenPagesIds[currDef.userVarId] = currDef.id;
}
}
_defPages[currDef.userVarId].push(currDef);
NGFactManager.updateFactDefCache(currDef);
}
for each(page in _defPages)
{
numBitsSet = 0;
for(i = 0; i < page.length; i++)
{
if(Boolean(gMainFrame.userInfo.userVarCache.isBitSet(page[i].userVarId,page[i].bitIdx)))
{
numBitsSet++;
}
}
if(numBitsSet == page.length)
{
if(!(Boolean(gMainFrame.userInfo.userVarCache.isBitSet(page[i - 1].userVarId,JB_KEEP_GIFT)) || Boolean(gMainFrame.userInfo.userVarCache.isBitSet(page[i - 1].userVarId,JB_DISCARD_GIFT))))
{
++_numUnclaimedGifts;
}
}
}
if(Boolean(_currRoomJBItems))
{
checkUnseenPage(_currRoomJBItems);
}
GuiManager.updateJBIcon();
}
}
}
@@ -0,0 +1,136 @@
package gui
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
public class LoadingSpiral extends MovieClip
{
public static var hasBeenLoaded:Boolean;
public static const LOADING_SPIRAL_MEDIA_ID:int = 44;
private var _isDarkenManagersSpiral:Boolean;
private var _loadingSpiral:MovieClip;
private var _loadingSpiralHelper:MediaHelper;
private var _parent:DisplayObjectContainer;
private var _addToParent:Boolean;
private var _displayPercentage:Boolean;
public function LoadingSpiral(parent:DisplayObjectContainer = null, xPos:Number = 0, yPos:Number = 0, displayPercentage:Boolean = false)
{
super();
if(Boolean(parent))
{
this._parent = parent;
}
this._addToParent = true;
this.x = xPos;
this.y = yPos;
this._loadingSpiralHelper = new MediaHelper();
this._loadingSpiralHelper.init(LOADING_SPIRAL_MEDIA_ID,this.loadingSpiralHandler);
this.addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown,false,0,true);
this.addEventListener(MouseEvent.MOUSE_OVER,this.onMouseOver,false,0,true);
hasBeenLoaded = false;
this._displayPercentage = displayPercentage;
}
public function destroy() : void
{
if(Boolean(this._parent) && Boolean(this._loadingSpiral) && this.parent == this._parent)
{
this._parent.removeChild(this);
this._parent = null;
this._addToParent = false;
}
if(!this._isDarkenManagersSpiral)
{
this._parent = null;
}
this._displayPercentage = false;
}
public function set isDarkenManagersSpiral(value:Boolean) : void
{
this._isDarkenManagersSpiral = value;
}
public function setNewParent(parent:DisplayObjectContainer, xPos:Number = 0, yPos:Number = 0, displayPercentage:Boolean = false) : void
{
this._parent = parent;
this._addToParent = true;
if(Boolean(this._parent) && Boolean(this._loadingSpiral))
{
this._parent.addChild(this);
}
if(Boolean(this._loadingSpiral))
{
if(displayPercentage)
{
this._loadingSpiral.txt.text = "0%";
this._loadingSpiral.txt.visible = true;
}
else
{
this._loadingSpiral.txt.visible = false;
}
}
this.x = xPos;
this.y = yPos;
}
public function updatePercentText(percentage:String) : void
{
if(Boolean(this._loadingSpiral))
{
this._loadingSpiral.txt.text = percentage;
}
}
private function loadingSpiralHandler(media:MovieClip) : void
{
if(this._addToParent)
{
this._loadingSpiral = media;
this._loadingSpiral.txt.text = "0%";
if(Boolean(this._loadingSpiral))
{
this.addChild(this._loadingSpiral);
}
if(Boolean(this._parent))
{
this._parent.addChild(this);
}
if(!this._displayPercentage)
{
this._loadingSpiral.txt.visible = false;
}
else
{
this._loadingSpiral.txt.visible = true;
}
hasBeenLoaded = true;
this._loadingSpiralHelper.destroy();
this._loadingSpiralHelper = null;
}
}
private function onMouseDown(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onMouseOver(evt:MouseEvent) : void
{
evt.stopPropagation();
}
}
}
@@ -0,0 +1,261 @@
package gui
{
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBYesNoPopup;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import item.ItemXtCommManager;
import loader.MediaHelper;
import localization.LocalizationManager;
public class MuseumDonation
{
private var _mediaHelper:MediaHelper;
private var _popup:MovieClip;
private var _guiLayer:DisplayLayer;
private var _closeCallback:Function;
private var _myGemCount:int;
private var _donationAmounts:Array;
private var _donationIndex:int;
private var _radioBtn1:MovieClip;
private var _radioBtn2:MovieClip;
private var _radioBtn3:MovieClip;
private var _lastChosenString:String;
public function MuseumDonation()
{
super();
}
public function init(closeCallback:Function) : void
{
this._guiLayer = GuiManager.guiLayer;
DarkenManager.showLoadingSpiral(true);
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(1546,this.onMediaLoaded);
this._closeCallback = closeCallback;
this._donationAmounts = [10,25,50,100,250,500,1000,2500,5000];
}
public function destroy() : void
{
this.removeEventListeners();
if(Boolean(this._mediaHelper))
{
this._mediaHelper.destroy();
this._mediaHelper = null;
}
this._closeCallback = null;
DarkenManager.unDarken(this._popup);
this._guiLayer.removeChild(this._popup);
this._popup = null;
}
private function onMediaLoaded(mc:MovieClip) : void
{
if(Boolean(mc))
{
this._popup = MovieClip(mc.getChildAt(0));
this._popup.x = MainFrame.VIEW_WIDTH * 0.5;
this._popup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._myGemCount = gMainFrame.clientInfo.gemCount;
this._popup.donateRedBtn.visible = false;
this._radioBtn1 = this._popup.radioBtn1;
this._radioBtn2 = this._popup.radioBtn2;
this._radioBtn3 = this._popup.radioBtn3;
this._popup.donateBtn.activateGrayState(true);
this._radioBtn1._circle.visible = false;
this._radioBtn2._circle.visible = false;
this._radioBtn3._circle.visible = false;
this.addEventListeners();
DarkenManager.showLoadingSpiral(false);
this._guiLayer.addChild(this._popup);
DarkenManager.darken(this._popup);
}
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onClose(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(this._closeCallback != null)
{
this._closeCallback();
}
else
{
this.destroy();
}
}
private function onUpBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
var currAmount:int = int(this._popup.donationAmountTxt.text);
if(this._donationIndex < this._donationAmounts.length - 1)
{
++this._donationIndex;
currAmount = int(this._donationAmounts[this._donationIndex]);
}
if(currAmount > this._myGemCount)
{
this._popup.donateRedBtn.visible = true;
}
else
{
this._popup.donateRedBtn.visible = false;
}
this._popup.donationAmountTxt.text = currAmount;
}
private function onDownBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
var currAmount:int = int(this._popup.donationAmountTxt.text);
if(this._donationIndex > 0)
{
--this._donationIndex;
currAmount = int(this._donationAmounts[this._donationIndex]);
}
if(currAmount > this._myGemCount)
{
this._popup.donateRedBtn.visible = true;
}
else
{
this._popup.donateRedBtn.visible = false;
}
this._popup.donationAmountTxt.text = currAmount;
}
private function onDonateBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
if(this._myGemCount < this._popup.donationAmountTxt.text)
{
SBTracker.trackPageview("/game/play/popup/donate/donation/notEnoughGems/#" + this._myGemCount,-1,SBTracker.TYPE_EVENT);
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdOnly(14770));
}
else
{
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdAndInsertOnly(14771,Utility.convertNumberToString(this._popup.donationAmountTxt.text)),true,this.onConfirm);
}
}
private function onConfirm(o:Object) : void
{
if(Boolean(o.status))
{
ItemXtCommManager.requestDonateGems(this._popup.donationAmountTxt.text,this.onDonateDone);
FeedbackManager.setupRequest(new UserImageUpload(),this._lastChosenString + "|" + this._popup.donationAmountTxt.text,FeedbackManager.TYPE_DONATION,0,this.onSuccess,this.onError);
}
}
private function onError(evt:Event) : void
{
}
private function onSuccess(evt:Event) : void
{
}
private function onDonateDone(status:Boolean) : void
{
if(status)
{
this._popup.visible = false;
SBTracker.trackPageview("/game/play/popup/donate/donation/#" + this._popup.donationAmountTxt.text);
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdOnly(14772),true,this.onDonationThanks);
}
else
{
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdOnly(14773));
}
}
private function onDonationThanks(evt:MouseEvent) : void
{
evt.stopPropagation();
SBOkPopup.destroyInParentChain(evt.target.parent);
this.onClose(null);
}
private function onRadioBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this._radioBtn1._circle.visible = false;
this._radioBtn2._circle.visible = false;
this._radioBtn3._circle.visible = false;
var currObj:Object = evt.currentTarget;
currObj._circle.visible = !currObj._circle.visible;
if(Boolean(currObj._circle.visible))
{
this._lastChosenString = this._popup["selectionLabelTxt" + currObj.name.substr(8)].text;
}
if(Boolean(this._popup.donateBtn.isGray))
{
this._popup.donateBtn.activateGrayState(false);
}
}
private function onPlayMovBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.showLoadingSpiral(true);
GenericListGuiManager.genericListVolumeClicked(evt.currentTarget.name.split("_")[1],{"shouldRepeat":false});
}
private function addEventListeners() : void
{
this._popup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._popup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
this._popup.upBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onUpBtn,false,0,true);
this._popup.downBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onDownBtn,false,0,true);
this._popup.donateBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onDonateBtn,false,0,true);
this._popup.donateRedBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onDonateBtn,false,0,true);
this._popup.radioBtn1.addEventListener(MouseEvent.MOUSE_DOWN,this.onRadioBtn,false,0,true);
this._popup.radioBtn2.addEventListener(MouseEvent.MOUSE_DOWN,this.onRadioBtn,false,0,true);
this._popup.radioBtn3.addEventListener(MouseEvent.MOUSE_DOWN,this.onRadioBtn,false,0,true);
this._popup.playMovBtn1_131.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovBtn,false,0,true);
this._popup.playMovBtn2_130.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovBtn,false,0,true);
this._popup.playMovBtn3_129.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovBtn,false,0,true);
}
private function removeEventListeners() : void
{
this._popup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._popup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._popup.upBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onUpBtn);
this._popup.downBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onDownBtn);
this._popup.donateBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onDonateBtn);
this._popup.donateRedBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onDonateBtn);
this._popup.radioBtn1.removeEventListener(MouseEvent.MOUSE_DOWN,this.onRadioBtn);
this._popup.radioBtn2.removeEventListener(MouseEvent.MOUSE_DOWN,this.onRadioBtn);
this._popup.radioBtn3.removeEventListener(MouseEvent.MOUSE_DOWN,this.onRadioBtn);
this._popup.playMovBtn1_131.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovBtn);
this._popup.playMovBtn2_130.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovBtn);
this._popup.playMovBtn3_129.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayMovBtn);
}
}
}
@@ -0,0 +1,235 @@
package gui
{
import com.sbi.corelib.audio.SBAudio;
import flash.display.MovieClip;
import flash.events.*;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import localization.LocalizationManager;
public class MySettings
{
public static var SETTINGS_BUDDY_REQUESTS:int = 0;
public static var SETTINGS_GAME_INVITES:int = 1;
public static var SETTINGS_DOOR_BELL:int = 2;
public static var TOGGLE_TYPE_TOGGLE_BTN:int = 0;
public static var TOGGLE_TYPE_TEXT:int = 1;
public static var TOGGLE_TYPE_CURSOR:int = 2;
public static var TOGGLE_TYPE_JOIN:int = 3;
private var _mySettings:MovieClip;
private var _popupLayer:DisplayLayer;
private var _closeCallback:Function;
private var _wallPrivacyDropDown:GuiDropdown;
private var _toggleWindows:WindowGenerator;
private var _toggleScrollBar:SBScrollbar;
public function MySettings()
{
super();
}
public function init(initPopupLayer:DisplayLayer, xPos:int, yPos:int, initCloseCallback:Function = null) : void
{
this._popupLayer = initPopupLayer;
this._closeCallback = initCloseCallback;
this._mySettings = GETDEFINITIONBYNAME("MySettings");
this._mySettings.x = xPos;
this._mySettings.y = yPos;
this._popupLayer.addChild(this._mySettings);
this.setupContent();
this.addEventListeners();
}
public function destroy() : void
{
this.removeEventListeners();
this._popupLayer.removeChild(this._mySettings);
this._closeCallback = null;
this._mySettings = null;
if(Boolean(this._toggleWindows))
{
this._toggleWindows.destroy();
this._toggleWindows = null;
}
if(Boolean(this._toggleScrollBar))
{
this._toggleScrollBar.destroy();
this._toggleWindows = null;
}
}
public function updateSoundBtn() : void
{
if(SBAudio.isMusicMuted || SBAudio.areSoundsMuted)
{
this._mySettings.musicToggle.toggleBtn.gotoAndPlay("off");
}
else
{
this._mySettings.musicToggle.toggleBtn.gotoAndPlay("on");
}
}
public function updateWorldMessage() : void
{
}
private function setupContent() : void
{
var numWindowsPerView:int = 0;
var itemWindowHeight:int = 0;
var itemWindowWidth:int = 0;
var daysRemaining:int = 0;
if(Boolean(gMainFrame.userInfo.isMember))
{
this._mySettings.statusNonmember.visible = false;
daysRemaining = int(gMainFrame.clientInfo.numDaysLeftOnSubscription);
if(daysRemaining > 0)
{
this._mySettings.gotoAndStop("memberScrollSubscription");
numWindowsPerView = 5;
}
else
{
this._mySettings.gotoAndStop("memberScroll");
numWindowsPerView = 6;
}
itemWindowHeight = int(this._mySettings.itemWindow.height);
itemWindowWidth = int(this._mySettings.itemWindow.width);
if(daysRemaining > 0)
{
if(daysRemaining > 1)
{
LocalizationManager.translateIdAndInsert(this._mySettings.timeRemaining.timeTxt,11361,daysRemaining);
}
else
{
LocalizationManager.translateIdAndInsert(this._mySettings.timeRemaining.timeTxt,11362,daysRemaining);
}
}
}
else
{
this._mySettings.statusMember.visible = false;
this._mySettings.gotoAndStop("nonMemScroll");
this._mySettings.joinBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onJoinBtn,false,0,true);
numWindowsPerView = 5;
itemWindowHeight = int(this._mySettings.itemWindow.height);
itemWindowWidth = int(this._mySettings.itemWindow.width);
}
var toggleLists:Array = [{
"type":TOGGLE_TYPE_JOIN,
"frame":"world",
"labelTxt":6395,
"btnTxt":6366
},{
"type":TOGGLE_TYPE_TOGGLE_BTN,
"frame":"lock",
"labelTxt":6271,
"onTxt":6393,
"offTxt":6301
},{
"type":TOGGLE_TYPE_TOGGLE_BTN,
"frame":"doorBell",
"labelTxt":18420,
"onTxt":6324,
"offTxt":6322
},{
"type":TOGGLE_TYPE_TOGGLE_BTN,
"frame":"music",
"labelTxt":6373,
"onTxt":6324,
"offTxt":6322
},{
"type":TOGGLE_TYPE_CURSOR,
"frame":"",
"labelTxt":6269
},{
"type":TOGGLE_TYPE_TOGGLE_BTN,
"frame":"buddyRequest",
"labelTxt":6251,
"onTxt":6324,
"offTxt":6322
},{
"type":TOGGLE_TYPE_TOGGLE_BTN,
"frame":"gameInvites",
"labelTxt":6282,
"onTxt":6324,
"offTxt":6322
}];
this._toggleWindows = new WindowGenerator();
this._toggleWindows.init(1,numWindowsPerView,toggleLists.length,0,4,0,ItemWindowToggle,toggleLists,null);
this._mySettings.itemWindow.addChild(this._toggleWindows);
this._toggleScrollBar = new SBScrollbar();
this._toggleScrollBar.init(this._toggleWindows,itemWindowWidth,itemWindowHeight,2,"scrollbar2",this._toggleWindows.boxHeight + 4);
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
if(this._closeCallback != null)
{
this._closeCallback();
}
else
{
this.destroy();
}
}
private function onJoinBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
var url:String = gMainFrame.clientInfo.websiteURL + "membership";
var request:URLRequest = new URLRequest(url);
try
{
navigateToURL(request,"_blank");
}
catch(e:Error)
{
}
}
private function addEventListeners() : void
{
with(this._mySettings)
{
addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
bx.addEventListener(MouseEvent.MOUSE_DOWN,onClose,false,0,true);
}
}
private function removeEventListeners() : void
{
with(this._mySettings)
{
removeEventListener(MouseEvent.MOUSE_DOWN,onPopup);
bx.removeEventListener(MouseEvent.MOUSE_DOWN,onClose);
if(Boolean(joinBtn))
{
joinBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onJoinBtn);
}
}
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,906 @@
package gui
{
import Party.PartyXtCommManager;
import avatar.Avatar;
import avatar.AvatarManager;
import com.sbi.analytics.SBTracker;
import com.sbi.loader.FileServerEvent;
import com.sbi.popup.SBOkPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.utils.getTimer;
import loader.DefPacksDefHelper;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.PetManager;
import room.RoomManagerWorld;
import room.RoomXtCommManager;
public class PartyManager
{
private static var _secToStart:Array;
private static var _secToEnd:Array;
private static var _hours:Array;
private static var _mins:Array;
private static var _partyMediaIds:Array;
private static var _partyDefIds:Array;
private static var _idsLocalized:Array;
private static var _partyDefs:Object;
private static var _xPos:int;
private static var _yPos:int;
private static var _timeStampSinceLastRequest:Number;
private static var _initialTime:Number;
private static var _numSecPassed:int;
private static var _loadingSpiral:LoadingSpiral;
private static var _partyPopup:MovieClip;
private static var _partyBarrier:MovieClip;
private static var _scrollButtons:SBScrollbar;
private static var _itemWindows:WindowGenerator;
private static var _listBuilt:Boolean;
private static var _isInitialRequest:Boolean;
private static var _loadingMediaHelper:MediaHelper;
private static var _partyHeaderDef:int;
private static var _partyHeaderMediaId:int;
private static var _headerSecToStart:Number;
private static var _headerSecToEnd:Number;
private static var _headerHours:Number;
private static var _headerMins:Number;
private static var _headerWindow:ItemWindowParty;
private static var _useHeaderParty:Boolean;
private static var _headerLoadingSpiral:LoadingSpiral;
private static var _adventureHeaderWindow:ItemWindowParty;
private static var _adventureHeaderMediaId:int;
private static var _timeOffset:int;
private static var _requestedOnClick:Boolean;
private static var _hasCreatedPartyPopup:Boolean;
public static const RESTRICTIONS_NONE:int = 0;
public static const RESTRICTIONS_AVATAR:int = 1;
public static const RESTRICTIONS_MEMBERONLY:int = 2;
public static const RESTRICTIONS_PET:int = 4;
public static const RESTRICTIONS_BEYOURPET:int = 8;
private static const REQUEST_INTERVAL:Number = 10000;
private static const PARTY_BARRIER_MEDIA_ID:int = 1299;
public function PartyManager()
{
super();
}
public static function init(initXPos:int, initYPos:int) : void
{
_xPos = initXPos;
_yPos = initYPos;
_hours = [];
_mins = [];
_timeOffset = Math.abs(RoomManagerWorld.instance.shardId) * 10 % 60;
_timeStampSinceLastRequest = 0;
_loadingSpiral = new LoadingSpiral();
_headerLoadingSpiral = new LoadingSpiral();
_partyPopup = GETDEFINITIONBYNAME("PartiesPopup");
_partyPopup.gotoAndStop("noFrame");
_requestedOnClick = false;
}
public static function reload() : void
{
close();
_hasCreatedPartyPopup = false;
_timeOffset = Math.abs(RoomManagerWorld.instance.shardId) * 10 % 60;
_timeStampSinceLastRequest = 0;
_partyPopup = GETDEFINITIONBYNAME("PartiesPopup");
_partyPopup.gotoAndStop("noFrame");
_requestedOnClick = false;
initialDataRequest();
}
public static function open() : void
{
_isInitialRequest = false;
GuiManager.showPartyBtnGlow(false);
if(!_hasCreatedPartyPopup)
{
setupPartiesPopup();
}
else
{
_partyPopup.visible = true;
}
if(Boolean(_partyDefIds))
{
if(shouldRequestNewList())
{
_listBuilt = false;
_numSecPassed = 0;
requestData();
}
else
{
buildPartyWindows();
}
}
else
{
shouldRequestNewList();
requestData();
}
}
public static function close() : void
{
_isInitialRequest = true;
if(Boolean(GuiManager.mainHud.partyBtn))
{
GuiManager.mainHud.partyBtn.downToUpState();
}
_partyPopup.visible = false;
destroyPartyWindows();
if(Boolean(_partyBarrier))
{
DarkenManager.unDarken(_partyBarrier);
}
}
public static function get visible() : Boolean
{
if(Boolean(_partyPopup))
{
return _partyPopup.visible;
}
return false;
}
public static function updateTime() : void
{
var now:Number = NaN;
if(_listBuilt)
{
now = getTimer();
if(now - _initialTime >= REQUEST_INTERVAL)
{
_initialTime = getTimer();
onTimer();
}
}
}
public static function isBeYourPetParty() : Boolean
{
var currPartyDef:Object = null;
if(gMainFrame.clientInfo.roomType == Utility.ROOMTYPE_PARTY)
{
currPartyDef = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
if(currPartyDef != null && currPartyDef.restrictions == RESTRICTIONS_BEYOURPET)
{
return true;
}
}
return false;
}
public static function canSwitchToAvatar(avt:Avatar, displayBarrier:Boolean = false) : Boolean
{
var currPartyDef:Object = null;
if(gMainFrame.clientInfo.roomType == Utility.ROOMTYPE_PARTY)
{
currPartyDef = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
if(currPartyDef != null)
{
if(currPartyDef.restrictions == RESTRICTIONS_AVATAR)
{
if((currPartyDef.avatarDefFlags & 1 << avt.avTypeId - 1) == 0)
{
if(displayBarrier)
{
showPartyBarrier(true);
}
return false;
}
}
else if(currPartyDef.restrictions == RESTRICTIONS_PET)
{
if(!PetManager.checkIfHasPet(avt.enviroTypeFlag))
{
if(displayBarrier)
{
showPartyBarrier(true,true);
}
return false;
}
}
}
}
return true;
}
public static function canSwitchPet(displayBarrier:Boolean = false) : Boolean
{
var currPartyDef:Object = null;
if(gMainFrame.clientInfo.roomType == Utility.ROOMTYPE_PARTY)
{
currPartyDef = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
if(currPartyDef != null && (currPartyDef.restrictions == RESTRICTIONS_PET || currPartyDef.restrictions == RESTRICTIONS_BEYOURPET))
{
if(displayBarrier)
{
showPartyBarrier(true);
}
return false;
}
}
return true;
}
public static function showPartyBarrier(isTryingToSwitch:Boolean = false, doesNotHaveRequiredPet:Boolean = false, secondaryDefId:int = -1) : void
{
var currPartyDef:Object = null;
if(secondaryDefId == -1)
{
secondaryDefId = int(gMainFrame.clientInfo.secondaryDefId);
}
if(Boolean(_partyBarrier))
{
currPartyDef = _partyDefs[secondaryDefId];
if(currPartyDef != null)
{
if(int(currPartyDef.restrictions) == RESTRICTIONS_PET || int(currPartyDef.restrictions) == RESTRICTIONS_BEYOURPET)
{
setupBarrierTextForPets({
"isTryingToSwitch":isTryingToSwitch,
"doesNotHaveRequiredPet":doesNotHaveRequiredPet
});
}
else
{
onAvatarNameLocalization(currPartyDef.avatarDefId,isTryingToSwitch);
}
}
}
else
{
DarkenManager.showLoadingSpiral(true);
_loadingMediaHelper = new MediaHelper();
_loadingMediaHelper.init(PARTY_BARRIER_MEDIA_ID,onMediaItemLoaded,{
"isTryingToSwitch":isTryingToSwitch,
"doesNotHaveRequiredPet":doesNotHaveRequiredPet,
"secondaryDefId":secondaryDefId
});
}
}
public static function getPartyDef(partyDefId:int) : Object
{
return _partyDefs[partyDefId];
}
public static function bringToFront() : void
{
_partyPopup.parent.setChildIndex(_partyPopup,_partyPopup.parent.numChildren - 1);
}
private static function setupPartiesPopup() : void
{
while(_partyPopup.itemWindow.numChildren > 1)
{
_partyPopup.itemWindow.removeChildAt(0);
}
if(_useHeaderParty)
{
while(_partyPopup.itemWindowHeader.numChildren > 1)
{
_partyPopup.itemWindowHeader.removeChildAt(0);
}
while(_partyPopup.itemWindowHeader2.numChildren > 1)
{
_partyPopup.itemWindowHeader2.removeChildAt(0);
}
}
_partyPopup.x = _xPos;
_partyPopup.y = _yPos + 304 * 0.5;
if(_useHeaderParty)
{
_partyPopup.y -= 64;
}
else
{
_partyPopup.y -= 32;
}
_loadingSpiral.setNewParent(_partyPopup.itemWindow,_partyPopup.itemWindow.width * 0.5 + 23.5,_partyPopup.itemWindow.height * 0.5);
if(_useHeaderParty)
{
_headerLoadingSpiral.setNewParent(_partyPopup.itemWindowHeader,_partyPopup.itemWindowHeader.width * 0.5,_partyPopup.itemWindowHeader.height * 0.5);
}
if(!GuiManager.guiLayer.contains(_partyPopup))
{
GuiManager.guiLayer.addChild(_partyPopup);
}
_partyPopup.addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
_partyPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn,false,0,true);
_partyPopup.visible = true;
_hasCreatedPartyPopup = true;
}
private static function buildPartyWindows() : void
{
var headerTime:Object = null;
if(Boolean(_scrollButtons))
{
_scrollButtons.destroy();
_scrollButtons = null;
}
if(Boolean(_itemWindows))
{
_itemWindows.destroy();
_itemWindows = null;
}
if(Boolean(_headerWindow))
{
_headerWindow.destroy();
_headerWindow = null;
}
if(_useHeaderParty)
{
headerTime = Utility.calculateTime(_headerSecToStart);
_headerMins = headerTime.mins;
_headerHours = headerTime.hours;
_headerWindow = new ItemWindowParty(onHeaderLoaded,null,"",0,headerWinMouseDown,null,null,null,{"mediaRefId":[_partyHeaderMediaId]});
}
if(Boolean(_adventureHeaderWindow))
{
_adventureHeaderWindow.destroy();
_adventureHeaderWindow = null;
}
_adventureHeaderWindow = new ItemWindowParty(onHeaderTwoLoaded,null,"",0,adventureHeaderMouseDown,null,null,null,{"mediaRefId":[_adventureHeaderMediaId]});
calculateTime();
var numItemsInCurrentArray:int = int(_partyDefIds.length);
if(numItemsInCurrentArray <= 0)
{
_loadingSpiral.visible = false;
return;
}
_itemWindows = new WindowGenerator();
_itemWindows.init(1,numItemsInCurrentArray,numItemsInCurrentArray,0,0,0,ItemWindowParty,null,"",{"mouseDown":winMouseDown},{"mediaRefId":_partyMediaIds},onItemWindowsCreated);
}
private static function destroyPartyWindows() : void
{
if(Boolean(_scrollButtons))
{
_scrollButtons.destroy();
_scrollButtons = null;
}
if(Boolean(_itemWindows))
{
_itemWindows.destroy();
_itemWindows = null;
}
if(Boolean(_headerWindow))
{
_headerWindow.destroy();
_headerWindow = null;
}
if(Boolean(_adventureHeaderWindow))
{
_adventureHeaderWindow.destroy();
_adventureHeaderWindow = null;
}
}
private static function onItemWindowsCreated() : void
{
var mc:MovieClip = null;
var numItemsInCurrentArray:int = int(_partyDefIds.length);
for(var i:int = 0; i < numItemsInCurrentArray; i++)
{
mc = MovieClip(_itemWindows.bg.getChildAt(i));
mc.defId = int(_partyDefs[_partyDefIds[i]].id);
mc.setupTextAndAnims(_secToStart[i],_secToStart[i] > 0 ? calculatePrintTime(i) : "");
mc.titleText = _partyDefs[_partyDefIds[i]].titleStrId;
}
_loadingSpiral.visible = false;
_partyPopup.itemWindow.addChild(_itemWindows);
_scrollButtons = new SBScrollbar();
_scrollButtons.init(_itemWindows,270,160,0,"scrollbar2",53,0,_partyDefIds.length * 53.1);
_initialTime = getTimer();
_listBuilt = true;
}
private static function onHeaderLoaded(window:MovieClip, index:int = -1) : void
{
_headerWindow.defId = _partyHeaderDef;
_headerWindow.setupTextAndAnims(_headerSecToStart,_headerSecToStart > 0 ? Utility.calculatePrintTime(_headerMins,_headerHours) : "");
_headerWindow.titleText = _partyDefs[_partyHeaderDef].titleStrId;
_headerLoadingSpiral.visible = false;
_partyPopup.itemWindowHeader2.addChild(_headerWindow);
}
private static function onHeaderTwoLoaded(window:MovieClip, index:int = -1) : void
{
_adventureHeaderWindow.setupTextAndAnims(0,"");
_partyPopup.itemWindowHeader.addChild(_adventureHeaderWindow);
}
private static function calculateTime() : void
{
var time:Object = null;
for(var i:int = 0; i < _secToStart.length; i++)
{
time = Utility.calculateTime(_secToStart[i]);
_mins[i] = time.mins;
_hours[i] = time.hours;
}
}
private static function shouldRequestNewList() : Boolean
{
var now:Number = getTimer();
if(now - _timeStampSinceLastRequest > REQUEST_INTERVAL)
{
_timeStampSinceLastRequest = now;
return true;
}
return false;
}
private static function calculatePrintTime(index:int, showFullWords:Boolean = false) : String
{
return Utility.calculatePrintTime(_mins[index],_hours[index],showFullWords);
}
private static function winMouseDown(evt:MouseEvent) : void
{
evt.stopPropagation();
var index:int = int(evt.currentTarget.index);
if(_secToStart[index] - _timeOffset <= 0)
{
if(_secToEnd[index] <= (getTimer() - _initialTime) / 1000)
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14777));
_partyDefIds.splice(index,1);
_partyMediaIds.splice(index,1);
_secToStart.splice(index,1);
_secToEnd.splice(index,1);
_hours.splice(index,1);
_mins.splice(index,1);
rebuildList();
return;
}
DarkenManager.showLoadingSpiral(true);
PartyXtCommManager.sendJoinPartyRequest(evt.currentTarget.defId);
close();
}
else
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14778,calculatePrintTime(index,true)));
}
}
private static function headerWinMouseDown(evt:MouseEvent) : void
{
if(_headerSecToStart <= 0)
{
DarkenManager.showLoadingSpiral(true);
PartyXtCommManager.sendJoinPartyRequest(evt.currentTarget.defId);
close();
}
else
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14778,Utility.calculatePrintTime(_headerMins,_headerHours,true)));
}
}
private static function adventureHeaderMouseDown(evt:MouseEvent) : void
{
DarkenManager.showLoadingSpiral(true);
RoomXtCommManager.sendNonDenRoomJoinRequest("adventures.queststaging_0_360#" + RoomManagerWorld.instance.shardId);
}
private static function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private static function onCloseBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
close();
}
private static function onTimer() : void
{
var shouldRebuildList:Boolean = false;
var currHours:int = 0;
var currMins:int = 0;
var mc:MovieClip = null;
var windowAlive:Boolean = false;
_numSecPassed += REQUEST_INTERVAL / 1000;
for(var i:int = 0; i < _secToStart.length; i++)
{
currHours = int(_hours[i]);
currMins = int(_mins[i]);
if(currHours > 0 || currMins > 0)
{
_secToStart[i] -= REQUEST_INTERVAL / 1000;
if(_secToStart[i] <= 0)
{
currHours = 0;
currMins = 0;
}
else if(_numSecPassed == 60)
{
if(currHours > 0 && currMins == 0)
{
currHours--;
}
if(currMins == 0)
{
currMins = 59;
}
else
{
currMins--;
}
}
_hours[i] = currHours;
_mins[i] = currMins;
windowAlive = Boolean(_itemWindows) && Boolean(_itemWindows.bg) && _itemWindows.bg.numChildren >= i;
if(windowAlive)
{
mc = MovieClip(_itemWindows.bg.getChildAt(i));
}
if(currHours > 0 || currMins > 0)
{
if(windowAlive)
{
mc.setupTextAndAnims(_secToStart[i],calculatePrintTime(i));
}
}
else
{
if(windowAlive)
{
mc.setupTextAndAnims(-1,"");
}
GuiManager.showPartyBtnGlow(true);
}
}
else
{
_secToEnd[i] -= REQUEST_INTERVAL / 1000;
if(_secToEnd[i] <= 0)
{
GuiManager.showPartyBtnGlow(false);
shouldRebuildList = true;
_partyDefIds.splice(i,1);
_partyMediaIds.splice(i,1);
_secToStart.splice(i,1);
_secToEnd.splice(i,1);
_hours.splice(i,1);
_mins.splice(i,1);
i--;
}
}
}
if(_numSecPassed == 60)
{
_numSecPassed = 0;
}
if(shouldRebuildList)
{
_numSecPassed = 0;
rebuildList();
}
}
private static function rebuildList() : void
{
var titleStrId:int = 0;
var uniqueTitleStrs:Array = [];
_partyMediaIds = [];
for(var i:int = 0; i < _partyDefIds.length; i++)
{
titleStrId = int(_partyDefs[_partyDefIds[i]].titleStrId);
if(!uniqueTitleStrs[titleStrId])
{
uniqueTitleStrs[titleStrId] = true;
}
_partyMediaIds[i] = int(_partyDefs[_partyDefIds[i]].mediaRefId);
}
buildPartyWindows();
}
public static function initialDataRequest() : void
{
_isInitialRequest = true;
_timeStampSinceLastRequest = getTimer();
requestData();
}
private static function requestData() : void
{
var dpdh:DefPacksDefHelper = null;
if(Boolean(_partyDefs))
{
requestPartyList();
}
else
{
dpdh = new DefPacksDefHelper();
dpdh.init(DefPacksDefHelper.DEF_PARTY,onPartyDataResponse,null,FileServerEvent.AMF3_TYPE);
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_PARTY] = dpdh;
}
}
private static function onPartyDataResponse(dfdh:DefPacksDefHelper) : void
{
DefPacksDefHelper.mediaArray[DefPacksDefHelper.DEF_PARTY] = null;
_partyDefs = dfdh.def;
}
public static function requestPartyList() : void
{
_requestedOnClick = true;
gMainFrame.server.setXtObject_Str("sl",[]);
}
public static function roomSoireeResponse(data:Object) : void
{
var msg:String = null;
var i:int = 2;
if(data[i++] == "0")
{
msg = data[i++];
if(msg == "NM")
{
DarkenManager.showLoadingSpiral(false);
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14779));
}
else if(msg == "NA")
{
showPartyBarrier(false,false,data[i++]);
}
else if(msg == "NP")
{
DarkenManager.showLoadingSpiral(false);
showPartyBarrier(false,false,data[i++]);
}
}
}
private static function onMediaItemLoaded(img:MovieClip) : void
{
var currPartyDef:Object = null;
if(Boolean(img))
{
_partyBarrier = MovieClip(img.getChildAt(0));
_partyBarrier.addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
_partyBarrier.bx.addEventListener(MouseEvent.MOUSE_DOWN,onBarrierClose,false,0,true);
_partyBarrier.x = MainFrame.VIEW_WIDTH * 0.5;
_partyBarrier.y = MainFrame.VIEW_HEIGHT * 0.5;
_partyBarrier.visible = false;
GuiManager.guiLayer.addChild(_partyBarrier);
currPartyDef = _partyDefs[img.passback.secondaryDefId];
if(currPartyDef != null)
{
if(int(currPartyDef.restrictions) == RESTRICTIONS_PET || int(currPartyDef.restrictions) == RESTRICTIONS_BEYOURPET)
{
setupBarrierTextForPets(img.passback);
}
else
{
onAvatarNameLocalization(currPartyDef.avatarDefId,img.passback.isTryingToSwitch);
}
}
}
}
private static function onBarrierClose(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.unDarken(_partyBarrier);
_partyBarrier.visible = false;
}
private static function onAvatarNameLocalization(avatarDefId:int, passback:Object = null) : void
{
var frameName:String = "Avatar" + avatarDefId;
var localizedAvatarName:String = LocalizationManager.translateIdOnly(gMainFrame.userInfo.getAvatarDefByAvType(avatarDefId).titleStrRef);
if(_partyBarrier.currentFrameLabel != frameName)
{
_partyBarrier.gotoAndStop(frameName);
}
localizedAvatarName = localizedAvatarName.toLowerCase();
var currPluralAvName:String = _partyBarrier.titleTxt.text.split(" ")[0].toLowerCase();
if(Boolean(passback))
{
LocalizationManager.translateIdAndInsert(_partyBarrier.Message_txt,11139,currPluralAvName);
}
else
{
LocalizationManager.translateIdAndInsert(_partyBarrier.Message_txt,11365,currPluralAvName,localizedAvatarName);
}
if(gMainFrame.userInfo.isMember)
{
if(Boolean(passback))
{
SBTracker.trackPageview("/game/play/popup/barrier/#" + frameName + "/member/switch");
}
else
{
SBTracker.trackPageview("/game/play/popup/barrier/#" + frameName + "/member");
}
}
else
{
SBTracker.trackPageview("/game/play/popup/barrier/#" + frameName + "/nonMember");
}
DarkenManager.showLoadingSpiral(false);
_partyBarrier.parent.setChildIndex(_partyBarrier,_partyBarrier.parent.numChildren - 1);
DarkenManager.darken(_partyBarrier);
_partyBarrier.visible = true;
}
private static function setupBarrierTextForPets(passback:Object = null) : void
{
if(_partyBarrier.currentFrameLabel != "Pets")
{
_partyBarrier.gotoAndStop("Pets");
}
if(Boolean(passback))
{
if(Boolean(passback.doesNotHaveRequiredPet))
{
LocalizationManager.translateId(_partyBarrier.Message_txt,18790);
}
else
{
LocalizationManager.translateId(_partyBarrier.Message_txt,11407);
}
}
else if(AvatarManager.roomEnviroType == Utility.ENVIRO_OCEAN)
{
LocalizationManager.translateId(_partyBarrier.Message_txt,11366);
}
else
{
LocalizationManager.translateId(_partyBarrier.Message_txt,11367);
}
if(gMainFrame.userInfo.isMember)
{
if(Boolean(passback))
{
SBTracker.trackPageview("/game/play/popup/barrier/#petParty/member/switch");
}
else
{
SBTracker.trackPageview("/game/play/popup/barrier/#petParty/member");
}
}
else
{
SBTracker.trackPageview("/game/play/popup/barrier/#petParty/nonMember");
}
DarkenManager.showLoadingSpiral(false);
_partyBarrier.parent.setChildIndex(_partyBarrier,_partyBarrier.parent.numChildren - 1);
DarkenManager.darken(_partyBarrier);
_partyBarrier.visible = true;
}
public static function partyListResponse(data:Object) : void
{
var titleStrId:int = 0;
var uniqueTitleStrs:Array = null;
var numParties:int = 0;
var j:int = 0;
var i:int = 0;
if(Boolean(_partyPopup))
{
_partyDefIds = [];
_secToStart = [];
_secToEnd = [];
_partyMediaIds = [];
uniqueTitleStrs = [];
numParties = int(data[3]);
j = 4;
_partyHeaderDef = int(data[2]);
_adventureHeaderMediaId = 2253;
if(_useHeaderParty)
{
_partyPopup.gotoAndStop("twoHeader");
if(Boolean(_partyDefs[_partyHeaderDef]))
{
_partyHeaderMediaId = _partyDefs[_partyHeaderDef].mediaRefId;
_headerSecToStart = 0;
_headerSecToEnd = 0;
}
}
else
{
_partyPopup.gotoAndStop("header");
}
for(i = 0; i < numParties; i++)
{
_partyDefIds[i] = int(data[j]);
if(Boolean(_partyDefs[int(data[j])]))
{
titleStrId = int(_partyDefs[int(data[j])].titleStrId);
if(!uniqueTitleStrs[titleStrId])
{
uniqueTitleStrs[titleStrId] = true;
}
_partyMediaIds[i] = int(_partyDefs[int(data[j++])].mediaRefId);
_secToStart[i] = Number(data[j++]);
if(_secToStart[i] != 0)
{
_secToStart[i] += _timeOffset;
}
_secToEnd[i] = Number(data[j++]);
if(_secToStart[i] == 0 && _isInitialRequest)
{
GuiManager.showPartyBtnGlow(true);
}
}
}
uniqueTitleStrs = null;
if(_partyMediaIds.length > 0)
{
if(!_isInitialRequest)
{
_partyPopup.visible = true;
}
else
{
_isInitialRequest = false;
}
if(_requestedOnClick)
{
buildPartyWindows();
}
}
}
_requestedOnClick = false;
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,685 @@
package gui
{
import avatar.AvatarManager;
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBYesNoPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import game.MinigameManager;
import loader.DefPacksDefHelper;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.GuiPet;
import pet.PetManager;
import pet.PetXtCommManager;
public class PetInventory
{
private static const LOADING_SPIRAL_SMALL:int = 397;
private static const EVT_ICON_ID:int = 44;
private const PET_INVENTORY_MEDIA_ID:int = 993;
private var _guiLayer:DisplayLayer;
private var _mediaHelpers:Array;
private var _loadingMediaHelper:MediaHelper;
private var _closeCallback:Function;
private var _petList:Array;
private var _petViews:Array;
private var _loadingSpiralBig:LoadingSpiral;
private var _inventoryMC:MovieClip;
private var _bigPet:GuiPet;
private var _scrollButtons:SBScrollbar;
private var _itemWindows:WindowGenerator;
private var _isRecycling:Boolean;
private var _activePetModified:Boolean;
private var _noCurrentActivePet:Boolean;
private var _idx:int;
private var _currSelectedIdx:int;
private var _initialPetInvId:int;
private var _recycleOneOnly:Boolean;
private var _hasRecycled:Boolean;
private var _shop:Shop;
private var _previousPetInvId:int;
public function PetInventory()
{
super();
}
public function init(initCloseCallback:Function, recycleOneOnly:Boolean = false) : void
{
DarkenManager.showLoadingSpiral(true);
this._guiLayer = GuiManager.guiLayer;
this._closeCallback = initCloseCallback;
this._mediaHelpers = [];
this._petViews = [];
this._petList = PetManager.myPetList;
this._idx = -1;
this._currSelectedIdx = -1;
this._recycleOneOnly = recycleOneOnly;
this._loadingSpiralBig = new LoadingSpiral();
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/pet/inventory");
this._loadingMediaHelper = new MediaHelper();
this._loadingMediaHelper.init(this.PET_INVENTORY_MEDIA_ID,this.onMediaItemLoaded);
this._mediaHelpers.push(this._loadingMediaHelper);
}
public function destroy() : void
{
var i:int = 0;
this.removeEventListeners();
DarkenManager.unDarken(this._inventoryMC);
this._guiLayer.removeChild(this._inventoryMC);
SBTracker.pop();
this._activePetModified = false;
this._noCurrentActivePet = false;
this._idx = -1;
this._initialPetInvId = -1;
this._currSelectedIdx = -1;
this._isRecycling = false;
this._inventoryMC = null;
this._petList = null;
if(Boolean(this._petViews))
{
for(i = 0; i < this._petViews.length; i++)
{
this._petViews[i].destroy();
}
}
this._petViews = null;
if(Boolean(this._bigPet))
{
this._bigPet.destroy();
this._bigPet = null;
}
if(Boolean(this._scrollButtons))
{
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
for(i = 0; i < this._mediaHelpers.length; i++)
{
this._mediaHelpers[i].destroy();
}
this._mediaHelpers.splice();
if(this._closeCallback != null)
{
if(this._recycleOneOnly)
{
this._closeCallback(this._hasRecycled);
}
else
{
this._closeCallback();
}
this._closeCallback = null;
}
}
private function onMediaItemLoaded(img:MovieClip) : void
{
var i:int = 0;
var myPet:Object = null;
DarkenManager.showLoadingSpiral(false);
if(Boolean(img))
{
this._inventoryMC = MovieClip(img.getChildAt(0));
this._inventoryMC.petNameTxt.text = "";
this._inventoryMC.itemCounter.counterTxt.text = "0/" + PetManager.getPetInventoryMax();
this._inventoryMC.bMastery.visible = false;
this._inventoryMC.helpBubble.visible = false;
if(AvatarManager.roomEnviroType == Utility.ENVIRO_OCEAN)
{
this._inventoryMC.shopBtn.visible = false;
}
if(Boolean(this._petList) && this._petList.length > 0)
{
if(PetManager.myActivePetInvId != 0)
{
for(i = 0; i < this._petList.length; i++)
{
if(this._petList[i].idx == PetManager.myActivePetInvId)
{
this._currSelectedIdx = i;
this._initialPetInvId = this._petList[i].idx;
if(!PetManager.canCurrAvatarUsePet(AvatarManager.playerAvatar.enviroTypeFlag,this._petList[i].type))
{
break;
}
myPet = this._petList[i];
this._bigPet = new GuiPet(myPet.idx,myPet.lBits,myPet.uBits,myPet.eBits,myPet.type,myPet.name,this.onBigPetLoaded);
this._inventoryMC.itemWindowPet.addChild(this._bigPet);
this._inventoryMC.petNameTxt.text = this._bigPet.petName;
this._inventoryMC.butterfly.visible = false;
if(myPet.masteryCounter >= PetManager.MASTERY_ACHIV_MIN_COUNT)
{
this._inventoryMC.bMastery.visible = true;
this._inventoryMC.bMastery.icon.gotoAndStop(PetManager.petNameForDefId(myPet.defId) + "1");
if((myPet.uBits >> 8 & 0x0F) > 0)
{
this._inventoryMC.bMastery.mouse.visible = false;
this._inventoryMC.bMastery.down.visible = true;
}
}
break;
}
}
}
this._inventoryMC.itemCounter.counterTxt.text = this._petList.length + "/" + PetManager.getPetInventoryMax();
}
DarkenManager.showLoadingSpiral(false);
this._inventoryMC.x = MainFrame.VIEW_WIDTH * 0.5;
this._inventoryMC.y = MainFrame.VIEW_HEIGHT * 0.5;
this._guiLayer.addChild(this._inventoryMC);
DarkenManager.darken(this._inventoryMC);
this.createItemWindows();
this.addEventListeners();
}
}
private function onBigPetLoaded(content:MovieClip, guiPet:GuiPet) : void
{
this._bigPet.scaleX = this._bigPet.scaleY = 5;
this._bigPet.y += 83;
}
private function createGuiPets() : void
{
this._petViews = [];
for(var i:int = 0; i < this._petList.length; i++)
{
this._petViews.push(new GuiPet(this._petList[i].idx,this._petList[i].lBits,this._petList[i].uBits,this._petList[i].eBits,this._petList[i].type,this._petList[i].name,null));
}
}
private function createItemWindows() : void
{
if(Boolean(this._scrollButtons))
{
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
while(this._inventoryMC.itemWindow.numChildren > 0)
{
this._inventoryMC.itemWindow.removeChildAt(0);
}
this.createGuiPets();
var numItemsInCurrArray:int = int(this._petList.length);
var xCount:int = Math.min(PetManager.getPetInventoryMax(),4);
var yCount:int = Math.ceil(xCount / 5);
this._itemWindows = new WindowGenerator();
this._itemWindows.init(xCount,yCount,PetManager.getPetInventoryMax(),2,2,1,ItemWindowPets,this._petList,"",{
"mouseDown":this.winMouseDown,
"mouseOver":this.winMouseOver,
"mouseOut":this.winMouseOut
},{"isRecycling":this._isRecycling || this._recycleOneOnly},null,false,false);
this._inventoryMC.itemWindow.addChild(this._itemWindows);
this._loadingSpiralBig.visible = false;
this._scrollButtons = new SBScrollbar();
this._scrollButtons.init(this._itemWindows,344,258,4,"scrollbar2",86);
}
private function onConfirmFreePet(o:Object) : void
{
if(Boolean(o.status))
{
PetXtCommManager.sendPetDismissRequest(this._petList[o.passback].idx,this.freePetCallback);
DarkenManager.showLoadingSpiral(true);
}
}
private function freePetCallback(status:Boolean, wasFound:Boolean, wasActivePet:Boolean) : void
{
DarkenManager.showLoadingSpiral(false);
GuiManager.resetPetWindowListInDen();
if(status)
{
if(wasFound)
{
SBTracker.trackPageview("/game/play/popup/pet/petInventory/free");
--this._idx;
--this._currSelectedIdx;
this._hasRecycled = true;
if(wasActivePet)
{
AvatarManager.playerAvatarWorldView.setActivePet(0,0,0,"");
this._activePetModified = true;
while(this._inventoryMC.itemWindowPet.numChildren > 0)
{
this._inventoryMC.itemWindowPet.removeChildAt(0);
}
this._inventoryMC.petNameTxt.text = "";
this._inventoryMC.butterfly.visible = true;
this._idx = -1;
this._currSelectedIdx = -1;
}
if(!this._recycleOneOnly)
{
this._petList = PetManager.myPetList;
this._inventoryMC.itemCounter.counterTxt.text = this._petList.length + "/" + PetManager.getPetInventoryMax();
this._isRecycling = false;
this._noCurrentActivePet = true;
this.createItemWindows();
}
else
{
this.destroy();
}
}
else
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14786));
}
}
}
private function onPetSwitch(status:Boolean = true) : void
{
DarkenManager.showLoadingSpiral(false);
if(status)
{
this.destroy();
}
else
{
PetManager.myActivePetInvId = this._previousPetInvId;
this.reloadPets();
}
}
private function winMouseDown(evt:MouseEvent) : void
{
var i:int = 0;
var myPet:Object = null;
var mc:MovieClip = null;
evt.stopPropagation();
if((this._isRecycling || this._recycleOneOnly) && Boolean(evt.currentTarget.cageIcon.visible))
{
if(!(PetManager.canCurrAvatarUsePet(AvatarManager.playerAvatar.enviroTypeFlag,this._petList[evt.currentTarget.index].type) && PetManager.myActivePetInvId == this._petList[evt.currentTarget.index].idx && !PartyManager.canSwitchPet(true)))
{
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdOnly(14787),true,this.onConfirmFreePet,evt.currentTarget.index);
}
}
else if(Boolean(evt.currentTarget.newPetIcon.visible))
{
PetManager.openPetFinder("",this.onPetSwitch);
}
else
{
if(Boolean(evt.currentTarget.gray.visible))
{
if(!gMainFrame.userInfo.isMember)
{
UpsellManager.displayPopup(UpsellManager.PETS,"equipMemberPet");
}
return;
}
while(this._inventoryMC.itemWindowPet.numChildren > 0)
{
this._inventoryMC.itemWindowPet.removeChildAt(0);
}
this._idx = evt.currentTarget.index;
this._currSelectedIdx = this._idx;
if((evt.currentTarget.cir.currentFrameLabel == "downMouse" || evt.currentTarget.cir.currentFrameLabel == "down") && PartyManager.canSwitchPet(true))
{
evt.currentTarget.cir.gotoAndStop("up");
if(this._initialPetInvId == 0)
{
this._idx = -1;
}
PetManager.myActivePetInvId = 0;
GuiManager.resetPetWindowListInDen();
this._activePetModified = false;
this._inventoryMC.petNameTxt.text = "";
this._inventoryMC.butterfly.visible = true;
this._inventoryMC.bMastery.visible = false;
this._bigPet.destroy();
this._bigPet = null;
}
else
{
this._activePetModified = true;
this._noCurrentActivePet = false;
for(i = 0; i < this._itemWindows.numWindowsCreated; i++)
{
mc = MovieClip(this._itemWindows.bg.getChildAt(i));
mc.cir.gotoAndStop("up");
}
evt.currentTarget.cir.gotoAndStop("downMouse");
myPet = this._petList[this._idx];
this._bigPet = new GuiPet(myPet.idx,myPet.lBits,myPet.uBits,myPet.eBits,myPet.type,myPet.name,this.onBigPetLoaded);
this._inventoryMC.itemWindowPet.addChild(this._bigPet);
this._inventoryMC.petNameTxt.text = this._bigPet.petName;
this._inventoryMC.butterfly.visible = false;
if(myPet.masteryCounter >= PetManager.MASTERY_ACHIV_MIN_COUNT)
{
this._inventoryMC.bMastery.visible = true;
this._inventoryMC.bMastery.icon.gotoAndStop(PetManager.petNameForDefId(myPet.defId) + "1");
if((myPet.uBits >> 8 & 0x0F) > 0)
{
this._inventoryMC.bMastery.mouse.visible = false;
this._inventoryMC.bMastery.down.visible = true;
}
else
{
this._inventoryMC.bMastery.mouse.visible = true;
this._inventoryMC.bMastery.down.visible = false;
}
}
else
{
this._inventoryMC.bMastery.visible = false;
this._inventoryMC.bMastery.mouse.visible = true;
this._inventoryMC.bMastery.down.visible = false;
}
this._previousPetInvId = PetManager.myActivePetInvId;
if(this._initialPetInvId == myPet.idx)
{
this._idx = -1;
PetManager.myActivePetInvId = this._initialPetInvId;
}
else
{
PetManager.myActivePetInvId = myPet.idx;
}
GuiManager.resetPetWindowListInDen();
}
}
}
private function winMouseOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.numChildren >= 1)
{
if(evt.currentTarget.cir.currentFrameLabel == "down")
{
evt.currentTarget.cir.gotoAndStop("downMouse");
}
else if(evt.currentTarget.cir.currentFrameLabel != "downMouse")
{
evt.currentTarget.cir.gotoAndStop("over");
}
AJAudio.playSubMenuBtnRollover();
}
}
private function winMouseOut(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.numChildren >= 1)
{
if(evt.currentTarget.cir.currentFrameLabel == "downMouse")
{
evt.currentTarget.cir.gotoAndStop("down");
}
else if(evt.currentTarget.cir.currentFrameLabel != "down")
{
evt.currentTarget.cir.gotoAndStop("up");
}
}
}
private function onCageBtn(evt:MouseEvent) : void
{
var i:int = 0;
var mc:MovieClip = null;
evt.stopPropagation();
if(this._isRecycling)
{
this._isRecycling = false;
for(i = 0; i < this._itemWindows.numWindowsCreated; i++)
{
mc = MovieClip(this._itemWindows.bg.getChildAt(i));
mc.cageIcon.visible = false;
}
}
else
{
this._isRecycling = true;
for(i = 0; i < this._itemWindows.numWindowsCreated; i++)
{
mc = MovieClip(this._itemWindows.bg.getChildAt(i));
if(Boolean(mc.hasPet))
{
mc.cageIcon.visible = true;
}
}
}
}
private function onCageOverBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.init(MovieClip(evt.currentTarget),LocalizationManager.translateIdOnly(14674),0,-30);
GuiManager.toolTip.startTimer(evt);
}
private function onCageOutBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private function onMasteryBtn(evt:MouseEvent) : void
{
var cat8:int = 0;
var uBits:int = 0;
var cat6:int = 0;
var cat7:int = 0;
var cat9:int = 0;
var cat10:int = 0;
var cat11:int = 0;
evt.stopPropagation();
var myPet:Object = this._petList[this._currSelectedIdx];
if(myPet != null)
{
cat8 = myPet.uBits >> 8 & 0x0F;
if(cat8 > 0)
{
cat8 = 0;
evt.currentTarget.mouse.visible = true;
evt.currentTarget.down.visible = false;
}
else
{
cat8 = 1;
evt.currentTarget.mouse.visible = false;
evt.currentTarget.down.visible = true;
}
uBits = int(myPet.uBits);
cat6 = uBits & 0x0F;
cat7 = uBits >> 4 & 0x0F;
cat9 = uBits >> 12 & 0x0F;
cat10 = uBits >> 16 & 0x0F;
cat11 = uBits >> 20 & 0x0F;
uBits = cat11 << 20 | cat10 << 16 | cat9 << 12 | cat8 << 8 | cat7 << 4 | cat6;
myPet.uBits = cat8 << 8 | uBits;
if(this._petViews[this._currSelectedIdx] != null)
{
this._petViews[this._currSelectedIdx].updateUBits(myPet.uBits);
}
this._bigPet.updateAllBits(myPet.lBits,myPet.uBits,myPet.eBits);
DarkenManager.showLoadingSpiral(true);
PetXtCommManager.sendPetMasteryRequest(cat8,myPet.idx);
}
}
private function updateActivePet(updatingBeforeGameJoin:Boolean = false) : void
{
var myPet:Object = null;
var callback:Function = null;
if(updatingBeforeGameJoin)
{
callback = this.onPetUpdate;
}
else
{
callback = this.onPetSwitch;
}
if(this._idx > -1)
{
if(Boolean(this._petList) && this._petList.length > 0)
{
myPet = this._petList[this._idx];
if(myPet != null)
{
if(this._activePetModified)
{
DarkenManager.showLoadingSpiral(true);
PetXtCommManager.sendPetSwitchRequest(myPet.idx,callback);
this._activePetModified = false;
return;
}
if(PetManager.myActivePetInvId == 0 && MovieClip(this._itemWindows.bg.getChildAt(this._idx)).cir.currentFrameLabel == "up" && !this._noCurrentActivePet)
{
DarkenManager.showLoadingSpiral(true);
PetXtCommManager.sendPetSwitchRequest(0,callback);
return;
}
}
}
}
if(AvatarManager.playerAvatarWorldView.getActivePet() != null)
{
if(this._bigPet == null)
{
AvatarManager.playerAvatarWorldView.setActivePet(0,0,0,"");
}
else
{
AvatarManager.playerAvatarWorldView.setActivePet(this._bigPet.getLBits(),this._bigPet.getUBits(),this._bigPet.getEBits(),this._bigPet.petName);
}
}
if(!updatingBeforeGameJoin)
{
this.destroy();
}
else
{
callback(true);
}
}
private function reloadPets() : void
{
this._petList = PetManager.myPetList;
while(this._inventoryMC.itemWindowPet.numChildren > 0)
{
this._inventoryMC.itemWindowPet.removeChildAt(0);
}
var myPet:Object = PetManager.myActivePet;
this._bigPet = new GuiPet(myPet.idx,myPet.lBits,myPet.uBits,myPet.eBits,myPet.type,myPet.name,this.onBigPetLoaded);
this._inventoryMC.itemWindowPet.addChild(this._bigPet);
this._inventoryMC.petNameTxt.text = this._bigPet.petName;
this._inventoryMC.butterfly.visible = false;
this.createItemWindows();
if(AvatarManager.playerAvatarWorldView.getActivePet() != null)
{
AvatarManager.playerAvatarWorldView.setActivePet(this._bigPet.getLBits(),this._bigPet.getUBits(),this._bigPet.getEBits(),this._bigPet.petName);
}
}
private function onPetUpdate(status:Boolean) : void
{
var gameObj:Object = null;
DarkenManager.showLoadingSpiral(false);
if(status)
{
gameObj = {"typeDefId":52};
MinigameManager.handleGameClick(gameObj,null,false,this.reloadPets);
}
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
this.updateActivePet();
}
private function onShopBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this._shop = new Shop();
if(AvatarManager.roomEnviroType == Utility.ENVIRO_OCEAN)
{
this._shop.init(GenericListXtCommManager.DEN_ITEM_PET_OCEAN,DefPacksDefHelper.DEF_DEN_ITEM,AvatarManager.playerAvatar,this._guiLayer);
}
else
{
this._shop.init(GenericListXtCommManager.DEN_ITEM_PET_LAND,DefPacksDefHelper.DEF_DEN_ITEM,AvatarManager.playerAvatar,this._guiLayer);
}
}
private function onSalonBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this.updateActivePet(true);
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function addEventListeners() : void
{
this._inventoryMC.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._inventoryMC.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
this._inventoryMC.cageBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onCageBtn,false,0,true);
this._inventoryMC.cageBtn.addEventListener(MouseEvent.MOUSE_OVER,this.onCageOverBtn,false,0,true);
this._inventoryMC.cageBtn.addEventListener(MouseEvent.MOUSE_OUT,this.onCageOutBtn,false,0,true);
this._inventoryMC.bMastery.addEventListener(MouseEvent.MOUSE_DOWN,this.onMasteryBtn,false,0,true);
this._inventoryMC.shopBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onShopBtn,false,0,true);
this._inventoryMC.salonBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSalonBtn,false,0,true);
}
private function removeEventListeners() : void
{
this._inventoryMC.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._inventoryMC.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
this._inventoryMC.cageBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCageBtn);
this._inventoryMC.cageBtn.removeEventListener(MouseEvent.MOUSE_OVER,this.onCageOverBtn);
this._inventoryMC.cageBtn.removeEventListener(MouseEvent.MOUSE_OUT,this.onCageOutBtn);
this._inventoryMC.bMastery.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMasteryBtn);
this._inventoryMC.shopBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onShopBtn);
this._inventoryMC.salonBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSalonBtn);
}
}
}
@@ -0,0 +1,125 @@
package gui
{
import avatar.AvatarManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import pet.GuiPet;
import pet.PetManager;
public class PetMastery
{
private const MASTERY_MEDIA_ID:int = 1381;
private var _masteryPopup:MovieClip;
private var _guiLayer:DisplayLayer;
private var _mediaHelper:MediaHelper;
private var _currPet:GuiPet;
public function PetMastery()
{
super();
}
public function init() : void
{
this._guiLayer = GuiManager.guiLayer;
}
public function displayMasteryPopup() : void
{
if(Boolean(this._masteryPopup))
{
this.setupInitialConditions();
this._guiLayer.addChild(this._masteryPopup);
DarkenManager.darken(this._masteryPopup);
}
else
{
DarkenManager.showLoadingSpiral(true);
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(this.MASTERY_MEDIA_ID,this.onMediaLoaded);
}
}
private function onMediaLoaded(mc:MovieClip) : void
{
if(Boolean(mc))
{
DarkenManager.showLoadingSpiral(false);
this._masteryPopup = MovieClip(mc.getChildAt(0));
this.setupInitialConditions();
this._masteryPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._masteryPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._guiLayer.addChild(this._masteryPopup);
DarkenManager.darken(this._masteryPopup);
this.addEventListeners();
}
}
private function setupInitialConditions() : void
{
var cat8:int = 0;
var uBits:int = 0;
var cat6:int = 0;
var cat7:int = 0;
var cat9:int = 0;
var cat10:int = 0;
var cat11:int = 0;
var myPet:Object = PetManager.myActivePet;
if(Boolean(myPet))
{
cat8 = 1;
uBits = int(myPet.uBits);
cat6 = uBits & 0x0F;
cat7 = uBits >> 4 & 0x0F;
cat9 = uBits >> 12 & 0x0F;
cat10 = uBits >> 16 & 0x0F;
cat11 = uBits >> 20 & 0x0F;
uBits = cat11 << 20 | cat10 << 16 | cat9 << 12 | cat8 << 8 | cat7 << 4 | cat6;
myPet.uBits = cat8 << 8 | uBits;
this._currPet = new GuiPet(myPet.idx,myPet.lBits,myPet.uBits,myPet.eBits,myPet.type,myPet.name,this.onPetLoaded);
while(this._masteryPopup.itemBlock.numChildren > 0)
{
this._masteryPopup.itemBlock.removeChildAt(0);
}
this._masteryPopup.itemBlock.addChild(this._currPet);
AvatarManager.playerAvatarWorldView.setActivePet(this._currPet.getLBits(),this._currPet.getUBits(),this._currPet.getEBits(),this._currPet.name);
}
}
private function onPetLoaded(content:MovieClip, guiPet:GuiPet) : void
{
this._currPet.scaleX = this._currPet.scaleY = 2.5;
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onMasteryClose(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.unDarken(this._masteryPopup);
this._guiLayer.removeChild(this._masteryPopup);
}
private function addEventListeners() : void
{
this._masteryPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._masteryPopup.xb.addEventListener(MouseEvent.MOUSE_DOWN,this.onMasteryClose,false,0,true);
}
private function removeEventListeners() : void
{
this._masteryPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._masteryPopup.xb.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMasteryClose);
}
}
}
@@ -0,0 +1,779 @@
package gui
{
import avatar.Avatar;
import avatar.AvatarEditorView;
import avatar.AvatarManager;
import avatar.AvatarSwitch;
import avatar.AvatarUtility;
import avatar.AvatarView;
import avatar.AvatarXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.client.KeepAlive;
import com.sbi.graphics.JPEGAsyncCompleteEvent;
import com.sbi.graphics.JpegAsynchEncoder;
import com.sbi.graphics.LayerAnim;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBYesNoPopup;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.events.*;
import flash.filters.GlowFilter;
import flash.geom.Matrix;
import flash.geom.Point;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.GuiPet;
import pet.PetManager;
public class PhotoBooth
{
private static var _nameSaveIndex:int = 1;
private const IMAGE_WIDTH:int = 626;
private const IMAGE_HEIGHT:int = 470;
private var _mediaHelper:MediaHelper;
private var _currAvtView:AvatarEditorView;
private var _booth:MovieClip;
private var _myPet:GuiPet;
private var _guiLayer:DisplayLayer;
private var _closeCallback:Function;
private var _numBackgroundFrames:int;
private var _currBackgroundFrame:int;
private var _jpgEncoder:JpegAsynchEncoder;
private var _hudAvtView:AvatarView;
private var _startingFrame:int;
private var _petPosIndex:int;
private var _debugAvtIndex:int;
private var _loadingSpiralAvt:LoadingSpiral;
private var _flip:Boolean;
public function PhotoBooth()
{
super();
}
public function init(closecallback:Function = null) : void
{
DarkenManager.showLoadingSpiral(true);
this._closeCallback = closecallback;
this._guiLayer = GuiManager.guiLayer;
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(2017,this.onMediaLoaded);
}
public function destroy() : void
{
SBTracker.trackPageview("/game/play/popup/photobooth/exit");
KeepAlive.stopKATimer(this._booth);
SafeChatManager.destroy(this._booth.chatTree);
this.removeEventListeners();
DarkenManager.unDarken(this._booth);
this._guiLayer.removeChild(this._booth);
}
private function onMediaLoaded(img:MovieClip) : void
{
DarkenManager.showLoadingSpiral(false);
if(Boolean(img))
{
SBTracker.trackPageview("/game/play/popup/photobooth/enter");
this._booth = MovieClip(img.getChildAt(0));
KeepAlive.startKATimer(this._booth);
this.initializeNeededItems();
this.positionAndDrawAvatarView(true);
this.showHudAvt();
this.loadPetView();
this.addEventListeners();
this._booth.x = MainFrame.VIEW_WIDTH * 0.5;
this._booth.y = MainFrame.VIEW_HEIGHT * 0.5;
DarkenManager.showLoadingSpiral(false);
this._guiLayer.addChild(this._booth);
DarkenManager.darken(this._booth);
}
}
private function initializeNeededItems() : void
{
this._numBackgroundFrames = this._booth.imageCont.backgroundCont.totalFrames;
this._currBackgroundFrame = 1;
this._petPosIndex = -1;
this._booth.imageCont.msgTxt.filters = [new GlowFilter(16777215)];
this._booth.imageCont.petLShadow.visible = false;
this._booth.imageCont.petRShadow.visible = false;
this._booth.posBtn.activateGrayState(true);
this._booth.avtBtn.visible = false;
SafeChatManager.buildSafeChatTree(this._booth.chatTree,"ECardTextTreeNode",SafeChatManager.TREE_PHOTOBOOTH,this.onTextClose,null);
SafeChatManager.closeSafeChat(this._booth.chatTree);
this._booth.imageCont.chatBalloon.visible = false;
this._booth.textBtn.currTxt.text = SafeChatManager.photoBoothNodes[0];
this._booth.imageCont.msgTxt.text = SafeChatManager.photoBoothNodes[0];
this._booth.imageCont.chatBalloon.closeChatBtn.visible = false;
this._booth.bubbleLockToggle.toggleBtn.gotoAndStop("startingOff");
this._booth.bubbleLockToggle.toggleBtn.toggleKnob.gotoAndStop("up");
this._booth.bubbleLockToggle.toggleBtn.toggleBG.gotoAndStop("up");
this._loadingSpiralAvt = new LoadingSpiral(this._booth.imageCont.charBox);
}
private function positionAndDrawAvatarView(reInitView:Boolean = false) : void
{
var offset:Point = null;
if(reInitView)
{
if(Boolean(this._currAvtView))
{
this._startingFrame = this._currAvtView.frame;
if(Boolean(this._currAvtView.parent))
{
this._booth.imageCont.charBox.removeChild(this._currAvtView);
}
}
this._loadingSpiralAvt.setNewParent(this._booth.imageCont.charBox);
this._loadingSpiralAvt.visible = true;
this._currAvtView = new AvatarEditorView();
this._currAvtView.init(AvatarManager.playerAvatar);
}
offset = AvatarUtility.getAvatarPhotoOffset(this._currAvtView.avTypeId);
this._currAvtView.x = offset.x;
this._currAvtView.y = offset.y;
this._currAvtView.visible = false;
this._currAvtView.playAnim(LayerAnim.AN_PHOTO,false,LayerAnim.PLAY_LOOP,this.onAvatarLoaded);
this._currAvtView.scaleX = this.IMAGE_WIDTH / 1024;
this._currAvtView.scaleY = this.IMAGE_HEIGHT / 768;
this._booth.imageCont.charBox.addChild(this._currAvtView);
}
private function loadPetView() : void
{
var myPet:Object = null;
var myPetList:Array = PetManager.myPetList;
this._myPet = null;
for(var i:int = 0; i < myPetList.length; i++)
{
if(myPetList[i].idx == PetManager.myActivePetInvId)
{
myPet = myPetList[i];
if(!PetManager.canCurrAvatarUsePet(AvatarManager.playerAvatar.enviroTypeFlag,myPet.type))
{
break;
}
this._booth.posBtn.activateGrayState(false);
this._myPet = new GuiPet(myPet.idx,myPet.lBits,myPet.uBits,myPet.eBits,myPet.type,myPet.name,this.onPetLoaded);
break;
}
}
if(this._myPet == null)
{
this._booth.posBtn.activateGrayState(true);
while(this._booth.imageCont.itemWindowPet2R.numChildren > 0)
{
this._booth.imageCont.itemWindowPet2R.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet1R.numChildren > 0)
{
this._booth.imageCont.itemWindowPet1R.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet2L.numChildren > 0)
{
this._booth.imageCont.itemWindowPet2L.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet1L.numChildren > 0)
{
this._booth.imageCont.itemWindowPet1L.removeChildAt(0);
}
}
}
private function addEventListeners() : void
{
with(this._booth)
{
addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
bx.addEventListener(MouseEvent.MOUSE_DOWN,onClose,false,0,true);
leftBtn.addEventListener(MouseEvent.MOUSE_DOWN,onLeftRightBtn,false,0,true);
rightBtn.addEventListener(MouseEvent.MOUSE_DOWN,onLeftRightBtn,false,0,true);
actionPose.addEventListener(MouseEvent.MOUSE_DOWN,onActionPoseBtn,false,0,true);
actionPose.addEventListener(MouseEvent.ROLL_OVER,onActionPoseOverHandler,false,0,true);
actionPose.addEventListener(MouseEvent.ROLL_OUT,onOutHandler,false,0,true);
posBtn.addEventListener(MouseEvent.MOUSE_DOWN,onPetPosBtn,false,0,true);
posBtn.addEventListener(MouseEvent.ROLL_OVER,onPetPosOverHandler,false,0,true);
posBtn.addEventListener(MouseEvent.ROLL_OUT,onOutHandler,false,0,true);
addTextBtn.addEventListener(MouseEvent.MOUSE_DOWN,onTextBtn,false,0,true);
camBtn.addEventListener(MouseEvent.MOUSE_DOWN,onSaveBtn,false,0,true);
camBtn.addEventListener(MouseEvent.ROLL_OVER,onSaveOverHandler,false,0,true);
camBtn.addEventListener(MouseEvent.ROLL_OUT,onOutHandler,false,0,true);
char.addEventListener(MouseEvent.MOUSE_DOWN,onCustomize,false,0,true);
char.addEventListener(MouseEvent.ROLL_OVER,charWindowOverHandler,false,0,true);
char.addEventListener(MouseEvent.ROLL_OUT,charWindowOutHandler,false,0,true);
bubbleLockToggle.toggleBtn.addEventListener(MouseEvent.MOUSE_DOWN,onToggleBtn,false,0,true);
bubbleLockToggle.toggleBtn.addEventListener(MouseEvent.MOUSE_OVER,onToggleOver,false,0,true);
bubbleLockToggle.toggleBtn.addEventListener(MouseEvent.MOUSE_OUT,onToggleOut,false,0,true);
}
}
private function removeEventListeners() : void
{
with(this._booth)
{
removeEventListener(MouseEvent.MOUSE_DOWN,onPopup);
bx.removeEventListener(MouseEvent.MOUSE_DOWN,onClose);
leftBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onLeftRightBtn);
rightBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onLeftRightBtn);
actionPose.removeEventListener(MouseEvent.MOUSE_DOWN,onActionPoseBtn);
actionPose.removeEventListener(MouseEvent.ROLL_OVER,onActionPoseOverHandler);
actionPose.removeEventListener(MouseEvent.ROLL_OUT,onOutHandler);
posBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onPetPosBtn);
posBtn.removeEventListener(MouseEvent.ROLL_OVER,onPetPosOverHandler);
posBtn.removeEventListener(MouseEvent.ROLL_OUT,onOutHandler);
addTextBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onTextBtn);
camBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onSaveBtn);
camBtn.removeEventListener(MouseEvent.ROLL_OVER,onSaveOverHandler);
camBtn.removeEventListener(MouseEvent.ROLL_OUT,onOutHandler);
char.removeEventListener(MouseEvent.MOUSE_DOWN,onCustomize);
bubbleLockToggle.toggleBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onToggleBtn);
bubbleLockToggle.toggleBtn.removeEventListener(MouseEvent.MOUSE_OVER,onToggleOver);
bubbleLockToggle.toggleBtn.removeEventListener(MouseEvent.MOUSE_OUT,onToggleOut);
}
}
private function onTextClose(msg:String, code:String) : void
{
this._booth.textBtn.currTxt.text = msg;
this._booth.imageCont.msgTxt.text = msg;
this.setTextVisibility();
SafeChatManager.closeSafeChat(this._booth.chatTree);
}
private function completeSaveAction() : void
{
DarkenManager.showLoadingSpiral(true,true);
var bd:BitmapData = new BitmapData(1024,768);
var scaleMatrix:Matrix = new Matrix(1024 / this.IMAGE_WIDTH,0,0,768 / this.IMAGE_HEIGHT,0,0);
bd.draw(this._booth.imageCont,scaleMatrix,null,null,null,true);
this._jpgEncoder = new JpegAsynchEncoder();
this._jpgEncoder.addEventListener(JPEGAsyncCompleteEvent.JPEGASYNC_COMPLETE,this.asyncEncodingComplete,false,0,true);
this._jpgEncoder.addEventListener(ProgressEvent.PROGRESS,this.onEncodingProgress,false,0,true);
this._jpgEncoder.PixelsPerIteration = 128;
this._jpgEncoder.JPEGAsyncEncoder(100);
this._jpgEncoder.encode(bd);
}
private function showHudAvt() : void
{
var avt:Avatar = AvatarManager.playerAvatar;
if(Boolean(this._hudAvtView))
{
if(this._hudAvtView.parent == this._booth.char.charLayer)
{
this._booth.char.charLayer.removeChild(this._hudAvtView);
}
this._hudAvtView.destroy();
}
this._hudAvtView = new AvatarView();
this._hudAvtView.init(avt);
this._hudAvtView.playAnim(LayerAnim.AN_HUD_AVT,false,LayerAnim.PLAY_ONE_SHOT);
var avatarOffset:Point = AvatarUtility.getAvatarHudPosition(this._hudAvtView.avTypeId);
this._hudAvtView.x = avatarOffset.x;
this._hudAvtView.y = avatarOffset.y;
this._booth.char.charLayer.addChild(this._hudAvtView);
}
private function setTextVisibility() : void
{
if(this._booth.bubbleLockToggle.toggleBtn.currentFrameLabel == "on" || this._booth.bubbleLockToggle.toggleBtn.currentFrameLabel == "startingOn")
{
this._booth.imageCont.msgTxt.visible = false;
}
else
{
this._booth.imageCont.msgTxt.visible = true;
}
}
private function addPetToCorrectSpot(newIndex:int, isNewPet:Boolean = false) : void
{
var matrix:Matrix = null;
if(newIndex > 3)
{
newIndex = 0;
}
var tempIndex:int = newIndex;
if(isNewPet)
{
if(newIndex % 2 != 0)
{
tempIndex = newIndex - 1;
}
}
switch(tempIndex)
{
case 0:
while(this._booth.imageCont.itemWindowPet2R.numChildren > 0)
{
this._booth.imageCont.itemWindowPet2R.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet1R.numChildren > 0)
{
this._booth.imageCont.itemWindowPet1R.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet2L.numChildren > 0)
{
this._booth.imageCont.itemWindowPet2L.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet1L.numChildren > 0)
{
this._booth.imageCont.itemWindowPet1L.removeChildAt(0);
}
if(this._myPet.isGround())
{
this._booth.imageCont.itemWindowPet2L.addChild(this._myPet);
}
else
{
this._booth.imageCont.itemWindowPet1L.addChild(this._myPet);
}
if(tempIndex == newIndex)
{
break;
}
case 1:
matrix = this._myPet.transform.matrix;
matrix.scale(-1,1);
this._myPet.transform.matrix = matrix;
break;
case 2:
while(this._booth.imageCont.itemWindowPet2L.numChildren > 0)
{
this._booth.imageCont.itemWindowPet2L.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet1L.numChildren > 0)
{
this._booth.imageCont.itemWindowPet1L.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet2R.numChildren > 0)
{
this._booth.imageCont.itemWindowPet2R.removeChildAt(0);
}
while(this._booth.imageCont.itemWindowPet1R.numChildren > 0)
{
this._booth.imageCont.itemWindowPet1R.removeChildAt(0);
}
if(this._myPet.isGround())
{
this._booth.imageCont.itemWindowPet2R.addChild(this._myPet);
}
else
{
this._booth.imageCont.itemWindowPet1R.addChild(this._myPet);
}
if(tempIndex == newIndex)
{
break;
}
case 3:
matrix = this._myPet.transform.matrix;
matrix.scale(-1,1);
this._myPet.transform.matrix = matrix;
}
this._petPosIndex = newIndex;
}
private function loadDebugAvatar(avt:Avatar) : void
{
if(Boolean(this._currAvtView))
{
this._startingFrame = this._currAvtView.frame;
if(Boolean(this._currAvtView.parent))
{
this._booth.imageCont.charBox.removeChild(this._currAvtView);
}
}
this._loadingSpiralAvt.setNewParent(this._booth.imageCont.charBox);
this._loadingSpiralAvt.visible = true;
this._currAvtView = new AvatarEditorView();
this._currAvtView.init(avt);
var offset:Point = AvatarUtility.getAvatarPhotoOffset(this._currAvtView.avTypeId);
this._currAvtView.x = offset.x;
this._currAvtView.y = offset.y;
this._currAvtView.visible = false;
this._currAvtView.playAnim(LayerAnim.AN_PHOTO,false,LayerAnim.PLAY_LOOP,this.onAvatarLoaded);
this._currAvtView.scaleX = this.IMAGE_WIDTH / 1024;
this._currAvtView.scaleY = this.IMAGE_HEIGHT / 768;
this._booth.imageCont.charBox.addChild(this._currAvtView);
}
private function onAvatarLoaded(l:LayerAnim, id:int) : void
{
var matrix:Matrix = null;
this._currAvtView.visible = true;
this._currAvtView.pauseAnim(true);
this._currAvtView.frame = this._startingFrame;
this._loadingSpiralAvt.visible = false;
if(this._flip)
{
matrix = this._currAvtView.transform.matrix;
matrix.scale(-1,1);
this._currAvtView.transform.matrix = matrix;
}
else if(this._booth.imageCont.avtShadow.scaleX < 0)
{
this._booth.imageCont.avtShadow.scaleX *= -1;
}
}
private function onPetLoaded(content:MovieClip, guiPet:GuiPet) : void
{
var matrix:Matrix = null;
this._myPet.scaleX = this._myPet.scaleY = 2;
if(this._petPosIndex < 2)
{
matrix = this._myPet.transform.matrix;
matrix.scale(-1,1);
this._myPet.transform.matrix = matrix;
}
this.addPetToCorrectSpot(this._petPosIndex == -1 ? 0 : this._petPosIndex,true);
}
private function onAvatarEditorClose() : void
{
this.positionAndDrawAvatarView(true);
this.showHudAvt();
this.loadPetView();
}
private function flashComplete() : void
{
this.completeSaveAction();
}
private function onSaveImage(o:Object) : void
{
if(Boolean(o.status))
{
SBTracker.trackPageview("/game/play/popup/photobooth/imageSaved");
DarkenManager.showLoadingSpiral(true);
AvatarXtCommManager.sendAvatarPhotoTake(this.onPhotoGemsSpent);
++_nameSaveIndex;
}
}
private function onPhotoGemsSpent(data:Object) : void
{
gMainFrame.clientInfo.gemCount = int(data[2]);
DarkenManager.showLoadingSpiral(false);
AJAudio.playShopCachingSound();
}
private function onSaveForGems(o:Object) : void
{
SBTracker.trackPageview("/game/play/popup/photobooth/saveForGems");
if(Boolean(o.status))
{
DarkenManager.showLoadingSpiral(true);
AvatarXtCommManager.sendAvatarPhotoTakeCheck(this.onGemsSpent);
}
}
private function onGemsSpent(data:Object) : void
{
DarkenManager.showLoadingSpiral(false);
if(data[2] >= 0)
{
this._booth.flash.playFlash(this.flashComplete);
}
else
{
new SBOkPopup(this._guiLayer,LocalizationManager.translateIdOnly(14788));
}
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
if(this._closeCallback != null)
{
this._closeCallback();
this._closeCallback = null;
}
else
{
this.destroy();
}
}
private function onLeftRightBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
KeepAlive.inputReceivedHandler(null);
SBTracker.trackPageview("/game/play/popup/photobooth/leftRight");
if(evt.currentTarget.name == "leftBtn")
{
if(this._currBackgroundFrame - 1 < 1)
{
this._currBackgroundFrame = this._numBackgroundFrames;
}
else
{
--this._currBackgroundFrame;
}
}
else if(evt.currentTarget.name == "rightBtn")
{
if(this._currBackgroundFrame + 1 > this._numBackgroundFrames)
{
this._currBackgroundFrame = 1;
}
else
{
++this._currBackgroundFrame;
}
}
if(this._booth.imageCont.backgroundCont.currentLabels[this._currBackgroundFrame - 1].name.indexOf("ocean") >= 0)
{
if(!Utility.isOcean(AvatarManager.playerAvatar.enviroTypeFlag))
{
this.onLeftRightBtn(evt);
return;
}
}
else if(!Utility.isLand(AvatarManager.playerAvatar.enviroTypeFlag))
{
this.onLeftRightBtn(evt);
return;
}
this._booth.imageCont.backgroundCont.gotoAndStop(this._currBackgroundFrame);
}
private function onActionPoseBtn(evt:MouseEvent) : void
{
var matrix:Matrix = null;
evt.stopPropagation();
KeepAlive.inputReceivedHandler(null);
SBTracker.trackPageview("/game/play/popup/photobooth/poseBtn");
if(Boolean(this._currAvtView))
{
matrix = this._currAvtView.transform.matrix;
matrix.scale(-1,1);
this._currAvtView.transform.matrix = matrix;
this._flip = !this._flip;
this._booth.imageCont.avtShadow.scaleX *= -1;
}
}
private function onActionPoseOverHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.init(this._guiLayer,LocalizationManager.translateIdOnly(14675),evt.currentTarget.x + evt.currentTarget.parent.x,evt.currentTarget.y + evt.currentTarget.parent.y - 27);
GuiManager.toolTip.startTimer(evt);
}
private function onPetPosBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
KeepAlive.inputReceivedHandler(null);
SBTracker.trackPageview("/game/play/popup/photobooth/petPose");
if(Boolean(this._myPet))
{
this.addPetToCorrectSpot(this._petPosIndex + 1);
}
}
private function onPetPosOverHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
if(!evt.currentTarget.isGray)
{
GuiManager.toolTip.init(this._guiLayer,LocalizationManager.translateIdOnly(14676),evt.currentTarget.x + evt.currentTarget.parent.x,evt.currentTarget.y + evt.currentTarget.parent.y - 27);
GuiManager.toolTip.startTimer(evt);
}
}
private function onTextBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
if(!this._booth.chatTree.visible)
{
SafeChatManager.openSafeChat(false,this._booth.chatTree);
}
else
{
SafeChatManager.closeSafeChat(this._booth.chatTree);
}
}
private function onSaveBtn(evt:MouseEvent) : void
{
SBTracker.trackPageview("/game/play/popup/photobooth/save");
evt.stopPropagation();
KeepAlive.inputReceivedHandler(null);
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdAndInsertOnly(14789,50),true,this.onSaveForGems);
}
private function onSaveOverHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.init(this._guiLayer,LocalizationManager.translateIdOnly(14677),evt.currentTarget.x + evt.currentTarget.parent.x,evt.currentTarget.y + evt.currentTarget.parent.y - 41);
GuiManager.toolTip.startTimer(evt);
}
private function onOutHandler(evt:MouseEvent) : void
{
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private function onEncodingProgress(event:ProgressEvent) : void
{
DarkenManager.updateLoadingSpiralPercentage(Math.round(event.bytesLoaded / event.bytesTotal * 100) + "%");
}
private function asyncEncodingComplete(event:JPEGAsyncCompleteEvent) : void
{
this._jpgEncoder.removeEventListener(JPEGAsyncCompleteEvent.JPEGASYNC_COMPLETE,this.asyncEncodingComplete);
this._jpgEncoder.removeEventListener(ProgressEvent.PROGRESS,this.onEncodingProgress);
DarkenManager.showLoadingSpiral(false);
new SBYesNoPopup(this._guiLayer,LocalizationManager.translateIdOnly(14790),true,this.onSaveImage,{
"FileReference":true,
"ImageData":this._jpgEncoder.ImageData,
"SaveName":"AnimalJam_" + _nameSaveIndex + ".jpg"
});
}
private function onCustomize(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.openAvatarEditor(this.onAvatarEditorClose);
GuiManager.toolTip.resetTimerAndSetVisibility();
}
private function charWindowOverHandler(evt:MouseEvent) : void
{
GuiManager.toolTip.init(this._guiLayer,LocalizationManager.translateIdOnly(14673),evt.currentTarget.x + evt.currentTarget.parent.x,evt.currentTarget.y + evt.currentTarget.parent.y - 55);
GuiManager.toolTip.startTimer(evt);
evt.currentTarget.gotoAndStop("over");
AJAudio.playHudBtnRollover();
}
private function charWindowOutHandler(evt:MouseEvent) : void
{
GuiManager.toolTip.resetTimerAndSetVisibility();
evt.currentTarget.gotoAndStop("up");
}
private function onChatBalloonOver(evt:MouseEvent) : void
{
evt.stopPropagation();
this._booth.imageCont.chatBalloon.closeChatBtn.visible = true;
}
private function onChatBalloonOut(evt:MouseEvent) : void
{
evt.stopPropagation();
this._booth.imageCont.chatBalloon.closeChatBtn.visible = false;
}
private function onCloseBalloon(evt:MouseEvent) : void
{
evt.stopPropagation();
this._booth.imageCont.chatBalloon.visible = false;
}
private function onToggleBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.trackPageview("/game/play/popup/photobooth/toggleText");
if(evt.currentTarget.currentFrameLabel == "on" || evt.currentTarget.currentFrameLabel == "startingOn")
{
evt.currentTarget.gotoAndPlay("off");
this._booth.imageCont.msgTxt.visible = true;
}
else
{
evt.currentTarget.gotoAndPlay("on");
this._booth.imageCont.msgTxt.visible = false;
}
}
private function onToggleOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.toggleBG.currentFrameLabel != "over")
{
evt.currentTarget.toggleBG.gotoAndStop("over");
}
if(evt.currentTarget.toggleKnob.currentFrameLabel != "over")
{
evt.currentTarget.toggleKnob.gotoAndStop("over");
}
}
private function onToggleOut(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.toggleBG.currentFrameLabel != "up")
{
evt.currentTarget.toggleBG.gotoAndStop("up");
}
if(evt.currentTarget.toggleKnob.currentFrameLabel != "up")
{
evt.currentTarget.toggleKnob.gotoAndStop("up");
}
}
private function onAvtDebugLoadBtn(evt:MouseEvent) : void
{
var avatarToLoad:Avatar = null;
evt.stopPropagation();
if(this._loadingSpiralAvt.visible)
{
return;
}
++this._debugAvtIndex;
var myAvatar:Array = AvatarSwitch.avatars;
if(this._debugAvtIndex >= AvatarUtility.avatarTypes.length)
{
this._debugAvtIndex = 0;
}
var currAvTypeId:int = int(AvatarUtility.avatarTypes[this._debugAvtIndex]);
for(var i:int = 0; i < myAvatar.length; i++)
{
if(myAvatar[i].avTypeId == currAvTypeId)
{
avatarToLoad = myAvatar[i];
break;
}
}
if(avatarToLoad == null)
{
avatarToLoad = AvatarUtility.creationAvatars[this._debugAvtIndex];
}
if(!Utility.isLand(avatarToLoad.enviroTypeFlag))
{
this.onAvtDebugLoadBtn(evt);
return;
}
this.loadDebugAvatar(avatarToLoad);
}
}
}
@@ -0,0 +1,134 @@
package gui
{
import com.sbi.analytics.SBTracker;
import den.DenXtCommManager;
import flash.display.MovieClip;
import flash.events.*;
import loader.MediaHelper;
import room.RoomManagerWorld;
import room.RoomXtCommManager;
public class PlayerEngagement
{
private var _engagementMediaHelper:MediaHelper;
private var _closeCallBack:Function;
private var _engagementPopup:MovieClip;
private var _currShardId:int;
public function PlayerEngagement()
{
super();
}
public function init(initCloseCallback:Function) : void
{
this._currShardId = RoomManagerWorld.instance.shardId;
this._engagementMediaHelper = new MediaHelper();
this._engagementMediaHelper.init(1567,this.onEngagementLoaded);
this._closeCallBack = initCloseCallback;
}
public function destroy(displayStartPopups:Boolean = false) : void
{
this.removeEventListeners();
DarkenManager.unDarken(this._engagementPopup);
GuiManager.guiLayer.removeChild(this._engagementPopup);
this._engagementPopup = null;
if(this._closeCallBack != null)
{
this._closeCallBack(displayStartPopups);
this._closeCallBack = null;
}
}
private function onEngagementLoaded(mc:MovieClip) : void
{
this._engagementMediaHelper.destroy();
this._engagementPopup = MovieClip(mc.getChildAt(0));
this._engagementPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._engagementPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
GuiManager.guiLayer.addChild(this._engagementPopup);
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._engagementPopup);
this.addEventListeners();
}
private function onDenBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.showLoadingSpiral(true);
SBTracker.trackPageview("/game/play/popup/playerEngagement/#den",-1,SBTracker.TYPE_EVENT);
DenXtCommManager.requestDenJoinFull("den" + gMainFrame.userInfo.myUserName);
this.destroy();
}
private function onVideoBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.showLoadingSpiral(true);
SBTracker.trackPageview("/game/play/popup/playerEngagement/#video",-1,SBTracker.TYPE_EVENT);
RoomXtCommManager.sendNonDenRoomJoinRequest("sarepia.movie_theater#" + this._currShardId);
this.destroy();
}
private function onGamesBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
DarkenManager.showLoadingSpiral(true);
SBTracker.trackPageview("/game/play/popup/playerEngagement/#games",-1,SBTracker.TYPE_EVENT);
RoomXtCommManager.sendNonDenRoomJoinRequest("jamaa_township.room_arcade#" + this._currShardId);
this.destroy();
}
private function onAdventureBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.trackPageview("/game/play/popup/playerEngagement/#adventure",-1,SBTracker.TYPE_EVENT);
RoomXtCommManager.sendNonDenRoomJoinRequest("adventures.queststaging_0_360#" + RoomManagerWorld.instance.shardId);
this.destroy();
}
private function onCloseBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.trackPageview("/game/play/popup/playerEngagement/#close",-1,SBTracker.TYPE_EVENT);
this.destroy();
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function addEventListeners() : void
{
with(this._engagementPopup)
{
denBtn.addEventListener(MouseEvent.MOUSE_DOWN,onDenBtn,false,0,true);
videoBtn.addEventListener(MouseEvent.MOUSE_DOWN,onVideoBtn,false,0,true);
gamesBtn.addEventListener(MouseEvent.MOUSE_DOWN,onGamesBtn,false,0,true);
advBtn.addEventListener(MouseEvent.MOUSE_DOWN,onAdventureBtn,false,0,true);
bx.addEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn,false,0,true);
addEventListener(MouseEvent.MOUSE_DOWN,onPopup,false,0,true);
}
}
private function removeEventListeners() : void
{
with(this._engagementPopup)
{
denBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onDenBtn);
videoBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onVideoBtn);
gamesBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onGamesBtn);
advBtn.removeEventListener(MouseEvent.MOUSE_DOWN,onAdventureBtn);
bx.removeEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn);
removeEventListener(MouseEvent.MOUSE_DOWN,onPopup);
}
}
}
}
@@ -0,0 +1,197 @@
package gui
{
import avatar.AvatarXtCommManager;
import avatar.UserInfo;
import buddy.Buddy;
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import loader.MediaHelper;
import localization.LocalizationManager;
public class PlayerSearch
{
public static const SEARCH_MEDIA_ID:int = 396;
public static const LOADING_SPIRAL_ID:int = 397;
private var _searchPopup:MovieClip;
private var _searchMediaHelper:MediaHelper;
private var _lastSearchedName:String;
public function PlayerSearch()
{
super();
}
public function init() : void
{
this._searchMediaHelper = new MediaHelper();
this._searchMediaHelper.init(SEARCH_MEDIA_ID,this.searchMediaCallback,true);
}
public function destroy() : void
{
this.removeListeners();
this._searchMediaHelper.destroy();
GuiManager.guiLayer.removeChild(this._searchPopup);
DarkenManager.unDarken(this._searchPopup);
this._searchPopup = null;
}
private function searchMediaCallback(img:MovieClip) : void
{
this._searchPopup = MovieClip(img.getChildAt(0));
this._searchPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._searchPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
GuiManager.guiLayer.addChild(this._searchPopup);
this.addListeners();
this.setInitialConditions();
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._searchPopup);
this._searchMediaHelper = new MediaHelper();
this._searchMediaHelper.init(LOADING_SPIRAL_ID,this.loadingSpiralCallback,true);
}
private function loadingSpiralCallback(img:MovieClip) : void
{
if(Boolean(this._searchPopup))
{
this._searchPopup.itemBlock.addChild(img);
this._searchPopup.itemBlock.visible = false;
}
}
private function setInitialConditions() : void
{
this._searchPopup.userNameTxt.text = "";
this._searchPopup.userNameTxt.restrict = "A-Za-z0-9";
this._searchPopup.userNameTxt.maxChars = 32;
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
this._searchPopup.notFoundTab.visible = false;
}
private function popupCloseHandler(e:MouseEvent) : void
{
e.stopPropagation();
this.destroy();
}
private function onSearchBtnHandler(e:MouseEvent) : void
{
e.stopPropagation();
this.performSearch();
}
private function keyDownListener(k:KeyboardEvent) : void
{
k.stopPropagation();
if(k.keyCode == 13)
{
this.performSearch();
}
}
private function performSearch() : void
{
var bud:Buddy = null;
this._searchPopup.notFoundTab.visible = true;
LocalizationManager.translateId(this._searchPopup.notFoundTab.getChildAt(1),11369);
var userName:String = this._searchPopup.userNameTxt.text;
if(gMainFrame.userInfo.myUserName.toLowerCase() == userName.toLowerCase())
{
LocalizationManager.translateId(this._searchPopup.notFoundTab.getChildAt(1),11370);
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
return;
}
var lcUserName:String = userName.toLowerCase();
if(this._lastSearchedName != lcUserName)
{
this._lastSearchedName = lcUserName;
bud = BuddyManager.getBuddyByUserName(lcUserName);
if(Boolean(bud))
{
this._searchPopup.notFoundTab.visible = false;
BuddyCard.showBuddyCard({
"userName":bud.userName,
"onlineStatus":bud.onlineStatus
});
this.destroy();
}
else
{
this._searchPopup.notFoundTab.visible = false;
this._searchPopup.itemBlock.visible = true;
AvatarXtCommManager.requestAvatarGet(userName,this.onUserLookUpReceived,true);
}
}
}
private function onUserLookUpReceived(userName:String, status:Boolean, onlineStatus:int) : void
{
var ui:UserInfo = null;
if(Boolean(this._searchPopup))
{
this._searchPopup.itemBlock.visible = false;
ui = gMainFrame.userInfo.getUserInfoByUserName(userName);
if(status)
{
if(Boolean(ui))
{
if(ui.userNameModeratedFlag > 0 && userName.toLowerCase() == this._searchPopup.userNameTxt.text.toLowerCase())
{
BuddyCard.showBuddyCard({
"userName":userName,
"onlineStatus":onlineStatus
});
this.destroy();
}
else
{
this._searchPopup.notFoundTab.visible = true;
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
}
}
else
{
BuddyCard.showBuddyCard({
"userName":userName,
"onlineStatus":onlineStatus
});
this.destroy();
}
}
else
{
this._searchPopup.notFoundTab.visible = true;
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
}
}
}
private function onPopup(e:MouseEvent) : void
{
e.stopPropagation();
}
private function addListeners() : void
{
this._searchPopup["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler,false,0,true);
this._searchPopup.searchBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSearchBtnHandler,false,0,true);
this._searchPopup.userNameTxt.addEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener,false,0,true);
this._searchPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
}
private function removeListeners() : void
{
this._searchPopup["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler);
this._searchPopup.searchBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSearchBtnHandler);
this._searchPopup.userNameTxt.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener);
this._searchPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
}
}
}
@@ -0,0 +1,172 @@
package gui
{
import achievement.AchievementXtCommManager;
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBPollPopup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import loader.PollDefHelper;
import localization.LocalizationManager;
public class PollManager
{
private static var _pollDefCache:Array;
private static var _pollLocs:Array;
private static var _pollDefHelpers:Array;
private static var _tabMediaHelper:MediaHelper;
private static var _tabTemplate:MovieClip;
private static var _guiLayer:DisplayLayer;
private static var _worldLayer:DisplayLayer;
private static var _pollPopup:SBPollPopup;
private static const POLL_MEDIA_ID_TAB:int = 153;
private static const POLL_TAB_FRAME_LABEL:String = "poll";
private static const POLL_IMAGE_TAB_FRAME_LABEL:String = "tshirtPoll";
private static const POLL_COUNT_USERVAR:int = 113;
public function PollManager()
{
super();
}
public static function init(initGuiLayer:DisplayLayer, initWorldLayer:DisplayLayer) : void
{
_guiLayer = initGuiLayer;
_worldLayer = initWorldLayer;
_pollDefCache = [];
_tabMediaHelper = new MediaHelper();
_tabMediaHelper.init(POLL_MEDIA_ID_TAB,mediaHelperHandler,true);
}
public static function setUpPolls(pollDefIds:Array, pollLocs:Array) : void
{
var def:Object = null;
var pdh:PollDefHelper = null;
_pollLocs = pollLocs;
_pollDefHelpers = [];
for(var i:int = 0; i < pollDefIds.length; i++)
{
def = _pollDefCache[pollDefIds[i]];
if(!def)
{
pdh = new PollDefHelper();
pdh.init(pollDefIds[i],onPollDefReceived);
_pollDefHelpers[pollDefIds[i]] = pdh;
}
else
{
setUpPoll(def);
}
}
}
private static function onPollDefReceived(pdh:PollDefHelper) : void
{
var o:Object = pdh.def;
var def:Object = {
"id":int(o.id),
"mediaId":int(o.mediaRef),
"userVarId":int(o.userVarRef),
"poll":LocalizationManager.translateIdOnly(int(o.pollStrRef)),
"title":LocalizationManager.translateIdOnly(int(o.titleStrRef))
};
_pollDefCache[def.id] = def;
_pollDefHelpers[def.id] = null;
setUpPoll(def);
}
private static function setUpPoll(def:Object) : void
{
var tab:MovieClip = null;
var defId:int = 0;
if(gMainFrame.userInfo.userVarCache.getUserVarValueById(int(def.userVarId)) < 0)
{
if(Boolean(_tabTemplate))
{
tab = new _tabTemplate.constructor();
tab.def = def;
defId = int(tab.id = int(def.id));
tab.x = _pollLocs[defId].x;
tab.y = _pollLocs[defId].y;
if(def.id == 27)
{
tab.gotoAndPlay(POLL_IMAGE_TAB_FRAME_LABEL);
}
else
{
tab.gotoAndPlay(POLL_TAB_FRAME_LABEL);
}
tab.addEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown,false,0,true);
_worldLayer.addChild(tab);
}
}
}
private static function mediaHelperHandler(mc:MovieClip) : void
{
var pid:int = int(mc.mediaHelper.id);
_tabTemplate = MovieClip(mc.getChildAt(0));
_tabMediaHelper.destroy();
_tabMediaHelper = null;
}
private static function onTabMouseDown(m:MouseEvent) : void
{
m.stopPropagation();
var tab:MovieClip = MovieClip(m.currentTarget);
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/vote/" + tab.def.id);
if(m.currentTarget.currentFrameLabel == POLL_IMAGE_TAB_FRAME_LABEL)
{
ImagePoll.displayPoll(tab.def.userVarId,ImagePoll.POLL_MEDIA_ID,ImagePoll.TSHIRT_IMAGES_MEDIA_ID,10,3,tab,onImagePollClose);
}
else
{
DarkenManager.showLoadingSpiral(true);
_pollPopup = new SBPollPopup();
_pollPopup.init(_guiLayer,tab,onPollVote,onPollDone,true);
}
}
private static function onImagePollClose(tab:MovieClip) : void
{
if(Boolean(tab.parent))
{
tab.parent.removeChild(tab);
}
tab.removeEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown);
SBTracker.pop();
}
private static function onPollVote(tab:MovieClip, option:int) : void
{
if(Boolean(tab.parent))
{
tab.parent.removeChild(tab);
}
tab.removeEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown);
AchievementXtCommManager.requestSetUserVar(tab.def.userVarId,option);
AchievementXtCommManager.requestSetUserVar(POLL_COUNT_USERVAR,1);
}
private static function onPollDone() : void
{
SBTracker.pop();
_pollPopup.destroy();
_pollPopup = null;
}
}
}
@@ -0,0 +1,654 @@
package gui
{
import com.sbi.loader.FileServerEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import loader.DefPacksDefHelper;
import localization.LocalizationManager;
public class PredictiveTextManager
{
private static var _predictiveTreesToFullFill:Array;
private static var _lastRequestedLanguage:int;
private static var _hasRequestedWords:Boolean;
public static const USE_TYPE_ALL:int = 0;
public static const USE_TYPE_ECARD:int = 1;
private const DEFAULT_WORD_VALIDITY:int = -1;
private const DOES_NOT_CONTAIN_WORD:int = 0;
private const CONTAINS_WORD_IS_NOT_A_WORD:int = 1;
private const IS_A_WORD:int = 2;
private const IS_A_SPECIAL_CHARACTER:int = 3;
private var _predictiveTree:PredictiveTextTree;
private var _chatMsgText:TextField;
private var _predictiveTextMC:MovieClip;
private var _chatBar:MovieClip;
private var _sendMsgCallback:Function;
private var _completeSuggestionCallback:Function;
private var _wordValidity:int;
private var _currWordStartIndex:int;
private var _currWordEndIndex:int;
private var _currWordLength:int;
private var _isShiftOn:Boolean;
private var _writtenWordsLength:Array;
private var _wasBackspaced:Boolean;
public function PredictiveTextManager()
{
super();
}
public static function requestAndCreateTextTreeNode() : void
{
_hasRequestedWords = true;
var dpdh:DefPacksDefHelper = new DefPacksDefHelper();
dpdh.init(uint(DefPacksDefHelper.PREDICTIVE_TEXT_FILE_TO_APPEND_TO + "" + LocalizationManager.currentLanguage),wordListResponse,null,FileServerEvent.PLAIN_TEXT_TYPE);
DefPacksDefHelper.mediaArray[1] = dpdh;
}
public static function get findPredictiveTextNodeIfPossible() : PredictiveTextNode
{
if(_hasRequestedWords && PredictiveTextTree.defaultRoot != null && _lastRequestedLanguage == LocalizationManager.currentLanguage)
{
return PredictiveTextTree.defaultRoot;
}
return null;
}
public static function get lastRequestedPredictiveLanguage() : int
{
return _lastRequestedLanguage;
}
public static function get hasRequestWordsList() : Boolean
{
return _hasRequestedWords;
}
private static function wordListResponse(df:DefPacksDefHelper) : void
{
DefPacksDefHelper.mediaArray[DefPacksDefHelper.PREDICTIVE_TEXT_FILE_TO_APPEND_TO + "" + LocalizationManager.currentLanguage] = null;
var str:String = df.def.toString().toLowerCase() as String;
var arr:Array = str.split("\r\n");
var arrLength:int = int(arr.length);
PredictiveTextTree.init();
for(var i:int = 0; i < arrLength; i++)
{
PredictiveTextTree.addFromStart(arr[i].split(","));
}
PredictiveTextTree.optimizeTree(PredictiveTextTree.defaultRoot);
if(Boolean(_predictiveTreesToFullFill))
{
for(i = 0; i < _predictiveTreesToFullFill.length; i++)
{
_predictiveTreesToFullFill[i].predictiveTree.updateRoot(PredictiveTextTree.defaultRoot);
}
_predictiveTreesToFullFill = null;
}
_lastRequestedLanguage = LocalizationManager.currentLanguage;
}
public function init(chatMessageText:TextField, initPredictiveTextNode:PredictiveTextNode, useType:int = 0, predictiveText:MovieClip = null, chatBarContainer:MovieClip = null, sendMessageCallback:Function = null, completeSuggestionCallback:Function = null) : void
{
this._chatBar = chatBarContainer;
this._chatMsgText = chatMessageText;
this._predictiveTextMC = predictiveText;
this._sendMsgCallback = sendMessageCallback;
this._completeSuggestionCallback = completeSuggestionCallback;
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC.visible = false;
this._predictiveTextMC["predictTxtTag0"].addEventListener(MouseEvent.MOUSE_DOWN,this.onPredictiveTag,false,0,true);
}
this._wordValidity = this.IS_A_WORD;
this._chatMsgText.restrict = "";
this._chatMsgText.defaultTextFormat.color = 4531987;
this._chatMsgText.tabEnabled = false;
this._writtenWordsLength = [];
this._predictiveTree = new PredictiveTextTree(initPredictiveTextNode,useType);
if(initPredictiveTextNode == null)
{
if(_predictiveTreesToFullFill == null)
{
_predictiveTreesToFullFill = [];
}
_predictiveTreesToFullFill.push(this);
}
}
public function reload(chatMessageText:TextField, predictiveText:MovieClip = null, chatBarContainer:MovieClip = null) : void
{
this._chatBar = chatBarContainer;
this._chatMsgText = chatMessageText;
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC["predictTxtTag0"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onPredictiveTag);
}
this._predictiveTextMC = predictiveText;
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC.visible = false;
this._predictiveTextMC["predictTxtTag0"].addEventListener(MouseEvent.MOUSE_DOWN,this.onPredictiveTag,false,0,true);
}
this._wordValidity = this.IS_A_WORD;
this._chatMsgText.restrict = "";
this._chatMsgText.defaultTextFormat.color = 4531987;
this._chatMsgText.tabEnabled = false;
this._writtenWordsLength = [];
}
public function destroy() : void
{
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC["predictTxtTag0"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onPredictiveTag);
}
this._predictiveTree.destroy();
this._chatBar = null;
this._chatMsgText = null;
this._predictiveTextMC = null;
this._sendMsgCallback = null;
this._completeSuggestionCallback = null;
}
public function get predictiveTree() : PredictiveTextTree
{
return this._predictiveTree;
}
public function get currentRestriction() : String
{
return this._predictiveTree.currentRestriction;
}
public function onTextFieldChanged(evt:Event) : void
{
var modifyCurrEndIndexAfterFormatting:Boolean = false;
if(this._wasBackspaced)
{
this._wasBackspaced = false;
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
this._predictiveTree.backspaced();
AJAudio.playTextType();
if(this._currWordLength == 0)
{
this._currWordLength = this._writtenWordsLength.pop();
}
else
{
--this._currWordLength;
}
if(this._currWordEndIndex - 1 < this._currWordStartIndex)
{
if(this._currWordEndIndex > 0)
{
this.findWhereLastWordStarts();
modifyCurrEndIndexAfterFormatting = true;
}
}
else if(this._currWordEndIndex > 0)
{
--this._currWordEndIndex;
this.setPredictiveTextField();
}
if(this._currWordEndIndex == 0)
{
this._writtenWordsLength.splice(0,this._writtenWordsLength.length);
this._currWordLength = 0;
this._wordValidity = this.IS_A_WORD;
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC.visible = false;
}
}
else
{
this._wordValidity = this._predictiveTree.checkCurrentWordValidity();
}
this.setTxtFormat();
if(modifyCurrEndIndexAfterFormatting)
{
--this._currWordEndIndex;
modifyCurrEndIndexAfterFormatting = false;
}
if(Boolean(this._chatBar))
{
this._chatBar.chatBGColor.white.visible = true;
}
this._chatMsgText.restrict = this._predictiveTree.currentRestriction;
}
}
public function onKeyUp(evt:KeyboardEvent) : void
{
if(evt.keyCode == Keyboard.SHIFT)
{
this._isShiftOn = false;
}
if(this._chatMsgText.type != TextFieldType.INPUT)
{
this._chatMsgText.type = TextFieldType.INPUT;
this._chatMsgText.selectable = true;
}
if(evt.keyCode > 36 && evt.keyCode < 41)
{
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
}
}
public function onKeyDown(evt:KeyboardEvent, textFieldInput:String) : void
{
var periodMatch:Array = null;
var questionMarkMatch:Array = null;
var format:TextFormat = null;
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
var regEx:RegExp = new RegExp("[:)(\'.,?!" + this.currentRestriction + "]","g");
if(evt.ctrlKey || evt.altKey || evt.keyCode == Keyboard.ALTERNATE)
{
if(evt.keyCode == Keyboard.BACKSPACE)
{
this._chatMsgText.type = TextFieldType.DYNAMIC;
this._chatMsgText.selectable = false;
}
return;
}
if(this._chatMsgText.type != TextFieldType.INPUT)
{
this._chatMsgText.type = TextFieldType.INPUT;
this._chatMsgText.selectable = true;
}
var regExpMatch:Array = textFieldInput != null ? textFieldInput.toLowerCase().match(regEx) : null;
if(evt.keyCode != Keyboard.ENTER && evt.keyCode != Keyboard.BACKSPACE && (this._chatMsgText.maxChars > 0 ? Boolean(this._chatMsgText.length >= this._chatMsgText.maxChars) : Boolean(false)))
{
return;
}
if(evt.keyCode == Keyboard.TAB)
{
AJAudio.playTextType();
this.onPredictiveTag(null);
return;
}
if(evt.keyCode == Keyboard.ENTER)
{
if(this._chatMsgText.text.length > 0 && this._wordValidity >= this.IS_A_WORD)
{
if(this._sendMsgCallback != null)
{
this._sendMsgCallback(null);
this.resetTreeSearch();
}
}
AJAudio.playTextEnter();
}
else
{
if(evt.keyCode == Keyboard.BACKSPACE)
{
this._wasBackspaced = true;
return;
}
if(evt.keyCode == Keyboard.SHIFT)
{
this._isShiftOn = true;
}
else if(regExpMatch != null && regExpMatch.length != 0 && regExpMatch.length == textFieldInput.length)
{
AJAudio.playTextType();
periodMatch = textFieldInput.toLowerCase().match(/[\.,]/g);
questionMarkMatch = textFieldInput.toLowerCase().match(/[?!]/g);
if(periodMatch != null && periodMatch.length != 0 && periodMatch.length == textFieldInput.length)
{
if(this._wordValidity > 1)
{
++this._currWordEndIndex;
++this._currWordLength;
this._predictiveTree.onSpecialCharacter();
this._wordValidity = this.IS_A_SPECIAL_CHARACTER;
this._chatMsgText.appendText(textFieldInput);
this.setTxtFormat();
this.setPredictiveTextField();
}
}
else if(questionMarkMatch != null && questionMarkMatch.length != 0 && questionMarkMatch.length == textFieldInput.length)
{
if(this._wordValidity > 1)
{
if(this._isShiftOn)
{
++this._currWordEndIndex;
++this._currWordLength;
this._wordValidity = this.IS_A_SPECIAL_CHARACTER;
this._predictiveTree.onSpecialCharacter();
this._chatMsgText.appendText(textFieldInput);
this.setTxtFormat();
this.setPredictiveTextField();
}
}
}
else
{
if(!(this._wordValidity != this.DOES_NOT_CONTAIN_WORD && this._wordValidity != this.IS_A_SPECIAL_CHARACTER && evt.charCode > 0))
{
AJAudio.playLimitedChatErrorSound();
if(Boolean(this._chatBar))
{
this._chatBar.chatBGColor.white.visible = false;
}
return;
}
++this._currWordEndIndex;
++this._currWordLength;
this._wordValidity = this._predictiveTree.containsString(textFieldInput.toLowerCase());
this._chatMsgText.appendText(textFieldInput);
this.setTxtFormat();
this.setPredictiveTextField();
}
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
}
else if(evt.keyCode == Keyboard.SPACE)
{
if(this._wordValidity != this.DOES_NOT_CONTAIN_WORD)
{
format = new TextFormat();
if(this._wordValidity == this.DEFAULT_WORD_VALIDITY)
{
this._wordValidity = this._predictiveTree.checkCurrentWordValidity();
}
if(this._wordValidity > this.CONTAINS_WORD_IS_NOT_A_WORD)
{
AJAudio.playTextType();
format.bold = true;
this._chatMsgText.appendText(" ");
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
this._predictiveTree.onSpacebar();
format.color = 4531987;
++this._currWordEndIndex;
this._writtenWordsLength.push(this._currWordLength);
this._currWordLength = 0;
if(this._currWordStartIndex <= 0)
{
this._chatMsgText.setTextFormat(format);
}
else
{
this._chatMsgText.setTextFormat(format,this._currWordStartIndex,this._currWordEndIndex);
}
this._currWordStartIndex = this._currWordEndIndex;
this._wordValidity = this.IS_A_WORD;
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC.visible = false;
}
}
else
{
this._wordValidity = this.DEFAULT_WORD_VALIDITY;
if(this._chatMsgText.text.charAt(this._chatMsgText.length - 1) != " ")
{
if(Boolean(this._chatBar))
{
this._chatBar.chatBGColor.white.visible = false;
}
format.bold = false;
format.color = 16711680;
if(this._currWordStartIndex <= 0)
{
this._chatMsgText.setTextFormat(format);
}
else
{
this._chatMsgText.setTextFormat(format,this._currWordStartIndex,this._currWordEndIndex);
}
}
}
}
}
}
this._chatMsgText.restrict = this._predictiveTree.currentRestriction;
}
public function resetTreeSearch() : void
{
this._currWordStartIndex = 0;
this._currWordEndIndex = 0;
this._currWordLength = 0;
this._writtenWordsLength.splice(0,this._writtenWordsLength.length);
this._wordValidity = this.IS_A_WORD;
this._isShiftOn = false;
this._predictiveTree.resetSearchTree();
if(Boolean(this._predictiveTextMC))
{
this._predictiveTextMC.visible = false;
}
if(Boolean(this._chatBar))
{
this._chatBar.chatBGColor.white.visible = true;
}
this.setTxtFormat();
this._chatMsgText.scrollV = 0;
this._chatMsgText.text = "";
this._chatMsgText.restrict = this._predictiveTree.currentRestriction;
}
public function onSendBtnDown(evt:MouseEvent) : void
{
if(this._chatMsgText.text.length > 0 && this._wordValidity >= this.IS_A_WORD)
{
if(Boolean(this._chatMsgText.text.match("\r")))
{
return;
}
if(this._sendMsgCallback != null)
{
this._sendMsgCallback(evt);
this.resetTreeSearch();
}
}
}
public function isWordValid() : Boolean
{
return this._wordValidity >= this.IS_A_WORD;
}
private function onPredictiveTag(evt:MouseEvent) : void
{
var txt:String = null;
if(Boolean(evt))
{
evt.stopPropagation();
}
if(Boolean(this._predictiveTextMC) && this._predictiveTextMC.visible)
{
txt = this._predictiveTextMC.predictTxtTag0.txt.text;
txt = txt.substr(this._currWordLength);
if(this._completeSuggestionCallback != null)
{
this._completeSuggestionCallback(txt,false,this.onPredictiveTxtTagWork);
}
else
{
this.onPredictiveTxtTagWork(txt);
}
}
}
private function onPredictiveTxtTagWork(txt:String, allow:Boolean = true) : void
{
var format:TextFormat = null;
var txtArray:Array = null;
var i:int = 0;
if(allow)
{
format = new TextFormat();
if(txt != "")
{
txtArray = txt.split("");
for(i = 0; i < txtArray.length; i++)
{
this._predictiveTree.containsString(txtArray[i]);
}
this._currWordEndIndex += txt.length;
this._currWordLength += txt.length;
this._chatMsgText.appendText(txt);
}
format.bold = true;
this._chatMsgText.appendText(" ");
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
this._predictiveTree.onSpacebar();
format.color = 4531987;
++this._currWordEndIndex;
this._writtenWordsLength.push(this._currWordLength);
this._currWordLength = 0;
this._chatMsgText.setTextFormat(format,this._currWordStartIndex,this._currWordEndIndex);
this._currWordStartIndex = this._currWordEndIndex;
this._wordValidity = this.IS_A_WORD;
this._predictiveTextMC.visible = false;
if(this._currWordEndIndex != this._currWordStartIndex)
{
this.setTxtFormat();
}
this._predictiveTree.clearWordSuggestions();
this._predictiveTextMC.visible = false;
gMainFrame.stage.focus = this._chatMsgText;
this._chatMsgText.setSelection(this._chatMsgText.length,this._chatMsgText.length);
this._chatMsgText.restrict = this._predictiveTree.currentRestriction;
if(this._completeSuggestionCallback != null)
{
this._completeSuggestionCallback("",true);
}
}
}
private function setPredictiveTextField() : void
{
var predictiveWord:String = null;
if(Boolean(this._predictiveTextMC))
{
if(this._chatMsgText.length > 0 && (this._wordValidity == this.IS_A_WORD || this._wordValidity == this.CONTAINS_WORD_IS_NOT_A_WORD))
{
predictiveWord = this._predictiveTree.showTopWord();
if(predictiveWord != null)
{
this._predictiveTextMC.visible = true;
this._predictiveTextMC.gotoAndStop(1);
this._predictiveTextMC["predictTxtTag0"].setText(predictiveWord);
}
else
{
this._predictiveTextMC.visible = false;
}
}
else
{
this._predictiveTextMC.visible = false;
}
}
}
private function setTxtFormat() : void
{
var format:TextFormat = new TextFormat();
if(this._currWordEndIndex == 0 && this._currWordStartIndex == 0)
{
this._wordValidity == this.IS_A_WORD;
}
if(this._wordValidity > this.CONTAINS_WORD_IS_NOT_A_WORD)
{
this._chatMsgText.textColor = 4531987;
if(Boolean(this._chatBar))
{
this._chatBar.chatBGColor.white.visible = true;
}
format.bold = false;
format.color = 4531987;
if(this._currWordStartIndex <= 0)
{
this._chatMsgText.setTextFormat(format);
}
else
{
this._chatMsgText.setTextFormat(format,this._currWordStartIndex,this._currWordEndIndex);
}
}
else
{
if(this._wordValidity == this.DOES_NOT_CONTAIN_WORD)
{
if(Boolean(this._chatBar))
{
this._chatBar.chatBGColor.white.visible = false;
}
}
format.bold = false;
format.color = 16711680;
if(this._currWordStartIndex <= 0)
{
this._chatMsgText.setTextFormat(format);
}
else
{
this._chatMsgText.setTextFormat(format,this._currWordStartIndex,this._currWordEndIndex);
}
}
}
private function findWhereLastWordStarts() : void
{
var skippedFirstSpace:Boolean = false;
var i:int = 0;
if(this._currWordStartIndex - 1 >= 0)
{
skippedFirstSpace = false;
for(i = this._currWordStartIndex - 1; i >= 0; i--)
{
if(this._chatMsgText.text.charAt(i) == " ")
{
if(i != this._currWordStartIndex - 1)
{
this.setPredictiveTextField();
this._currWordEndIndex = skippedFirstSpace ? this._currWordStartIndex : int(this._currWordStartIndex - 1);
this._currWordStartIndex = i == this._currWordStartIndex - 1 ? i : int(i + 1);
break;
}
skippedFirstSpace = true;
}
if(i == 0)
{
this._currWordEndIndex = skippedFirstSpace ? this._currWordStartIndex : int(this._currWordStartIndex - 1);
this._currWordStartIndex = i;
}
}
}
}
}
}
@@ -0,0 +1,50 @@
package gui
{
public class PredictiveTextNode
{
public var char:String;
public var children:Vector.<PredictiveTextNode> = new Vector.<PredictiveTextNode>();
public var weight:int;
public var isSpecialCharacter:Boolean;
public var useType:int;
public function PredictiveTextNode(ch:String, isEndWord:int, childrenArray:Vector.<PredictiveTextNode>, isSpecial:Boolean = false, usabilityType:int = 0)
{
super();
this.char = ch;
this.weight = isEndWord;
this.children = childrenArray;
this.isSpecialCharacter = isSpecial;
this.useType = usabilityType;
}
public function destroy() : void
{
this.children = null;
}
public function contains(c:String) : int
{
var childLength:int = 0;
var i:int = 0;
if(this.children != null)
{
childLength = int(this.children.length);
for(i = 0; i < childLength; i++)
{
if(this.children[i].char == c)
{
return i;
}
}
}
return -1;
}
}
}
@@ -0,0 +1,650 @@
package gui
{
public class PredictiveTextTree
{
private static var _defaultRoot:PredictiveTextNode;
private static var _lastKnowWordNode:PredictiveTextNode;
private static var _weightOfWord:int;
private static var _useType:int;
private static var _optimizationString:String = "";
private static var _savedChildren:Vector.<PredictiveTextNode> = new Vector.<PredictiveTextNode>();
private var _root:PredictiveTextNode;
private var _currSearchNode:PredictiveTextNode;
private var _nodeCount:int = 0;
private var _nodeCountAfter:int = 0;
private var _numWordsPrinted:int = 0;
private var _charSearchIndex:int = 0;
private var _similarWordsIndex:int = 0;
private var _useType:int;
private var _isLastNode:Boolean;
private var _hasCompletedCheckingMyself:Boolean;
private var _searchChildren:Vector.<Object> = new Vector.<Object>();
private var _similarWords:Vector.<Object> = new Vector.<Object>();
public function PredictiveTextTree(textNode:PredictiveTextNode, useType:int)
{
super();
this._root = textNode;
this._currSearchNode = this._root;
this._useType = useType;
}
public static function init() : void
{
_defaultRoot = new PredictiveTextNode("",0,new Vector.<PredictiveTextNode>());
}
public static function addFromStart(s:Array) : void
{
_weightOfWord = s[1];
_useType = s[2] == "" ? PredictiveTextManager.USE_TYPE_ALL : int(s[2]);
add(s[0].split(""),0,_defaultRoot);
}
public static function get defaultRoot() : PredictiveTextNode
{
return _defaultRoot;
}
public static function optimizeTree(n:PredictiveTextNode) : void
{
var childLength:int = 0;
var i:int = 0;
var weight:int = 0;
if(Boolean(n.children))
{
childLength = int(n.children.length);
for(i = 0; i < childLength; i++)
{
optimizeTree(n.children[i]);
if(n.weight > 0 || n == _defaultRoot || childLength > 1)
{
if(Boolean(_lastKnowWordNode))
{
_lastKnowWordNode.children = _savedChildren;
_lastKnowWordNode.weight = Math.max(1,_lastKnowWordNode.weight);
_lastKnowWordNode.char = reverseString(_optimizationString);
_lastKnowWordNode = null;
_savedChildren = null;
_optimizationString = "";
}
}
else if(Boolean(_lastKnowWordNode))
{
weight = _lastKnowWordNode.weight;
_lastKnowWordNode = n;
_lastKnowWordNode.weight = weight;
_optimizationString += n.char;
}
}
if(n.weight > 0)
{
if(_lastKnowWordNode == null || n.weight > _lastKnowWordNode.weight)
{
_savedChildren = n.children;
_lastKnowWordNode = n;
_optimizationString += n.char;
}
}
}
}
private static function add(s:Array, index:int, newNode:PredictiveTextNode) : void
{
var nextNodeIndex:int = 0;
if(index == s.length)
{
newNode.weight = Math.max(1,_weightOfWord);
newNode.useType = _useType;
}
else
{
nextNodeIndex = newNode.contains(s[index]);
if(nextNodeIndex != -1)
{
add(s,index + 1,newNode.children[nextNodeIndex]);
}
else
{
newNode.children.push(new PredictiveTextNode(s[index],0,new Vector.<PredictiveTextNode>(),false,_useType));
add(s,index + 1,newNode.children[newNode.children.length - 1]);
}
}
}
private static function reverseString(s:String) : String
{
var temp:String = "";
for(var i:int = s.length - 1; i >= 0; i--)
{
temp += s.charAt(i);
}
return temp;
}
public function destroy() : void
{
if(Boolean(_lastKnowWordNode))
{
_lastKnowWordNode.destroy();
_lastKnowWordNode = null;
}
this._searchChildren = null;
this._similarWords = null;
_savedChildren = null;
}
public function updateRoot(textNode:PredictiveTextNode) : void
{
this._root = textNode;
this.clearWordSuggestions();
this.resetSearchTree();
}
public function containsString(s:String) : int
{
var answer:int = 0;
answer = this.checkMyself(s);
if(answer > 0)
{
return answer;
}
if(answer == -1)
{
return 0;
}
answer = this.checkMyChildren(s);
if(answer > 0)
{
return answer;
}
return 0;
}
public function checkCurrentWordValidity() : int
{
var nodeToCheck:Object = null;
var retValue:int = 0;
if(this._searchChildren.length > 0)
{
nodeToCheck = this._searchChildren[this._searchChildren.length - 1];
if(Boolean(nodeToCheck.node))
{
if(Boolean(this._currSearchNode))
{
if(this._currSearchNode.isSpecialCharacter)
{
retValue = 3;
}
else if(this._currSearchNode.char.length > 1)
{
if(this._charSearchIndex == nodeToCheck.node.char.length)
{
this._charSearchIndex = 0;
if(nodeToCheck.node.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == nodeToCheck.node.useType)
{
retValue = this._currSearchNode.weight > 0 ? 1 : 0;
}
else
{
retValue = this._currSearchNode.weight > 0 ? 2 : 1;
}
}
else
{
retValue = 1;
}
}
else if(this._currSearchNode.char.charAt(this._charSearchIndex) == nodeToCheck.node.char)
{
if(nodeToCheck.node.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == nodeToCheck.node.useType)
{
retValue = this._currSearchNode.weight > 0 ? 1 : 0;
}
else
{
retValue = this._currSearchNode.weight > 0 ? 2 : 1;
}
}
else
{
retValue = 1;
}
}
}
else
{
retValue = 2;
}
}
return retValue;
}
public function showTopWord() : String
{
this.clearWordSuggestions();
this.findAllSimilarWords();
this._similarWords.sort(this.compare);
return this._similarWords.length > 0 ? this._similarWords[0].word : null;
}
public function resetSearchTree() : void
{
this._searchChildren = new Vector.<Object>();
this._currSearchNode = this._root;
}
public function clearWordSuggestions() : void
{
this._similarWords.splice(0,this._similarWords.length);
this._similarWordsIndex = 0;
}
public function backspaced() : void
{
var obj:Object = null;
if(this._searchChildren.length > 0)
{
this._hasCompletedCheckingMyself = false;
this._searchChildren.pop();
if(this._searchChildren.length == 0)
{
this._currSearchNode = this._root;
this._charSearchIndex = 0;
}
else
{
obj = this._searchChildren[this._searchChildren.length - 1];
this._currSearchNode = obj.node == null ? this._root : obj.node;
this._charSearchIndex = obj.wordIndex;
}
}
this.clearWordSuggestions();
}
public function onSpecialCharacter() : void
{
var tempNode:PredictiveTextNode = new PredictiveTextNode(this._currSearchNode.char,this._currSearchNode.weight,this._currSearchNode.children,true);
this._searchChildren.push({
"node":tempNode,
"wordIndex":0
});
this._hasCompletedCheckingMyself = false;
}
public function onSpacebar() : void
{
this._searchChildren.push({
"node":null,
"wordIndex":0
});
this._currSearchNode = this._root;
this._charSearchIndex = 0;
this._hasCompletedCheckingMyself = false;
}
public function get nodeCount() : Number
{
return this._nodeCount;
}
public function get nodeCountAfter() : Number
{
return this._nodeCountAfter;
}
public function get theRoot() : PredictiveTextNode
{
return this._root;
}
public function get numWords() : Number
{
return this._numWordsPrinted;
}
public function get currentRestriction() : String
{
var children:Vector.<PredictiveTextNode> = null;
var i:int = 0;
var restriction:String = "";
if(Boolean(this._currSearchNode))
{
restriction += this._currSearchNode.char;
children = this._currSearchNode.children;
for(i = 0; i < children.length; i++)
{
if(children[i].char.charAt(0) == "-")
{
restriction += "\\-";
}
else
{
restriction += children[i].char.charAt(0);
}
}
}
return restriction;
}
private function checkMyself(s:String) : int
{
if(Boolean(this._currSearchNode))
{
if(this._currSearchNode.isSpecialCharacter)
{
return -1;
}
if(this._currSearchNode.char.length > 1 && !this._hasCompletedCheckingMyself)
{
if(this._currSearchNode.char.charAt(this._charSearchIndex) == s)
{
++this._charSearchIndex;
if(this._charSearchIndex == this._currSearchNode.char.length)
{
this._searchChildren.push({
"node":this._currSearchNode,
"wordIndex":this._charSearchIndex
});
this._charSearchIndex = 0;
this._hasCompletedCheckingMyself = true;
if(this._currSearchNode.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == this._currSearchNode.useType)
{
return this._currSearchNode.weight > 0 || this._currSearchNode.children.length > 0 ? 1 : 0;
}
return this._currSearchNode.weight > 0 ? 2 : 1;
}
this._searchChildren.push({
"node":this._currSearchNode,
"wordIndex":this._charSearchIndex
});
if(this._currSearchNode.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == this._currSearchNode.useType)
{
return 0;
}
return 1;
}
this._searchChildren.push({
"node":this._currSearchNode,
"wordIndex":this._charSearchIndex
});
return -1;
}
return 0;
}
return 0;
}
private function checkMyChildren(s:String) : int
{
var currNodeChildLength:int = 0;
var i:int = 0;
var currSearchNodeChild:PredictiveTextNode = null;
if(Boolean(this._currSearchNode))
{
currNodeChildLength = int(this._currSearchNode.children.length);
for(i = 0; i < currNodeChildLength; i++)
{
this._hasCompletedCheckingMyself = false;
currSearchNodeChild = this._currSearchNode.children[i];
if(currSearchNodeChild.isSpecialCharacter)
{
return 0;
}
if(currSearchNodeChild.char == s)
{
this._searchChildren.push({
"node":currSearchNodeChild,
"wordIndex":0
});
this._currSearchNode = currSearchNodeChild;
if(currSearchNodeChild.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == currSearchNodeChild.useType)
{
return this._currSearchNode.weight > 0 || currSearchNodeChild.children.length > 0 ? 1 : 0;
}
return this._currSearchNode.weight > 0 ? 2 : 1;
}
if(currSearchNodeChild.char.length > 1)
{
if(currSearchNodeChild.char.charAt(this._charSearchIndex) == s)
{
++this._charSearchIndex;
if(this._charSearchIndex == currSearchNodeChild.char.length)
{
this._searchChildren.push({
"node":currSearchNodeChild,
"wordIndex":this._charSearchIndex
});
this._currSearchNode = currSearchNodeChild;
this._charSearchIndex = 0;
}
else
{
this._searchChildren.push({
"node":currSearchNodeChild,
"wordIndex":this._charSearchIndex
});
this._currSearchNode = currSearchNodeChild;
}
if(currSearchNodeChild.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == currSearchNodeChild.useType)
{
return (this._currSearchNode.weight > 0 || currSearchNodeChild.children.length > 0) && this._charSearchIndex == 0 ? 1 : 0;
}
return this._currSearchNode.weight > 0 && this._charSearchIndex == 0 ? 2 : 1;
}
}
}
}
this._searchChildren.push({
"node":this._currSearchNode,
"wordIndex":this._charSearchIndex
});
return 0;
}
private function findAllSimilarWords(nextNode:PredictiveTextNode = null, appendString:String = "", levelNode:PredictiveTextNode = null) : Vector.<Object>
{
var wordIndex:int = 0;
var i:int = 0;
var searchNode:PredictiveTextNode = nextNode != null ? nextNode : this._currSearchNode;
if(searchNode == this._root)
{
return this._similarWords;
}
if(levelNode == null)
{
levelNode = this._currSearchNode;
}
if(Boolean(searchNode))
{
wordIndex = int(this._searchChildren[this._searchChildren.length - 1].wordIndex);
if(searchNode == this._currSearchNode && this._currSearchNode.char.length > 1 && this._currSearchNode.weight > 0 && wordIndex < this._currSearchNode.char.length)
{
if(!(searchNode.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == searchNode.useType))
{
this._similarWords.push({
"word":this.appendCompletionString(""),
"weight":this._currSearchNode.weight,
"index":wordIndex
});
++this._similarWordsIndex;
}
}
for(i = 0; i < searchNode.children.length; i++)
{
if(this._similarWords.length <= this._similarWordsIndex)
{
if(!(searchNode.children[i].useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == searchNode.children[i].useType))
{
this._similarWords.push({
"word":appendString,
"weight":searchNode.children[i].weight
});
this._similarWords[this._similarWordsIndex].word += searchNode.children[i].char;
this._similarWords[this._similarWordsIndex].weight = searchNode.children[i].weight;
}
}
else
{
this._similarWords[this._similarWordsIndex].word += searchNode.children[i].char;
this._similarWords[this._similarWordsIndex].weight = searchNode.children[i].weight;
}
if(searchNode.children[i].weight > 0 && this._similarWords.length > this._similarWordsIndex)
{
this._similarWords[this._similarWordsIndex].word = this.appendCompletionString(this._similarWords[this._similarWordsIndex].word);
this._similarWords[this._similarWordsIndex].weight = searchNode.children[i].weight;
if(searchNode != this._currSearchNode)
{
return this._similarWords;
}
++this._similarWordsIndex;
}
else
{
if(searchNode != levelNode)
{
appendString += searchNode.char;
levelNode = searchNode;
}
this.findAllSimilarWords(searchNode.children[i],appendString);
++this._similarWordsIndex;
}
}
if(nextNode == null && searchNode.children.length == 0)
{
if(!(searchNode.useType > PredictiveTextManager.USE_TYPE_ALL && this._useType == searchNode.useType))
{
this._similarWords.push({
"word":this.appendCompletionString(""),
"weight":searchNode.weight
});
}
}
--this._similarWordsIndex;
}
return this._similarWords;
}
private function compare(x:Object, y:Object) : int
{
if(x.weight > y.weight)
{
return -1;
}
if(x.weight < y.weight)
{
return 1;
}
return 0;
}
private function appendCompletionString(s:String) : String
{
var lastGoodChild:PredictiveTextNode = null;
var i:int = 0;
var completionString:String = "";
if(Boolean(this._searchChildren))
{
for(i = this._searchChildren.length - 1; i >= 0; i--)
{
if(!Boolean(this._searchChildren[i].node))
{
break;
}
if(Boolean(lastGoodChild))
{
if(lastGoodChild == this._searchChildren[i].node)
{
continue;
}
if(this._searchChildren[i].node.char.length > 1)
{
completionString += reverseString(this._searchChildren[i].node.char);
}
else
{
completionString += this._searchChildren[i].node.char;
}
lastGoodChild = this._searchChildren[i].node;
}
else
{
if(this._searchChildren[i].node.char.length > 1)
{
completionString += reverseString(this._searchChildren[i].node.char);
}
else
{
completionString += this._searchChildren[i].node.char;
}
lastGoodChild = this._searchChildren[i].node;
}
}
}
return reverseString(completionString) + s;
}
private function countNodes(n:PredictiveTextNode) : void
{
++this._nodeCount;
for(var i:int = 0; i < n.children.length; i++)
{
this.countNodes(n.children[i]);
}
}
private function countNodesAfter(n:PredictiveTextNode) : void
{
++this._nodeCountAfter;
for(var i:int = 0; i < n.children.length; i++)
{
this.countNodesAfter(n.children[i]);
}
}
private function drawTree(n:PredictiveTextNode, appendString:String) : void
{
var i:int = 0;
var initialI:int = 0;
if(Boolean(n.children))
{
for(i = 0; i < n.children.length; i++)
{
if(initialI == i)
{
appendString += n.char;
}
initialI = i;
this.drawTree(n.children[i],appendString);
}
if(n.children.length == 0)
{
appendString += n.char;
}
if(n.weight > 0)
{
++this._numWordsPrinted;
}
}
}
}
}
@@ -0,0 +1,248 @@
package gui
{
import avatar.AvatarManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import quest.QuestXtCommManager;
public class PrivateAdventureJoin
{
private const MEDIA_ID:int = 2300;
private var _mediaHelper:MediaHelper;
private var _popup:MovieClip;
private var _guiLayer:DisplayLayer;
private var _closeCallback:Function;
private var _savedParams:Array;
private var _inParamsWaiting:Object;
private var _waitingAvatarWindows:WindowGenerator;
private var _windowScrollbar:SBScrollbar;
private var _scriptDefId:int;
public function PrivateAdventureJoin()
{
super();
}
public function init(initScriptDefId:int, initCloseCallback:Function) : void
{
if(Boolean(GuiManager.chatHist))
{
GuiManager.chatHist.removeEmotesFromChatRepeat();
}
this._savedParams = [];
this._guiLayer = GuiManager.guiLayer;
this._closeCallback = initCloseCallback;
this._scriptDefId = initScriptDefId;
DarkenManager.showLoadingSpiral(true);
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(this.MEDIA_ID,this.onMediaLoaded);
}
public function destroy() : void
{
GuiManager.grayOutHudItemsForPrivateLobby(false);
GuiManager.mainHud.emotesBtn.activateGrayState(false);
this.removeEventListeners();
this._mediaHelper.destroy();
this._mediaHelper = null;
this._guiLayer.removeChild(this._popup);
}
public function handleWaitResponse(params:Object) : void
{
var userList:Array = null;
if(Boolean(this._popup))
{
if(Boolean(this._waitingAvatarWindows))
{
this._waitingAvatarWindows.destroy();
this._waitingAvatarWindows = null;
}
userList = params.slice(2);
this._waitingAvatarWindows = new WindowGenerator();
this._waitingAvatarWindows.init(1,4,userList.length,0,0,0,ItemWindowCustPlayers,params.slice(2),"",{
"mouseDown":this.onWindowDown,
"mouseOver":this.onWindowOver,
"mouseOut":this.onWindowOut,
"memberOnlyMouseDown":null
},{
"onBxBtn":this.onKickPlayerBtn,
"scriptDefId":this._scriptDefId
},this.onWindowLoaded,false,false);
}
else
{
this._inParamsWaiting = params;
}
}
public function updateDisplayIndex(mainHudHigher:Boolean = true) : void
{
var mainHudIndex:int = GuiManager.guiLayer.getChildIndex(GuiManager.mainHud);
var myIndex:int = this._popup.parent.getChildIndex(this._popup);
if(mainHudHigher)
{
if(mainHudIndex < myIndex)
{
this._popup.parent.setChildIndex(this._popup,mainHudIndex);
}
}
else if(mainHudIndex > myIndex)
{
this._popup.parent.setChildIndex(this._popup,mainHudIndex);
}
}
private function onMediaLoaded(img:MovieClip) : void
{
if(Boolean(img))
{
GuiManager.mainHud.emotesBtn.activateGrayState(true);
DarkenManager.showLoadingSpiral(false);
this._popup = MovieClip(img.getChildAt(0));
this.addEventListeners();
this._popup.x = this._popup.width * 0.5;
this._popup.y = MainFrame.VIEW_HEIGHT * 0.5 - 20;
this._guiLayer.addChild(this._popup);
GuiManager.closeAnyHudPopups();
if(this._inParamsWaiting != null)
{
this.handleWaitResponse(this._inParamsWaiting);
this._inParamsWaiting = null;
}
else
{
this._waitingAvatarWindows = new WindowGenerator();
this._waitingAvatarWindows.init(1,4,1,0,0,0,ItemWindowCustPlayers,[AvatarManager.playerSfsUserId],"",{
"mouseDown":this.onWindowDown,
"mouseOver":this.onWindowOver,
"mouseOut":this.onWindowOut,
"memberOnlyMouseDown":null
},{"onBxBtn":this.onKickPlayerBtn},this.onWindowLoaded,false,false);
}
}
}
private function onWindowLoaded() : void
{
if(this._popup.playerWindow.numChildren > 0)
{
this._popup.playerWindow.removeChildAt(0);
}
this._popup.playerWindow.addChild(this._waitingAvatarWindows);
if(Boolean(this._windowScrollbar))
{
this._windowScrollbar.destroy();
this._windowScrollbar = null;
}
this._windowScrollbar = new SBScrollbar();
this._windowScrollbar.init(this._waitingAvatarWindows,this._waitingAvatarWindows.width,this._waitingAvatarWindows.boxHeight * 4 + 0 * 4 + 0 * 2,10,"scrollbar2",this._waitingAvatarWindows.boxHeight + 0);
}
private function close() : void
{
if(this._closeCallback != null)
{
this._closeCallback(false);
this._closeCallback = null;
}
else
{
this.destroy();
}
}
private function onWindowDown(evt:MouseEvent) : void
{
var player:Object = null;
evt.stopPropagation();
if(evt.currentTarget.userName != gMainFrame.userInfo.myUserName)
{
player = {
"userName":evt.currentTarget.userName,
"onlineStatus":true
};
BuddyCard.showBuddyCard(player);
}
}
private function onWindowOver(evt:MouseEvent) : void
{
evt.stopPropagation();
if(evt.currentTarget.userName != gMainFrame.userInfo.myUserName)
{
evt.currentTarget.char.gotoAndStop("over");
evt.currentTarget.showXBtn(true);
}
}
private function onWindowOut(evt:MouseEvent) : void
{
evt.stopPropagation();
evt.currentTarget.char.gotoAndStop("up");
if(evt.currentTarget.userName != gMainFrame.userInfo.myUserName)
{
evt.currentTarget.showXBtn(false);
}
}
private function onKickPlayerBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
QuestXtCommManager.sendQuestPrivateKick(evt.currentTarget.parent.parent.userName);
}
private function onPopup(evt:MouseEvent) : void
{
evt.stopPropagation();
}
private function onPopupOver(evt:MouseEvent) : void
{
evt.stopPropagation();
this.updateDisplayIndex(false);
}
private function onCloseBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
QuestXtCommManager.sendQuestJoinCancel();
this.close();
}
private function onPlayBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
QuestXtCommManager.sendQuestStartRequest();
this.close();
}
private function addEventListeners() : void
{
this._popup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
this._popup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtn,false,0,true);
this._popup.playBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn,false,0,true);
this._popup.addEventListener(MouseEvent.MOUSE_OVER,this.onPopupOver,false,0,true);
}
private function removeEventListeners() : void
{
this._popup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
this._popup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtn);
this._popup.playBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn);
this._popup.removeEventListener(MouseEvent.MOUSE_OVER,this.onPopupOver);
}
}
}
@@ -0,0 +1,570 @@
package gui
{
import avatar.AvatarManager;
import com.sbi.popup.SBPopup;
import den.DenItem;
import den.DenXtCommManager;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import item.ItemXtCommManager;
import localization.LocalizationManager;
public class RecycleItems
{
private static const RECYCLE_TUT_LIST_ID:int = 52;
public static const RECYCLE_ACCESSORIES:int = 0;
public static const RECYCLE_DEN_ITEMS:int = 1;
public static const RECYCLE_DEN_AUDIO:int = 2;
public static const RECYCLE_DEN_ITEMS_OCEAN_ONLY:int = 3;
public static const RECYCLE_DEN_ITEMS_LAND_ONLY:int = 4;
public static const RECYCLE_ACCESSORIES_OCEAN_ONLY:int = 5;
public static const RECYCLE_ACCESSORIES_LAND_ONLY:int = 6;
private static var _accessoriesScrollValue:Number = 0;
private static var _accessoriesOceanOnlyScrollValue:Number = 0;
private static var _accessoriesLandOnlyScrollValue:Number = 0;
private static var _denScrollValue:Number = 0;
private static var _denOceanOnlyScrollValue:Number = 0;
private static var _denLandOnlyScrollValue:Number = 0;
private static var _denAudioScrollValue:Number = 0;
private static var _scrollValue:Number = 0;
private var _recycle:MovieClip;
private var _recycleSmall:MovieClip;
private var _itemRecycleId:int;
private var _savedTradeIdx:int;
private var _recyclePopup:SBPopup;
private var _recyclePopupSmall:SBPopup;
private var _closeCallback:Function;
private var _onRecycleSuccessCallback:Function;
private var _recycleInventory:Array;
private var _scrollButtons:MovieClip;
private var _itemWindows:WindowGenerator;
private var _popupLayer:DisplayObjectContainer;
private var _idx:int;
private var _height:int;
private var _recycleOneItem:Boolean;
private var _hasRecycled:Boolean;
private var _isInCurrEnviro:Boolean;
private var _tempMC:Object;
private var _spirals:Array;
public function RecycleItems()
{
super();
}
private static function onInfoBtnOut(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.resetTimerAndSetVisibility();
}
public function init(itemRecycleId:int, guiLayer:DisplayObjectContainer, recycleOneItem:Boolean = false, init_closeCallback:Function = null, initPopupX:int = 450, initPopupY:int = 250, isInCurrEnviro:Boolean = false) : void
{
this._recycle = GETDEFINITIONBYNAME("RecyclePopupContent");
this._recycleSmall = GETDEFINITIONBYNAME("RecycleSmlPopupContent");
this._recycleSmall.itemBlock.gift.visible = false;
this._recycleSmall.itemBlock.addBtn.visible = false;
this._recycleSmall.itemBlock.removeBtn.visible = false;
this._recycleSmall.itemBlock.avtSpecificIcon.visible = false;
this._recycleSmall.itemBlock.avtSpecific.visible = false;
this._recycleSmall.itemBlock.avtSpecificHighlight.visible = false;
this._itemRecycleId = itemRecycleId;
this._popupLayer = guiLayer;
this._recycleOneItem = recycleOneItem;
this._isInCurrEnviro = isInCurrEnviro;
this._recyclePopup = new SBPopup(guiLayer,GETDEFINITIONBYNAME("RecyclePopupSkin"),this._recycle,true,true,false,false,true);
this._recyclePopupSmall = new SBPopup(guiLayer,GETDEFINITIONBYNAME("RecycleSmlPopupSkin"),this._recycleSmall,false,true,false,false,true);
this._closeCallback = init_closeCallback;
this._recyclePopup.x = initPopupX;
this._recyclePopup.y = initPopupY;
this._recyclePopup.bxClosesPopup = false;
this._height = this._recycle.itemBlock.height;
this._spirals = [];
this.addListeners();
AJAudio.playItemRecycledSound();
if(this._itemRecycleId == RECYCLE_DEN_ITEMS || this._itemRecycleId == RECYCLE_DEN_ITEMS_OCEAN_ONLY || this._itemRecycleId == RECYCLE_DEN_ITEMS_LAND_ONLY)
{
if(gMainFrame.userInfo.playerUserInfo.denItemsFull.length <= 0)
{
DenXtCommManager.requestDenItems(this.fillInventory);
}
}
this.fillInventory();
}
public function destroy() : void
{
var j:int = 0;
this.removeListeners();
if(Boolean(this._recyclePopup))
{
this._recyclePopup.destroy();
this._recyclePopup = null;
}
if(Boolean(this._recyclePopupSmall))
{
this._recyclePopupSmall.destroy();
this._recyclePopupSmall = null;
}
if(Boolean(this._scrollButtons))
{
_scrollValue = this._scrollButtons.scrollYValue;
switch(this._itemRecycleId)
{
case RECYCLE_ACCESSORIES:
_accessoriesScrollValue = _scrollValue;
break;
case RECYCLE_ACCESSORIES_LAND_ONLY:
_accessoriesLandOnlyScrollValue = _scrollValue;
break;
case RECYCLE_ACCESSORIES_OCEAN_ONLY:
_accessoriesOceanOnlyScrollValue = _scrollValue;
break;
case RECYCLE_DEN_ITEMS:
_denScrollValue = _scrollValue;
break;
case RECYCLE_DEN_ITEMS_LAND_ONLY:
_denLandOnlyScrollValue = _scrollValue;
break;
case RECYCLE_DEN_ITEMS_OCEAN_ONLY:
_denOceanOnlyScrollValue = _scrollValue;
break;
case RECYCLE_DEN_AUDIO:
_denAudioScrollValue = _scrollValue;
}
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
if(Boolean(this._spirals) && this._spirals.length > 0)
{
for(j = 0; j < this._spirals.length; j++)
{
this._spirals[j].destroy();
}
}
this._spirals = null;
this._hasRecycled = false;
this._tempMC = null;
this._closeCallback = null;
}
public function hasBeenInited() : Boolean
{
return this._recyclePopup != null;
}
private function fillInventory(isRefill:Boolean = false) : void
{
var temp:Array = null;
var i:int = 0;
var j:int = 0;
if(!isRefill)
{
this._recycleInventory = [];
if(this._itemRecycleId == RECYCLE_ACCESSORIES)
{
this._recycleInventory = gMainFrame.userInfo.playerAvatarInfo.getFullItems();
_scrollValue = _accessoriesScrollValue;
}
else if(this._itemRecycleId == RECYCLE_ACCESSORIES_LAND_ONLY || this._itemRecycleId == RECYCLE_ACCESSORIES_OCEAN_ONLY)
{
temp = gMainFrame.userInfo.playerAvatarInfo.getFullItems();
if(this._itemRecycleId == RECYCLE_ACCESSORIES_LAND_ONLY)
{
for(i = 0; i < temp.length; i++)
{
if(temp[i].enviroType == Utility.ENVIRO_LAND)
{
this._recycleInventory.push(temp[i]);
}
}
_scrollValue = _accessoriesLandOnlyScrollValue;
}
else
{
for(i = 0; i < temp.length; i++)
{
if(temp[i].enviroType == Utility.ENVIRO_OCEAN)
{
this._recycleInventory.push(temp[i]);
}
}
_scrollValue = _accessoriesOceanOnlyScrollValue;
}
}
else
{
temp = gMainFrame.userInfo.playerUserInfo.denItemsFull;
if(this._itemRecycleId == RECYCLE_DEN_ITEMS_LAND_ONLY || this._itemRecycleId == RECYCLE_DEN_ITEMS_OCEAN_ONLY)
{
if(this._isInCurrEnviro)
{
temp = Utility.denItemListByEnviroType(temp,AvatarManager.roomEnviroType);
}
}
this._recycleInventory = new Array();
for(i = 0; i < temp.length; i++)
{
if(this._itemRecycleId == RECYCLE_DEN_AUDIO)
{
if(temp[i].sortId == DenItem.SORT_AUDIO && temp[i].itemDefId != DenItem.DEF_AUDIO_DEF_ID)
{
this._recycleInventory[j] = temp[i].clone();
j++;
}
}
else if(temp[i].sortId != DenItem.SORT_AUDIO)
{
if(this._itemRecycleId == RECYCLE_DEN_ITEMS || this._isInCurrEnviro)
{
this._recycleInventory[j] = temp[i].clone();
j++;
}
else if(this._itemRecycleId == RECYCLE_DEN_ITEMS_LAND_ONLY && temp[i].enviroType == Utility.ENVIRO_LAND)
{
this._recycleInventory[j] = temp[i].clone();
j++;
}
else if(temp[i].enviroType == Utility.ENVIRO_OCEAN)
{
this._recycleInventory[j] = temp[i].clone();
j++;
}
}
}
if(this._itemRecycleId == RECYCLE_DEN_AUDIO)
{
_scrollValue = _denAudioScrollValue;
}
else if(this._itemRecycleId == RECYCLE_DEN_ITEMS)
{
_scrollValue = _denScrollValue;
}
else if(this._itemRecycleId == RECYCLE_DEN_ITEMS_LAND_ONLY)
{
_scrollValue = _denLandOnlyScrollValue;
}
else if(this._itemRecycleId == RECYCLE_DEN_ITEMS_OCEAN_ONLY)
{
_scrollValue = _denOceanOnlyScrollValue;
}
}
}
this.createWindows();
}
private function createWindows() : void
{
if(Boolean(this._scrollButtons))
{
_scrollValue = this._scrollButtons.scrollYValue;
this._scrollButtons.destroy();
this._scrollButtons = null;
}
if(Boolean(this._itemWindows) && this._itemWindows.numChildren > 0)
{
while(Boolean(this._itemWindows.bg.numChildren))
{
this._itemWindows.bg.removeChildAt(0);
}
}
if(Boolean(this._itemWindows))
{
this._itemWindows.destroy();
this._itemWindows = null;
}
while(Boolean(this._recycle.itemBlock.numChildren))
{
this._recycle.itemBlock.removeChildAt(0);
}
this._itemWindows = new WindowGenerator();
this._itemWindows.init(3,4,Math.max(this._recycleInventory.length,12),2,2,0,ItemWindowOriginal,this._recycleInventory,"icon",{
"mouseDown":this.onItemWindowDown,
"mouseOver":this.onItemRollOver,
"mouseOut":this.onItemRollOut
},{"isRecycling":true},null,false,false);
this._recycle.itemBlock.addChild(this._itemWindows);
this._scrollButtons = new SBScrollbar();
this._scrollButtons.init(this._itemWindows,this._itemWindows.width,84 * 4 + 2 * 4,0,"scrollbar2",this._itemWindows.boxHeight + 2,_scrollValue);
}
private function attemptToRecycleItem(itemValue:int) : void
{
var currItem:Object = this._recycleInventory[this._idx];
this._recycleSmall.itemBlock.iconLayer.addChild(this._tempMC.icon);
this._recycleSmall.itemBlock.ocean.visible = currItem.isOcean;
this._recycleSmall.itemBlock.avtSpecific.visible = false;
LocalizationManager.translateIdAndInsert(this._recycleSmall.bodyTxt,11371,Utility.convertNumberToString(currItem.recycleValue));
this._recyclePopupSmall.open();
}
private function sendRecycleRequest(status:Boolean) : void
{
var inventoryId:int = 0;
var currItem:Object = null;
var tradeList:Array = null;
var i:int = 0;
if(status)
{
DarkenManager.showLoadingSpiral(true);
inventoryId = int(this._recycleInventory[this._idx].invIdx);
currItem = this._recycleInventory[this._idx];
tradeList = gMainFrame.userInfo.getMyTradeList();
this._savedTradeIdx = -1;
for(i = 0; i < tradeList.length; i++)
{
if(tradeList[i].type == this._itemRecycleId && tradeList[i].invIdx == inventoryId)
{
this._savedTradeIdx = i;
break;
}
}
if(this._itemRecycleId == RECYCLE_ACCESSORIES || this._itemRecycleId == RECYCLE_ACCESSORIES_LAND_ONLY || this._itemRecycleId == RECYCLE_ACCESSORIES_OCEAN_ONLY)
{
ItemXtCommManager.requestItemRecycle(inventoryId,this.confirmRecycle,this.onRecycleListCallback);
}
else
{
DenXtCommManager.requestRecycle(true,inventoryId,this.confirmRecycle,this.onRecycleListCallback);
}
}
}
private function confirmRecycle(success:Boolean) : void
{
if(success)
{
if(Boolean(this._tempMC.icon.parent))
{
this._tempMC.icon.parent.removeChild(this._tempMC.icon);
}
if(this._savedTradeIdx != -1)
{
gMainFrame.userInfo.removeFromMyTradeList(this._savedTradeIdx);
if(this._itemRecycleId == RECYCLE_ACCESSORIES || this._itemRecycleId == RECYCLE_ACCESSORIES_LAND_ONLY || this._itemRecycleId == RECYCLE_ACCESSORIES_OCEAN_ONLY)
{
TradeManager.adjustByOnNumClothingItemsInMyTradeList(-1);
}
else if(this._itemRecycleId == RECYCLE_DEN_ITEMS || this._itemRecycleId == RECYCLE_DEN_AUDIO || this._itemRecycleId == RECYCLE_DEN_ITEMS_LAND_ONLY || this._itemRecycleId == RECYCLE_DEN_ITEMS_OCEAN_ONLY)
{
TradeManager.adjustByOnNumDenItemsInMyTradeList(-1);
}
}
}
this._savedTradeIdx = -1;
}
private function onRecycleListCallback() : void
{
DarkenManager.showLoadingSpiral(false);
this._recycleInventory.splice(this._idx,1);
this._hasRecycled = true;
if(this._onRecycleSuccessCallback != null)
{
this._onRecycleSuccessCallback();
}
if(this._recycleOneItem)
{
this.applyAndClose(true);
}
else
{
_scrollValue = this._scrollButtons.scrollYValue;
this.fillInventory(true);
}
}
public function setOnRecycleSuccessCallback(callback:Function) : void
{
this._onRecycleSuccessCallback = callback;
}
private function applyAndClose(itemRecycled:Boolean = false) : void
{
ItemXtCommManager.recycleIlCallback = null;
DenXtCommManager.recycleDiCallback = null;
if(this._closeCallback != null)
{
this._closeCallback(itemRecycled);
}
else
{
this.destroy();
}
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
this.applyAndClose(this._hasRecycled);
}
private function onItemWindowDown(evt:MouseEvent) : void
{
evt.stopPropagation();
this._idx = evt.currentTarget.index;
this._tempMC = this._recycleInventory[this._idx].clone();
if(Boolean(this._recycleInventory[this._idx].isMemberOnly))
{
if(!gMainFrame.userInfo.isMember)
{
this._recycleSmall.itemBlock.lockOpen.visible = false;
this._recycleSmall.itemBlock.lock.visible = true;
}
else
{
this._recycleSmall.itemBlock.lockOpen.visible = true;
this._recycleSmall.itemBlock.lock.visible = false;
}
this._recycleSmall.itemBlock.gray.visible = false;
}
else
{
this._recycleSmall.itemBlock.lock.visible = false;
this._recycleSmall.itemBlock.lockOpen.visible = false;
this._recycleSmall.itemBlock.gray.visible = false;
}
if(!this._recycleInventory[this._idx].isRare)
{
this._recycleSmall.itemBlock.rare.visible = false;
}
this.attemptToRecycleItem(this._recycleInventory[this._idx].value);
}
private function onItemRollOver(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(evt.currentTarget.cir.currentFrameLabel == "down")
{
evt.currentTarget.cir.gotoAndStop("downMouse");
}
else if(evt.currentTarget.cir.currentFrameLabel != "downMouse")
{
evt.currentTarget.cir.gotoAndStop("over");
}
AJAudio.playSubMenuBtnRollover();
}
private function onItemRollOut(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(evt.currentTarget.cir.currentFrameLabel == "downMouse")
{
evt.currentTarget.cir.gotoAndStop("down");
}
else if(evt.currentTarget.cir.currentFrameLabel != "down")
{
evt.currentTarget.cir.gotoAndStop("up");
}
}
private function onOkBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this._recyclePopupSmall.close();
this.sendRecycleRequest(true);
}
private function onNoBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this._recycleSmall.itemBlock.iconLayer.removeChild(this._tempMC.icon);
this._recyclePopupSmall.close();
}
private function onInfoBtnDown(evt:MouseEvent) : void
{
evt.stopPropagation();
GenericListGuiManager.genericListVolumeClicked(RECYCLE_TUT_LIST_ID);
}
private function onInfoBtnOver(evt:MouseEvent) : void
{
evt.stopPropagation();
GuiManager.toolTip.init(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14678),evt.currentTarget.x + this._recyclePopup.x,evt.currentTarget.y + this._recyclePopup.y + evt.currentTarget.height);
GuiManager.toolTip.startTimer(evt);
}
private function addListeners() : void
{
if(Boolean(this._recyclePopup))
{
this._recyclePopup.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
if(Boolean(this._recyclePopupSmall))
{
this._recyclePopupSmall.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.onNoBtn,false,0,true);
}
this._recyclePopup.skin.s["infoBtn"].addEventListener(MouseEvent.MOUSE_DOWN,this.onInfoBtnDown,false,0,true);
this._recyclePopup.skin.s["infoBtn"].addEventListener(MouseEvent.MOUSE_OVER,this.onInfoBtnOver,false,0,true);
this._recyclePopup.skin.s["infoBtn"].addEventListener(MouseEvent.MOUSE_OUT,onInfoBtnOut,false,0,true);
this._recycleSmall.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onOkBtn,false,0,true);
this._recycleSmall.noBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onNoBtn,false,0,true);
}
private function removeListeners() : void
{
if(Boolean(this._recyclePopup))
{
this._recyclePopup.skin.s["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
if(Boolean(this._recyclePopupSmall))
{
this._recyclePopupSmall.skin.s["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onNoBtn);
}
this._recycleSmall.okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onOkBtn);
this._recycleSmall.noBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onNoBtn);
this._recyclePopup.skin.s["infoBtn"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onInfoBtnDown);
this._recyclePopup.skin.s["infoBtn"].addEventListener(MouseEvent.MOUSE_OVER,this.onInfoBtnOver);
this._recyclePopup.skin.s["infoBtn"].addEventListener(MouseEvent.MOUSE_OUT,onInfoBtnOut);
}
}
}
@@ -0,0 +1,301 @@
package gui
{
import buddy.BuddyXtCommManager;
import com.sbi.popup.SBPopup;
import facilitator.FacilitatorXtCommManager;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import loader.MediaHelper;
import localization.LocalizationManager;
public class ReportAPlayer
{
private static var _popupLayer:DisplayLayer;
private static var _closeCallback:Function;
private static var _report:MovieClip;
private static var _reportFromCard:MovieClip;
private static var _reportPopup:SBPopup;
private static var _reportFromCardPopup:SBPopup;
private static var _reportFromCardConfirmPopup:MovieClip;
private static var _isFromPlayersCard:Boolean;
private static var _playersAvatarUserName:String;
private static var _playersModeratedAvatarUserName:String;
private static var _reasonArray:Array;
private static var _hasReported:Boolean;
private static var _reportConfirmMediaHelper:MediaHelper;
private static var _agreeBox:GuiCheckBox;
public function ReportAPlayer()
{
super();
}
public static function initReasonArray(ira:Array) : void
{
_reasonArray = ira;
}
public static function closeReportFromCardPopoup() : void
{
if(Boolean(_reportFromCardPopup))
{
_reportFromCardPopup.close();
}
}
public function init(guiLayer:DisplayLayer, initCloseCallback:Function = null, fromPlayersCard:Boolean = false, playersAvatarUserName:String = null, playersModeratedAvatarUserName:String = null, initPopupX:int = 450, initPopupY:int = 275) : void
{
_popupLayer = guiLayer;
_closeCallback = initCloseCallback;
_isFromPlayersCard = fromPlayersCard;
_playersAvatarUserName = playersAvatarUserName;
_playersModeratedAvatarUserName = playersModeratedAvatarUserName;
_hasReported = false;
_reasonArray = [LocalizationManager.translateIdOnly(11372),LocalizationManager.translateIdOnly(14791),LocalizationManager.translateIdOnly(14792),LocalizationManager.translateIdOnly(14793),LocalizationManager.translateIdOnly(14794),LocalizationManager.translateIdOnly(14795),LocalizationManager.translateIdOnly(15736),LocalizationManager.translateIdOnly(15737)];
if(fromPlayersCard)
{
_reportFromCard = GETDEFINITIONBYNAME("ReportPopupReportContent");
_reportFromCardPopup = new SBPopup(_popupLayer,GETDEFINITIONBYNAME("ReportPopupReportSkin"),_reportFromCard,true,true,false,false,true);
_reportFromCardPopup.x = initPopupX;
_reportFromCardPopup.y = initPopupY;
_reportFromCardPopup.bxClosesPopup = false;
LocalizationManager.translateId(_reportFromCard.reasonTxt,11372);
LocalizationManager.translateIdAndInsert(_reportFromCard.titleTxt,11373,_playersModeratedAvatarUserName);
SafeChatManager.buildSafeChatTree(_reportFromCard.reasonChatTree,"ECardTextTreeNode",SafeChatManager.TREE_ECARDTEXT,this.onReasonTextClose,_reasonArray);
SafeChatManager.closeSafeChat(_reportFromCard.reasonChatTree);
}
else
{
_report = GETDEFINITIONBYNAME("ReportPopupHowToContent2");
_reportPopup = new SBPopup(_popupLayer,GETDEFINITIONBYNAME("ReportPopupHowToSkin"),_report);
_reportPopup.x = initPopupX;
_reportPopup.y = initPopupY;
_reportPopup.bxClosesPopup = false;
}
this.addListeners();
}
public function destroy() : void
{
this.removeListeners();
if(Boolean(_reportFromCardPopup))
{
_reportFromCardPopup.destroy();
_reportFromCardPopup = null;
}
if(Boolean(_reportPopup))
{
_reportPopup.destroy();
_reportPopup = null;
}
if(Boolean(_reportFromCardConfirmPopup))
{
if(Boolean(_agreeBox))
{
_agreeBox.destroy();
_agreeBox = null;
}
DarkenManager.unDarken(_reportFromCardConfirmPopup);
_popupLayer.removeChild(_reportFromCardConfirmPopup);
_reportFromCardConfirmPopup = null;
}
GuiManager.displayRulesPopup(false);
if(Boolean(_reportFromCard))
{
SafeChatManager.destroy(_reportFromCard.reasonChatTree);
}
if(Boolean(GuiManager.mainHud.reportBtn))
{
GuiManager.mainHud.reportBtn.downToUpState();
}
_closeCallback = null;
}
private function onClose(e:MouseEvent) : void
{
e.stopPropagation();
if(_hasReported && _agreeBox.checked)
{
if(!BuddyManager.isBlocked(_playersAvatarUserName))
{
BuddyXtCommManager.sendBuddyBlockRequest(_playersAvatarUserName);
}
}
if(_closeCallback != null)
{
_closeCallback(_hasReported);
}
else
{
this.destroy();
}
}
private function onReportBtnHandler(e:MouseEvent) : void
{
e.stopPropagation();
FacilitatorXtCommManager.sendReportAPlayerRequest(_playersAvatarUserName,this.reasonIdForReason(_reportFromCard.reasonTxt.text),this.reportAPlayerResponse);
_reportFromCardPopup.close();
}
private function reasonIdForReason(reason:String) : int
{
switch(reason)
{
case _reasonArray[0]:
return FacilitatorXtCommManager.RULE_MEAN;
case _reasonArray[1]:
return FacilitatorXtCommManager.RULE_LANGUAGE;
case _reasonArray[2]:
return FacilitatorXtCommManager.RULE_BAD_DEN;
case _reasonArray[3]:
return FacilitatorXtCommManager.RULE_PERSONAL_INFO;
case _reasonArray[4]:
return FacilitatorXtCommManager.RULE_SECURITY;
case _reasonArray[5]:
return FacilitatorXtCommManager.RULE_SCAMMING;
case _reasonArray[6]:
return FacilitatorXtCommManager.RULE_RELATIONSHIP;
case _reasonArray[7]:
return FacilitatorXtCommManager.RULE_USERNAME;
default:
throw new Error("Reason for reporting is invalid. Reason: " + reason);
}
}
private function onNoHandler(e:MouseEvent) : void
{
e.stopPropagation();
this.onClose(null);
}
private function onReasonHandler(e:MouseEvent) : void
{
e.stopPropagation();
if(!_reportFromCard.reasonChatTree.visible)
{
SafeChatManager.openSafeChat(true,_reportFromCard.reasonChatTree);
}
else
{
SafeChatManager.closeSafeChat(_reportFromCard.reasonChatTree);
}
}
private function onReasonTextClose(msg:String, code:String) : void
{
_reportFromCard.reasonTxt.text = msg;
SafeChatManager.closeSafeChat(_reportFromCard.reasonChatTree);
}
private function onRules(e:MouseEvent) : void
{
e.stopPropagation();
GuiManager.displayRulesPopup(true);
}
private function reportAPlayerResponse(status:Boolean) : void
{
DarkenManager.showLoadingSpiral(true);
_reportConfirmMediaHelper = new MediaHelper();
_reportConfirmMediaHelper.init(2694,this.onReportConfirmLoaded,status);
}
private function onReportConfirmLoaded(img:MovieClip) : void
{
DarkenManager.showLoadingSpiral(false);
_reportFromCardConfirmPopup = MovieClip(img.getChildAt(0));
_reportFromCardConfirmPopup.x = _reportFromCardPopup.x;
_reportFromCardConfirmPopup.y = _reportFromCardPopup.y;
if(Boolean(img.passback))
{
LocalizationManager.translateId(_reportFromCardConfirmPopup.titleTxt,11374);
_hasReported = true;
}
else
{
LocalizationManager.translateId(_reportFromCardConfirmPopup.titleTxt,11375);
}
_reportFromCardConfirmPopup.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
_agreeBox = new GuiCheckBox(_reportFromCardConfirmPopup.agree_box);
_agreeBox.init(_reportFromCardConfirmPopup.bodyTxt);
_agreeBox.checked = true;
_reportConfirmMediaHelper.destroy();
_reportConfirmMediaHelper = null;
_popupLayer.addChild(_reportFromCardConfirmPopup);
DarkenManager.darken(_reportFromCardConfirmPopup);
}
public function get visible() : Boolean
{
if(Boolean(_reportPopup))
{
return _reportPopup.visible;
}
return false;
}
private function addListeners() : void
{
if(_isFromPlayersCard)
{
if(Boolean(_reportFromCardPopup))
{
_reportFromCardPopup.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
_reportFromCard.reportBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onReportBtnHandler,false,0,true);
_reportFromCard.noBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onNoHandler,false,0,true);
_reportFromCard.addTxtBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onReasonHandler,false,0,true);
}
else
{
if(Boolean(_reportPopup))
{
_reportPopup.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
_report.rulesReportBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onRules,false,0,true);
}
}
private function removeListeners() : void
{
if(_isFromPlayersCard)
{
if(Boolean(_reportFromCardPopup))
{
_reportFromCardPopup.skin.s["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
if(Boolean(_reportFromCardConfirmPopup))
{
_reportFromCardConfirmPopup.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
_reportFromCard.reportBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onReportBtnHandler);
_reportFromCard.noBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onNoHandler);
_reportFromCard.addTxtBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onReasonHandler);
}
else
{
if(Boolean(_reportPopup))
{
_reportPopup.skin.s["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
}
_report.rulesReportBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onRules);
}
}
}
}
@@ -0,0 +1,559 @@
package gui
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import gskinner.motion.GTween;
import gskinner.motion.easing.Quadratic;
public class SBScrollbar extends MovieClip
{
private const MIN_HANDLE_HEIGHT:int = 30;
private const EASE_TIME:Number = 0.001;
private const EASE_BUTTON_TIME:Number = 0.5;
private var _scrollContentMask:MovieClip;
private var _wheelScrollPercent:Number;
private var _wheelScrollChange:Number;
private var _scrollHeight:Number;
private var _bounds:Rectangle;
private var _scrollTween:GTween;
private var _scrollContent:MovieClip;
private var _scrollContentHeight:Number;
private var _track:MovieClip;
private var _scrollHandle:MovieClip;
private var _topBtn:MovieClip;
private var _bottomBtn:MovieClip;
private var _gap:Number;
private var _snapHeight:Number;
private var _viewableWidth:Number;
private var _viewableHeight:Number;
private var _adjTrackHeight:Number;
private var _handleMovementPercentage:Number;
private var _currContentY:Number;
private var _numRowsInView:int;
private var _fullScreenScrollChange:Number;
private var _numPerRow:int;
public function SBScrollbar()
{
super();
}
public function init(scrollContent:MovieClip, viewableWidth:Number, viewableHeight:Number, gap:Number, scrollbarClass:String, snapHeight:Number, yStartPos:Number = 0, scrollableHeight:Number = -1) : void
{
this._scrollContent = scrollContent;
this._scrollContent.y = 0;
this._scrollContent.x = 0;
var scrollbar:MovieClip = GETDEFINITIONBYNAME(scrollbarClass);
if(Boolean(scrollbar.track) && Boolean(scrollbar.handle))
{
this._track = scrollbar.track;
this._scrollHandle = scrollbar.handle;
this._topBtn = scrollbar.topBtn;
this._bottomBtn = scrollbar.botBtn;
this._snapHeight = snapHeight;
this._gap = gap;
this._viewableWidth = viewableWidth;
this._viewableHeight = viewableHeight;
this._numPerRow = Math.round(this._viewableWidth / this._scrollContent.boxWidth);
if(scrollableHeight < this._viewableHeight)
{
this._scrollContentHeight = this._scrollContent.height;
}
else
{
this._scrollContentHeight = scrollableHeight;
}
this._scrollContentMask = this.createMask(this._viewableWidth,this._viewableHeight);
this._scrollContent.parent.addChild(this._scrollContentMask);
this._scrollContentMask.x = this._scrollContent.x;
this._scrollContentMask.y = this._scrollContent.y;
this._scrollContent.mask = this._scrollContentMask;
this._scrollHeight = this._scrollContentHeight - this._scrollContentMask.height;
if(yStartPos <= 0)
{
this._currContentY = 0;
}
else if(yStartPos > this._scrollHeight)
{
this._currContentY = this._scrollHeight;
}
else
{
this._currContentY = yStartPos;
}
this.setupAllItems();
this._numRowsInView = Math.round(this._viewableHeight / this._snapHeight);
this._fullScreenScrollChange = this._snapHeight * (this._numRowsInView - 1);
this._handleMovementPercentage = 0;
this._bounds = new Rectangle(this._track.x,this._scrollContentMask.y,0,Math.round(this._bottomBtn.y - this._scrollHandle.height));
this._bounds.top = this._topBtn.height;
this._adjTrackHeight = this._track.height - this._scrollHandle.height;
this._wheelScrollPercent = this._snapHeight / (this._scrollContentHeight - this._scrollContentMask.height);
this._wheelScrollChange = this._wheelScrollPercent * (this._scrollContentMask.y + this._scrollContentMask.height - this._scrollHandle.height);
this.setScrollHandleLocation(this._currContentY);
this.updateLoadItems();
this._scrollContent.y = this._scrollContentMask.y - this._currContentY;
return;
}
throw new Error("Error: SBSCrollbar.init()- The 5th parameter must contain two symbols; \'track\' and \'handle\'.");
}
public function destroy() : void
{
if(Boolean(this._scrollHandle))
{
this._scrollHandle.y = 0;
this._scrollContent.y = 0;
}
if(Boolean(this._scrollContent))
{
if(Boolean(this._scrollContent.stage))
{
this._scrollContent.stage.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler);
this._scrollContent.stage.removeEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMoveHandler);
}
if(Boolean(this._scrollContent.parent))
{
this._scrollContent.parent.removeEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseWheelHandler);
if(Boolean(this._scrollContent.stage))
{
this._scrollContent.parent.stage.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler);
}
if(Boolean(this._scrollContent.parent.parent))
{
this._scrollContent.parent.parent.removeEventListener(MouseEvent.ROLL_OUT,this.onStageOut);
}
if(Boolean(this._scrollContent.parent) && Boolean(this._scrollContent.parent.parent) && Boolean(this._scrollContent.parent.parent.parent))
{
this._scrollContent.parent.parent.parent.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler);
}
if(Boolean(this._scrollContentMask) && Boolean(this._scrollContentMask.parent))
{
this._scrollContentMask.parent.removeChild(this._scrollContentMask);
}
if(Boolean(this._track) && Boolean(this._track.parent) && this._track.parent == this._scrollContent.parent)
{
this._scrollContent.parent.removeChild(this._track);
}
if(Boolean(this._scrollHandle) && Boolean(this._scrollHandle.parent) && this._scrollHandle.parent == this._scrollContent.parent)
{
this._scrollHandle.removeEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDownHandler);
this._scrollContent.parent.removeChild(this._scrollHandle);
}
if(Boolean(this._topBtn) && Boolean(this._topBtn.parent) && this._topBtn.parent == this._scrollContent.parent)
{
this._topBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnClick);
this._scrollContent.parent.removeChild(this._topBtn);
}
if(Boolean(this._bottomBtn) && Boolean(this._bottomBtn.parent) && this._bottomBtn.parent == this._scrollContent.parent)
{
this._bottomBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnClick);
this._scrollContent.parent.removeChild(this._bottomBtn);
}
}
}
this._track = null;
this._scrollHandle = null;
this._topBtn = null;
this._bottomBtn = null;
this._scrollContent = null;
this._scrollContentMask = null;
this._bounds = null;
this._gap = NaN;
this._snapHeight = NaN;
this._viewableWidth = NaN;
this._viewableHeight = NaN;
this._adjTrackHeight = NaN;
this._handleMovementPercentage = NaN;
this._currContentY = NaN;
this._numRowsInView = NaN;
this._fullScreenScrollChange = NaN;
}
public function get scrollHeight() : Number
{
return this._scrollHeight;
}
public function get getMaskHeight() : Number
{
return this._scrollContentMask.height;
}
public function get getMaskY() : Number
{
return this._scrollContentMask.y;
}
public function get scrollYValue() : Number
{
if(this._scrollContentHeight <= this._scrollContentMask.height)
{
this._currContentY = 0;
}
return this._currContentY;
}
public function get scrollYPercentage() : Number
{
if(this._scrollContentHeight <= this._scrollContentMask.height)
{
return this._currContentY = 0;
}
return this._currContentY / this._scrollHeight;
}
public function get getScrollContentParent() : MovieClip
{
return MovieClip(this._scrollContent.parent);
}
public function scrollToElement(elIdx:int) : void
{
if(elIdx < 0 || elIdx > this._scrollContentHeight / this._snapHeight)
{
throw new Error("Invalid index.");
}
this.updateContentPosition(Math.min(this._scrollHeight,elIdx * this._snapHeight - this._currContentY));
}
private function setupAllItems() : void
{
this._scrollContent.parent.addChild(this._track);
this._track.x = Math.round(this._scrollContent.x + this._viewableWidth + this._gap + this._track.width * 0.5);
this._track.y = this._scrollContent.y + this._topBtn.height;
this._track.height = this._scrollContentMask.height - this._topBtn.height - this._bottomBtn.height;
this._scrollContent.parent.addChild(this._topBtn);
this._topBtn.x = this._track.x;
this._topBtn.y = this._scrollContent.y;
this._scrollContent.parent.addChild(this._bottomBtn);
this._bottomBtn.x = this._track.x;
this._bottomBtn.y = this._track.y + this._track.height;
this._scrollContent.parent.addChild(this._scrollHandle);
this._scrollHandle.x = this._track.x;
this._scrollHandle.y = this._track.y;
this.resizeHandle();
}
private function snapToPlace() : void
{
var newPos:Number = Math.round(this._scrollHeight * this._handleMovementPercentage / this._snapHeight);
newPos = this._snapHeight * newPos;
var percent:Number = newPos / this._scrollHeight;
this._currContentY = this._scrollHeight * percent;
new GTween(this._scrollContent,this.EASE_BUTTON_TIME,{"y":this._scrollContentMask.y - this._currContentY},{"ease":Quadratic.easeOut});
this.setScrollHandleLocation(this._currContentY);
var handlePos:Number = Math.max(this._scrollHandle.y,this._track.y);
new GTween(this._scrollHandle,this.EASE_BUTTON_TIME,{"y":handlePos},{"ease":Quadratic.easeOut});
}
private function setScrollHandleLocation(contentYValue:Number) : void
{
var percent:Number = Math.min(1,contentYValue / this._scrollHeight);
var newPos:Number = percent * this._scrollHeight;
newPos /= this._snapHeight;
this._handleMovementPercentage = newPos * this._snapHeight / this._scrollHeight;
this._scrollHandle.y = Math.max(this._handleMovementPercentage * this._adjTrackHeight + this._topBtn.height,this._track.y);
}
private function loadCurrViewableObjects(currContentY:Number) : void
{
var currRow:int = Math.ceil(currContentY / this._snapHeight);
var currStartIndex:int = currRow * this._numPerRow;
var currEndIndex:int = currStartIndex + this._numRowsInView * this._numPerRow;
var numChildren:int = int(this._scrollContent.bg.numChildren);
for(var i:int = currStartIndex; i < currEndIndex; i++)
{
if(i < numChildren)
{
this._scrollContent.bg.getChildAt(i).loadCurrItem(currContentY);
}
}
}
private function updateLoadItems(isScrollbar:Boolean = false) : void
{
var newPos:Number = NaN;
var percent:Number = NaN;
if(this._scrollContent.hasOwnProperty("bg"))
{
if(!isScrollbar)
{
this.loadCurrViewableObjects(this._currContentY);
}
else
{
newPos = Math.round(this._scrollHeight * this._handleMovementPercentage / this._snapHeight);
newPos = this._snapHeight * newPos;
percent = newPos / this._scrollHeight;
this.loadCurrViewableObjects(this._scrollHeight * percent);
}
}
}
private function updateContentPosition(scrollAmount:Number = NaN) : void
{
if(!isNaN(scrollAmount))
{
this._currContentY += scrollAmount;
this.setScrollHandleLocation(this._currContentY);
this.updateLoadItems();
this._scrollTween = new GTween(this._scrollContent,this.EASE_BUTTON_TIME,{"y":this._scrollContentMask.y - this._currContentY},{"ease":Quadratic.easeOut});
}
else
{
this._handleMovementPercentage = Math.min(1,(this._scrollHandle.y - this._topBtn.height) / this._adjTrackHeight);
this.updateLoadItems(true);
this._scrollTween = new GTween(this._scrollContent,this.EASE_TIME,{"y":this._scrollContentMask.y - this._scrollHeight * this._handleMovementPercentage},{"ease":Quadratic.easeOut});
}
}
private function onBtnClick(evt:MouseEvent) : void
{
evt.stopPropagation();
var scrollAmt:Number = 0;
if(Boolean(this._scrollTween))
{
this._scrollTween.end();
}
if(evt.currentTarget.name == this._topBtn.name)
{
scrollAmt = this.scrollUp();
}
else
{
scrollAmt = this.scrollDown();
}
if(scrollAmt != 0)
{
this.updateContentPosition(scrollAmt);
}
}
private function scrollUp() : Number
{
var j:int = 0;
var scrollAmt:int = 0;
if(this._currContentY > 0)
{
if(this._currContentY >= this._fullScreenScrollChange)
{
scrollAmt = -this._fullScreenScrollChange;
}
else
{
for(j = this._numRowsInView - 2; j > 0; j--)
{
if(this._currContentY >= this._snapHeight * j)
{
scrollAmt = -(this._snapHeight * j);
break;
}
}
if(scrollAmt > -this._currContentY)
{
scrollAmt = -this._currContentY;
}
}
}
return scrollAmt;
}
private function scrollDown() : Number
{
var i:int = 0;
var scrollAmt:Number = 0;
var contentHeightBelowWindow:Number = this._scrollContentHeight - this._currContentY - this._viewableHeight;
if(contentHeightBelowWindow > 0)
{
if(contentHeightBelowWindow >= this._fullScreenScrollChange)
{
scrollAmt = this._fullScreenScrollChange;
}
else
{
for(i = this._numRowsInView - 2; i > 0; i--)
{
if(contentHeightBelowWindow >= this._snapHeight * i)
{
scrollAmt = this._snapHeight * i;
break;
}
}
if(scrollAmt < contentHeightBelowWindow)
{
scrollAmt = contentHeightBelowWindow;
}
}
}
return scrollAmt;
}
private function onMouseDownHandler(evt:MouseEvent) : void
{
evt.stopPropagation();
if(this._scrollHandle.height < this._scrollContentHeight - 3)
{
this._scrollHandle.startDrag(false,this._bounds);
this._scrollContent.parent.parent.addEventListener(MouseEvent.ROLL_OUT,this.onStageOut,false,0,true);
this._scrollContent.stage.addEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMoveHandler,false,0,true);
this._scrollContent.parent.stage.addEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler,false,0,true);
this._scrollContent.parent.parent.parent.addEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler,false,0,true);
}
}
private function onStageOut(evt:MouseEvent) : void
{
evt.stopPropagation();
this.onMouseUpHandler(evt);
}
private function onMouseUpHandler(evt:MouseEvent = null) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
this._scrollHandle.stopDrag();
if(Boolean(this._scrollTween))
{
this._scrollTween.end();
}
if(this._snapHeight > 0)
{
this.snapToPlace();
}
if(Boolean(this._scrollContent.stage))
{
this._scrollContent.stage.removeEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMoveHandler);
}
if(Boolean(this._scrollContent.parent.stage))
{
this._scrollContent.parent.stage.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler);
}
if(Boolean(this._scrollContent.parent.parent))
{
this._scrollContent.parent.parent.removeEventListener(MouseEvent.ROLL_OUT,this.onStageOut);
}
if(Boolean(this._scrollContent.parent.parent.parent))
{
this._scrollContent.parent.parent.parent.removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUpHandler);
}
}
private function onTrackDown(evt:MouseEvent) : void
{
var scrollAmt:Number = 0;
var point:Number = Math.ceil(evt.localY * evt.currentTarget.scaleY);
if(Boolean(this._scrollTween))
{
this._scrollTween.end();
}
if(point < this._scrollHandle.y + this._scrollHandle.height - this._topBtn.height)
{
scrollAmt = this.scrollUp();
}
else
{
scrollAmt = this.scrollDown();
}
if(scrollAmt != 0)
{
this.updateContentPosition(scrollAmt);
}
}
private function onMouseMoveHandler(evt:MouseEvent) : void
{
this.updateContentPosition();
}
private function onMouseWheelHandler(evt:MouseEvent) : void
{
var scrollAmt:Number = 0;
if(evt.delta > 0)
{
scrollAmt = this.scrollUp();
}
else
{
scrollAmt = this.scrollDown();
}
if(scrollAmt != 0)
{
this.updateContentPosition(scrollAmt);
}
}
private function createMask(viewableWidth:Number, viewableHeight:Number) : MovieClip
{
var maskMC:MovieClip = new MovieClip();
maskMC.graphics.beginFill(16777215);
maskMC.graphics.drawRect(0,0,viewableWidth,viewableHeight);
maskMC.graphics.endFill();
return maskMC;
}
private function resizeHandle() : void
{
var handleHeight:Number = NaN;
if(this._scrollContentHeight <= this._scrollContentMask.height || this._currContentY != this._scrollHeight && this._scrollContentHeight - this._currContentY - this._viewableHeight < this._snapHeight)
{
this._scrollHandle.visible = false;
if(Boolean(this._topBtn.hasGrayState) && Boolean(this._bottomBtn.hasGrayState))
{
this._topBtn.activateGrayState(true);
this._bottomBtn.activateGrayState(true);
}
if(this._scrollContent.parent.hasEventListener(MouseEvent.MOUSE_WHEEL))
{
this._scrollContent.parent.removeEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseWheelHandler);
}
}
else
{
handleHeight = this._scrollContentMask.height / this._scrollContentHeight * this._scrollContentMask.height - this._topBtn.height - this._bottomBtn.height;
this._topBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnClick,false,0,true);
this._bottomBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnClick,false,0,true);
this._scrollHandle.addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDownHandler,false,0,true);
this._track.addEventListener(MouseEvent.MOUSE_DOWN,this.onTrackDown,false,0,true);
this._scrollContent.parent.addEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseWheelHandler,false,0,true);
if(handleHeight < this.MIN_HANDLE_HEIGHT)
{
handleHeight = this.MIN_HANDLE_HEIGHT;
}
this._scrollHandle.mid.height = handleHeight - this._scrollHandle.top.height - this._scrollHandle.bot.height;
this._scrollHandle.top.y = 0;
this._scrollHandle.mid.y = this._scrollHandle.top.y + this._scrollHandle.top.height - 0.1;
this._scrollHandle.bot.y = this._scrollHandle.mid.y + this._scrollHandle.mid.height - 0.1;
}
}
}
}
@@ -0,0 +1,663 @@
package gui
{
import com.sbi.debug.DebugUtility;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.utils.getDefinitionByName;
import localization.LocalizationManager;
public class SafeChatManager
{
public static var sctNodes:Array;
public static var ctNodes:Array;
public static var photoBoothNodes:Array;
public static var adventureNodes:Array;
private static var SafeChatTreeNode:Class;
private static var _safeChatCallback:Function;
private static var _safeChatCallbackFromOtherSystem:Function;
private static var _safeChatBtn:MovieClip;
private static var _safeChatTree:MovieClip;
private static var _actionBtn:MovieClip;
private static var _actionWindow:Sprite;
private static var _emoteBtn:MovieClip;
private static var _emoteWindow:Sprite;
private static var _treeArray:Array;
private static var _nodeYLocation:Number;
private static var _lowestNodeYLocation:Number;
private static var _safeTreeNodeHeight:Number;
private static var _safeChatTreeNodes:MovieClip;
public static const TREE_SAFECHAT:int = 0;
public static const TREE_ECARDTEXT:int = 1;
public static const TREE_REPORTREASON:int = 2;
public static const TREE_PHOTOBOOTH:int = 3;
public static const TREE_ADVENTURE:int = 4;
private static const SCT_DIM_ALPHA:Number = 0.5;
private static const SCT_BRIGHT_ALPHA:Number = 1;
private static const JAG_LOCALIZATION_ID:int = 66;
private static const BC_LOCALIZATION_ID:int = 47;
private static const PHOTOBOOTH_LOCALIZATION_ID:int = 158;
private static const ADVENTURE_LOCALIZATION_ID:int = 170;
public function SafeChatManager()
{
super();
}
public static function init(safeChatSendCallback:Function, safeChatButton:MovieClip, safeChatTreeGui:MovieClip, actBtn:MovieClip, actWindow:Sprite, emoticonBtn:MovieClip, emoticonWindow:Sprite) : void
{
if(_safeChatCallback != null)
{
throw new Error("ERROR: Singleton SafeChatManager did not expect to be created twice!");
}
_safeChatCallback = safeChatSendCallback;
_safeChatBtn = safeChatButton;
_safeChatTree = safeChatTreeGui;
if(Boolean(sctNodes))
{
buildSafeChatTree(_safeChatTree);
}
_safeChatTree.visible = false;
_actionBtn = actBtn;
_actionWindow = actWindow;
_emoteBtn = emoticonBtn;
_emoteWindow = emoticonWindow;
}
public static function reload(reloadLists:Boolean, safeChatButton:MovieClip, safeChatTreeGui:MovieClip, actBtn:MovieClip, actWindow:Sprite, emoticonBtn:MovieClip, emoticonWindow:Sprite) : void
{
_safeChatTree = safeChatTreeGui;
_safeChatBtn = safeChatButton;
_safeChatTree.visible = false;
_actionBtn = actBtn;
_actionWindow = actWindow;
_emoteBtn = emoticonBtn;
_emoteWindow = emoticonWindow;
if(reloadLists)
{
while(_safeChatTree.numChildren > 1)
{
_safeChatTree.removeChildAt(_safeChatTree.numChildren - 1);
}
ctNodes = sctNodes = photoBoothNodes = adventureNodes = null;
requestSafeChatLists();
}
else if(_safeChatTree.numChildren < 2)
{
_safeChatTree.addChild(_safeChatTreeNodes);
}
_safeChatBtn.downToUpState();
}
public static function buildSafeChatTree(safeChatTreeGui:MovieClip, definitionName:String = null, type:int = 0, safeChatSendCallback:Function = null, initArray:Array = null) : void
{
var sizingNode:MovieClip = null;
var startingHeight:int = 0;
var i:uint = 0;
var n:MovieClip = null;
_safeChatCallbackFromOtherSystem = safeChatSendCallback;
if(definitionName == null)
{
definitionName = "SafeChatTreeNode";
}
SafeChatTreeNode = getDefinitionByName(definitionName) as Class;
if(initArray != null)
{
_treeArray = initArray;
}
else if(type == TREE_ECARDTEXT)
{
_treeArray = ctNodes;
}
else if(type == TREE_PHOTOBOOTH)
{
_treeArray = photoBoothNodes;
}
else if(type == TREE_ADVENTURE)
{
_treeArray = adventureNodes;
}
else
{
_treeArray = sctNodes;
}
if(Boolean(_treeArray))
{
sizingNode = new SafeChatTreeNode();
startingHeight = safeChatTreeGui.height - (_treeArray.length * sizingNode.height - 1);
_safeChatTreeNodes = new MovieClip();
for(i = 0; i < _treeArray.length; i++)
{
n = new SafeChatTreeNode();
n.x = 0;
n.y = startingHeight + i * (n.height - 1);
_safeChatTreeNodes.addChild(n);
n["menuNums"] = [i];
n.addEventListener(MouseEvent.MOUSE_DOWN,sctNodeMouseHandler,false,0,true);
if(_treeArray[i] is String)
{
LocalizationManager.updateToFit(n.sctNodeTxt,_treeArray[i]);
n.sctNodeBG.gotoAndStop(1);
}
else
{
if(!(_treeArray[i] is Array))
{
throw new Error("invalid type in sctNodes...");
}
_safeTreeNodeHeight = n.height;
_lowestNodeYLocation = startingHeight + (_treeArray.length - 1) * (_safeTreeNodeHeight - 1);
_nodeYLocation = n.y;
LocalizationManager.updateToFit(n.sctNodeTxt,_treeArray[i][0]);
n.sctNodeBG.gotoAndStop(3);
buildChatTreeSubMenu(_treeArray[i],DisplayObjectContainer(n),0);
}
}
safeChatTreeGui.addChild(_safeChatTreeNodes);
}
}
public static function requestSafeChatLists() : void
{
GenericListXtCommManager.requestGenericList(BC_LOCALIZATION_ID,onListLoaded);
GenericListXtCommManager.requestGenericList(JAG_LOCALIZATION_ID,onListLoaded);
GenericListXtCommManager.requestGenericList(PHOTOBOOTH_LOCALIZATION_ID,onListLoaded);
GenericListXtCommManager.requestGenericList(ADVENTURE_LOCALIZATION_ID,onListLoaded);
}
public static function containsInTreeArray(txt:String, type:int = 0) : Boolean
{
var currItem:Object = null;
var found:Boolean = false;
var treeArray:Array = null;
var j:int = 0;
if(type == TREE_ECARDTEXT)
{
treeArray = ctNodes;
}
else if(type == TREE_PHOTOBOOTH)
{
treeArray = photoBoothNodes;
}
else if(type == TREE_ADVENTURE)
{
treeArray = adventureNodes;
}
else
{
treeArray = sctNodes;
}
for(var i:int = 0; i < treeArray.length; i++)
{
currItem = treeArray[i];
if(currItem is Array)
{
for(j = 0; j < currItem.length; j++)
{
if(currItem[j] == txt)
{
return true;
}
}
}
else if(currItem == txt)
{
return true;
}
}
return false;
}
private static function onListLoaded(glId:int, locStrs:Array) : void
{
var delim:RegExp = null;
var splitArray:Array = null;
if(gMainFrame.server.isBlueboxMode())
{
delim = /&#10/g;
}
else
{
delim = /\r\n|\n|\r/g;
}
var tempArray:Array = [];
for(var i:int = 0; i < locStrs.length; i++)
{
splitArray = LocalizationManager.translateIdOnly(locStrs[i]).split(delim);
if(splitArray.length == 1)
{
tempArray.push(splitArray[0]);
}
else
{
tempArray.push(splitArray);
}
}
if(glId == BC_LOCALIZATION_ID)
{
sctNodes = tempArray;
}
else if(glId == JAG_LOCALIZATION_ID)
{
ctNodes = tempArray;
}
else if(glId == PHOTOBOOTH_LOCALIZATION_ID)
{
photoBoothNodes = tempArray;
}
else if(glId == ADVENTURE_LOCALIZATION_ID)
{
adventureNodes = tempArray;
}
else
{
DebugUtility.debugTrace("Loaded safe chat list that doesn\'t match!");
}
if(Boolean(ctNodes) && Boolean(sctNodes) && Boolean(photoBoothNodes) && Boolean(adventureNodes))
{
buildSafeChatTree(_safeChatTree);
}
}
private static function buildChatTreeSubMenu(scSubTree:Array, parentNode:DisplayObjectContainer, level:uint) : void
{
var sn:MovieClip = null;
var sil:uint = 0;
var doc:DisplayObjectContainer = null;
level++;
var outOfBoundYLocation:Number = _nodeYLocation + (scSubTree.length - 2) * (_safeTreeNodeHeight - 1);
if(outOfBoundYLocation > _lowestNodeYLocation)
{
_nodeYLocation -= outOfBoundYLocation - _lowestNodeYLocation;
}
for(var si:uint = 1; si < scSubTree.length; si++)
{
sn = new SafeChatTreeNode();
sn.x = level * sn.width - parentNode.x;
sn.y = _nodeYLocation + (si - 1) * (sn.height - 1);
sil = level;
doc = parentNode;
while(sil > 0)
{
sn.y -= doc.y;
doc = doc.parent;
sil--;
}
parentNode.addChild(sn);
sn.visible = false;
if(Boolean(sn.parent["menuNums"]))
{
sn["menuNums"] = sn.parent["menuNums"].slice();
sn["menuNums"].push(si);
}
else
{
sn["menuNums"] = [si];
}
sn.addEventListener(MouseEvent.MOUSE_DOWN,sctNodeMouseHandler,false,0,true);
if(scSubTree[si] is String)
{
LocalizationManager.updateToFit(sn.sctNodeTxt,scSubTree[si]);
sn.sctNodeBG.gotoAndStop(1);
}
else
{
if(!(scSubTree[si] is Array))
{
throw new Error("invalid type in scSubTree...");
}
LocalizationManager.updateToFit(sn.sctNodeTxt,scSubTree[si][0]);
sn.sctNodeBG.gotoAndStop(3);
buildChatTreeSubMenu(scSubTree[si],DisplayObjectContainer(sn),level);
}
}
}
public static function destroy(tree:MovieClip = null) : void
{
if(tree != null)
{
while(tree.numChildren > 1)
{
tree.getChildAt(tree.numChildren - 1).removeEventListener(MouseEvent.MOUSE_DOWN,sctNodeMouseHandler);
tree.removeChildAt(tree.numChildren - 1);
}
_safeChatCallbackFromOtherSystem = null;
tree.visible = false;
tree = null;
}
else
{
while(_safeChatTree.numChildren > 0)
{
_safeChatTree.getChildAt(0).removeEventListener(MouseEvent.MOUSE_DOWN,sctNodeMouseHandler);
_safeChatTree.removeChildAt(0);
}
_safeChatBtn = null;
_safeChatTree.visible = false;
_safeChatTree = null;
_actionBtn = null;
_actionWindow = null;
_emoteBtn = null;
_emoteWindow = null;
}
}
public static function traceDisplayList(container:DisplayObjectContainer, indentString:String = "") : void
{
var child:DisplayObject = null;
for(var i:uint = 0; i < container.numChildren; i++)
{
child = container.getChildAt(i);
if(child == null)
{
DebugUtility.debugTrace(indentString + "NULL?!");
}
else
{
DebugUtility.debugTrace(indentString + " " + child + " " + child.name);
}
if(child is DisplayObjectContainer)
{
traceDisplayList(DisplayObjectContainer(child),indentString + " ");
}
}
}
public static function resetSafeChatTree(isFromSafeChat:Boolean, tree:MovieClip = null) : void
{
var ro:DisplayObject = null;
var roc:DisplayObjectContainer = null;
var rr:uint = 0;
var dr:DisplayObject = null;
if(isFromSafeChat)
{
SafeChatTreeNode = getDefinitionByName("SafeChatTreeNode") as Class;
}
var tempTree:MovieClip = MovieClip(_safeChatTree.getChildAt(1));
if(Boolean(tree))
{
tempTree = tree;
}
for(var r:uint = 0; r < tempTree.numChildren; r++)
{
ro = tempTree.getChildAt(r);
if(Boolean(ro) && ro is DisplayObjectContainer)
{
if(ro is SafeChatTreeNode)
{
if(SafeChatTreeNode(ro).sctNodeBG.currentFrame == 4)
{
SafeChatTreeNode(ro).sctNodeBG.gotoAndStop(3);
}
if(SafeChatTreeNode(ro).sctNodeBG.currentFrame == 2)
{
SafeChatTreeNode(ro).sctNodeBG.gotoAndStop(1);
}
}
roc = DisplayObjectContainer(ro);
for(rr = 0; rr < roc.numChildren; rr++)
{
dr = roc.getChildAt(rr);
if(Boolean(dr) && dr is SafeChatTreeNode)
{
dr.visible = false;
SafeChatTreeNode(dr).sctNodeBG.gotoAndStop(1);
}
}
}
}
}
public static function showSafeChatInput(flag:Boolean) : void
{
_safeChatBtn.visible = flag;
_safeChatTree.visible = flag;
}
public static function safeChatCodeForString(msg:String, treeType:int = -1) : String
{
var currMenu:Array = null;
var parentMenuStr:String = null;
var j:int = 0;
if(treeType != -1 || _treeArray == null)
{
if(treeType == TREE_ECARDTEXT)
{
currMenu = ctNodes;
}
else if(treeType == TREE_PHOTOBOOTH)
{
currMenu = photoBoothNodes;
}
else if(treeType == TREE_ADVENTURE)
{
currMenu = adventureNodes;
}
else
{
currMenu = sctNodes;
}
}
else
{
currMenu = _treeArray;
}
for(var i:int = 0; i < currMenu.length; i++)
{
if(currMenu[i] is String)
{
if(currMenu[i] == msg)
{
return i + "0";
}
}
else
{
parentMenuStr = currMenu[i][0];
if(msg == parentMenuStr)
{
return String(i);
}
for(j = 1; j < currMenu[i].length; j++)
{
if(parentMenuStr.indexOf("...") > -1)
{
if(msg == parentMenuStr.substr(0,parentMenuStr.length - 3) + " " + currMenu[i][j])
{
return i + "," + j;
}
}
else if(currMenu[i][j] == msg)
{
return i + "," + j;
}
}
}
}
return null;
}
public static function safeChatStringForCode(code:String, treeType:int = -1) : String
{
var parentMenuStr:String = null;
var lookupMenus:Array = code.split(",");
if(treeType != -1 || _treeArray == null)
{
if(treeType == TREE_ECARDTEXT)
{
_treeArray = ctNodes;
}
else if(treeType == TREE_PHOTOBOOTH)
{
_treeArray = photoBoothNodes;
}
else if(treeType == TREE_ADVENTURE)
{
_treeArray = adventureNodes;
}
else
{
_treeArray = sctNodes;
}
}
else if(gMainFrame.clientInfo.roomType == Utility.ROOMTYPE_QUEST)
{
_treeArray = adventureNodes;
}
else
{
_treeArray = sctNodes;
}
var currMenu:Array = _treeArray;
for(var msc:uint = 0; msc < lookupMenus.length; msc++)
{
if(msc >= lookupMenus.length - 1)
{
if(currMenu[lookupMenus[msc]] is String)
{
if(Boolean(parentMenuStr) && Boolean(parentMenuStr.indexOf("...") > 0) && parentMenuStr.indexOf("...") == parentMenuStr.length - 3)
{
return parentMenuStr.substr(0,parentMenuStr.length - 3) + " " + currMenu[lookupMenus[msc]];
}
return currMenu[lookupMenus[msc]];
}
if(currMenu[lookupMenus[msc]] is Array)
{
return currMenu[lookupMenus[msc]][0];
}
return null;
}
if(currMenu[lookupMenus[msc]] is String)
{
return null;
}
if(!(currMenu[lookupMenus[msc]] is Array))
{
return null;
}
parentMenuStr = currMenu[lookupMenus[msc]][0];
currMenu = currMenu[lookupMenus[msc]];
}
return null;
}
public static function openSafeChat(isFromSafeChat:Boolean, tree:MovieClip = null) : void
{
if(Boolean(tree) && !tree.visible)
{
tree.visible = true;
resetSafeChatTree(isFromSafeChat,MovieClip(tree.getChildAt(1)));
}
else if(!_safeChatTree.visible)
{
_safeChatTree.visible = true;
resetSafeChatTree(isFromSafeChat);
brightenSafeChat();
}
}
public static function dimSafeChat() : void
{
if(_safeChatTree.visible && _safeChatTree.alpha != SCT_DIM_ALPHA)
{
_safeChatTree.alpha = SCT_DIM_ALPHA;
}
}
public static function brightenSafeChat() : void
{
if(_safeChatTree.alpha != SCT_BRIGHT_ALPHA)
{
_safeChatTree.alpha = SCT_BRIGHT_ALPHA;
}
}
public static function closeSafeChat(tree:MovieClip = null) : void
{
if(Boolean(tree) && tree.visible)
{
tree.visible = false;
}
else if(Boolean(_safeChatTree) && _safeChatTree.visible)
{
_safeChatTree.visible = false;
_safeChatBtn.downToUpState();
}
}
public static function showHide() : void
{
_safeChatTree.visible = !_safeChatTree.visible;
}
public static function sctNodeMouseHandler(mEvt:MouseEvent) : void
{
var sctParentStr:String = null;
mEvt.stopPropagation();
brightenSafeChat();
if(!mEvt.currentTarget is SafeChatTreeNode)
{
DebugUtility.debugTrace("ERROR: illegal event type in sctNodeMouseHandler!");
return;
}
if(!Utility.canChat())
{
return;
}
var sctLocalDisplayStr:String = mEvt.currentTarget.sctNodeTxt.text;
if(sctLocalDisplayStr.indexOf("...") >= 0)
{
return;
}
if(Boolean(mEvt.currentTarget.parent.sctNodeTxt))
{
sctParentStr = mEvt.currentTarget.parent.sctNodeTxt.text;
if(sctParentStr.indexOf("...") > 0)
{
sctLocalDisplayStr = sctParentStr.slice(0,sctParentStr.indexOf("...")) + " " + sctLocalDisplayStr;
}
}
if(_safeChatCallbackFromOtherSystem != null)
{
_safeChatCallbackFromOtherSystem(sctLocalDisplayStr,mEvt.currentTarget.menuNums.toString());
}
else
{
_safeChatCallback(sctLocalDisplayStr,mEvt.currentTarget.menuNums.toString());
}
}
}
}
@@ -0,0 +1,301 @@
package gui
{
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBPopup;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import localization.LocalizationManager;
import room.RoomXtCommManager;
public class ServerSelector
{
private static var _popupLayer:DisplayObjectContainer;
private static var _closeCallback:Function;
private static var _serverAllContent:MovieClip;
private static var _serverAll:MovieClip;
private static var _scrollButtons:SBScrollbar;
private static var _itemWindows:WindowGenerator;
private static var _serverAllPopup:SBPopup;
private static var _availShards:Array;
private static var _serverNames:Array;
private static var _numBuddies:Array;
private static var _languageIds:Array;
private static var _popuplation:Array;
private static var _nameIdx:int;
private static var _lastClickedShardTarget:Object;
private static const NUM_Y_WIN:int = 10;
public function ServerSelector()
{
super();
}
public static function init(guiLayer:DisplayObjectContainer, initData:Object, initCloseCallback:Function = null, initPopupX:int = 450, initPopupY:int = 275) : void
{
_popupLayer = guiLayer;
_lastClickedShardTarget = null;
_closeCallback = initCloseCallback;
_availShards = [];
_numBuddies = [];
_languageIds = [];
_popuplation = [];
_nameIdx = 0;
_serverAllContent = GETDEFINITIONBYNAME("ServerAllPopupContent");
_serverAllPopup = new SBPopup(_popupLayer,GETDEFINITIONBYNAME("ServerAllPopupSkin"),_serverAllContent,true,true,false,false,true);
_serverAllPopup.bxClosesPopup = false;
_serverAllPopup.x = initPopupX;
_serverAllPopup.y = initPopupY;
DarkenManager.showLoadingSpiral(true);
MovieClip(_serverAllPopup.content).helpNameBtn.visible = false;
fillNamesArray();
SBTracker.trackPageview("/game/play/shardDetail");
addListeners();
}
public static function isOpen() : Boolean
{
if(Boolean(_serverAllPopup))
{
return _serverAllPopup.visible;
}
return false;
}
public static function destroy() : void
{
removeListeners();
if(Boolean(_itemWindows))
{
_itemWindows.destroy();
_itemWindows = null;
}
if(Boolean(_serverAllPopup))
{
_serverAllPopup.x = undefined;
_serverAllPopup.y = undefined;
_serverAllPopup.destroy();
_serverAllPopup = null;
}
_closeCallback = null;
}
public static function setupAllShards(data:Object, lastShardId:int) : void
{
var isEmpty:Boolean = false;
var totalPopulation:int = 0;
var newIndex:int = 0;
var newLang:int = 0;
var slr:int = 0;
var i:int = 0;
var firstSkippedShardId:int = -1;
var numEmptySoFar:int = 0;
var myLang:int = LocalizationManager.accountLanguage;
_availShards = [];
_languageIds = [];
_popuplation = [];
_numBuddies = [];
while(data[slr] != null)
{
isEmpty = data[slr + 2] == 0;
if(isEmpty)
{
numEmptySoFar++;
}
if(isEmpty && numEmptySoFar > 5)
{
if(firstSkippedShardId == -1)
{
firstSkippedShardId = int(data[slr]);
}
slr += 4;
}
else
{
_availShards[i] = data[slr++];
_languageIds[i] = data[slr++];
totalPopulation += int(data[slr]);
_popuplation[i] = data[slr++];
_numBuddies[i] = data[slr++];
i++;
}
}
if(totalPopulation >= _availShards.length * 4 && i < _serverNames.length)
{
if(firstSkippedShardId == -1)
{
newIndex = lastShardId + 1;
newLang = myLang;
}
else
{
newIndex = firstSkippedShardId;
newLang = int(_languageIds[firstSkippedShardId]);
}
_availShards.splice(0,0,String(newIndex));
_languageIds.splice(0,0,String(newLang));
_popuplation.splice(0,0,String(0));
_numBuddies.splice(0,0,String(0));
}
createServerButtons();
}
public static function getShardName(shardId:int) : String
{
var shardIdx:int = shardId - 1;
if(Boolean(_serverNames) && 0 <= shardIdx)
{
return LocalizationManager.translateIdOnly(_serverNames[shardIdx % _serverNames.length]);
}
return "Nullandria" + shardId;
}
public static function fillNamesArray(isFromWorld:Boolean = false) : void
{
if(_serverNames == null || _serverNames.length == 0)
{
GenericListXtCommManager.requestGenericList(16,onShardNamesCallback,null,isFromWorld);
}
else
{
RoomXtCommManager.sendMoreShardRequest();
}
}
public static function updatePopulationForRoomFullError() : void
{
if(Boolean(_lastClickedShardTarget))
{
_lastClickedShardTarget.population = "4";
}
}
private static function setupMoreServers(mc:MovieClip) : void
{
var langId:int = 0;
var availShardsIdx:int = (_availShards[_nameIdx] - 1) % _serverNames.length;
if(availShardsIdx < _serverNames.length)
{
LocalizationManager.translateId(mc.textField,_serverNames[availShardsIdx]);
if(_numBuddies[mc.index] > 0)
{
mc.buddy = true;
}
else
{
mc.buddy = false;
}
langId = int(_languageIds[mc.index]);
if(langId == LocalizationManager.LANG_ENG)
{
langId = LocalizationManager.LANG_BLANK;
}
mc.flag = langId + 1;
if(_popuplation[mc.index] > 0)
{
mc.population = _popuplation[mc.index];
}
else
{
mc.population = "0";
}
++_nameIdx;
return;
}
_nameIdx = 0;
setupMoreServers(mc);
}
private static function createServerButtons() : void
{
var mc:MovieClip = null;
if(Boolean(_scrollButtons))
{
_scrollButtons.destroy();
_scrollButtons = null;
}
if(Boolean(_itemWindows) && _itemWindows.numChildren > 0)
{
_itemWindows.destroy();
_itemWindows = null;
}
var numItemsInCurrentArray:int = int(_availShards.length);
var xCount:int = Math.min(numItemsInCurrentArray,2);
var yCount:int = Math.min(numItemsInCurrentArray,NUM_Y_WIN);
_itemWindows = new WindowGenerator();
_itemWindows.init(xCount,yCount,numItemsInCurrentArray,20,8,10,ItemWindowServer,null,"",{"mouseDown":winMouseDown},null,null,false,false);
_serverAllContent.itemBlock.addChild(_itemWindows);
_itemWindows.x = 0;
_itemWindows.y = 0;
_nameIdx = 0;
for(var i:int = 0; i < numItemsInCurrentArray; i++)
{
mc = MovieClip(_itemWindows.bg.getChildAt(i));
setupMoreServers(mc);
}
_scrollButtons = new SBScrollbar();
_scrollButtons.init(_itemWindows,_serverAllContent.itemBlock.width - 31,_itemWindows.boxHeight * NUM_Y_WIN + 8 * NUM_Y_WIN,0,"scrollbar2",_itemWindows.boxHeight + 8);
DarkenManager.showLoadingSpiral(false);
}
private static function winMouseDown(m:MouseEvent) : void
{
m.stopPropagation();
DarkenManager.showLoadingSpiral(true);
_lastClickedShardTarget = m.currentTarget;
if(Boolean(m.currentTarget.full))
{
if(_closeCallback != null)
{
_closeCallback(_availShards[m.currentTarget.index]);
}
}
else if(_closeCallback != null)
{
_closeCallback(_availShards[m.currentTarget.index]);
}
}
private static function onShardNamesCallback(glId:int, locStrings:Array) : void
{
_serverNames = locStrings;
}
private static function onCloseBtn(evt:MouseEvent) : void
{
destroy();
}
private static function onNamesBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
FeedbackManager.openFeedbackPopup(FeedbackManager.TYPE_SERVERS);
}
private static function addListeners() : void
{
_serverAllPopup.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn,false,0,true);
}
private static function removeListeners() : void
{
_serverAllPopup.skin.s["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,onCloseBtn);
}
}
}
@@ -0,0 +1,70 @@
package gui
{
public class SharedAvatarAnimalConstants
{
public static const AV_TIGER:int = 1;
public static const AV_EAGLE:int = 2;
public static const AV_DEER:int = 3;
public static const AV_WOLF:int = 4;
public static const AV_KOALA:int = 5;
public static const AV_PANDA:int = 6;
public static const AV_MONKEY:int = 7;
public static const AV_BUNNY:int = 8;
public static const AV_HYENA:int = 9;
public static const AV_OTTER:int = 10;
public static const AV_POLAR_BEAR:int = 11;
public static const AV_RHINO:int = 13;
public static const AV_CROC:int = 15;
public static const AV_ELEPHANT:int = 16;
public static const AV_LION:int = 17;
public static const AV_SEAL:int = 18;
public static const AV_DOLPHIN:int = 19;
public static const AV_SHARK:int = 20;
public static const AV_OCTOPUS:int = 21;
public static const AV_TURTLE:int = 22;
public static const AV_HORSE:int = 23;
public static const AV_PENGUIN:int = 24;
public static const AV_FOX:int = 25;
public static const AV_GIRAFFE:int = 26;
public static const AV_KANGAROO:int = 27;
public static const AV_ARCTIC_WOLF:int = 28;
public static const AV_SNOW_LEOPARD:int = 29;
public static const AV_RACCOON:int = 30;
public static const AV_CHEETAH:int = 31;
public function SharedAvatarAnimalConstants()
{
super();
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,964 @@
package gui
{
import achievement.Achievement;
import achievement.AchievementXtCommManager;
import avatar.Avatar;
import avatar.AvatarManager;
import avatar.AvatarSwitch;
import avatar.AvatarUtility;
import avatar.AvatarView;
import com.sbi.analytics.SBTracker;
import com.sbi.graphics.LayerAnim;
import com.sbi.graphics.LayerBitmap;
import com.sbi.popup.SBOkPopup;
import den.DenItem;
import den.DenXtCommManager;
import diamond.DiamondXtCommManager;
import ecard.ECard;
import ecard.ECardManager;
import ecard.ECardXtCommManager;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import gskinner.motion.GTween;
import gskinner.motion.easing.Circular;
import gskinner.motion.easing.Quadratic;
import item.Item;
import item.SimpleIcon;
import loader.DenItemHelper;
import loader.MediaHelper;
import localization.LocalizationManager;
import pet.PetManager;
import room.RoomManagerWorld;
public class StartupPopups
{
public static const GEMS_MEDIA_ID:int = 1086;
public static const DIAMOND_MEDIA_ID:int = 2221;
public static const DIAMOND_ANIMAL_REDEEM_ID:int = 2254;
public static const JOEY_MEDIA_ID:int = 2541;
private const EXPIRING_MESSAGE:int = 1953;
private const PROMOTION_CODE:int = 1068;
private const WELCOME_POPUP:int = 85;
private const NEW_MEMBER:int = 117;
private const DEMOTION_MESSAGE:int = 156;
private const PLAYER_ENGAGEMENT:int = 1567;
private var _loadTheseMediaItems:Array;
private var _mediaViews:Array;
private var _popupImages:Array;
private var _popupLayer:DisplayLayer;
private var _imageBeingLoaded:Boolean;
private var _imageToLoad:MovieClip;
private var _expiringPopup:MovieClip;
private var _codePopup:MovieClip;
private var _welcomePopup:MovieClip;
private var _loginBonusPopup:MovieClip;
private var _newMemberPopup:MovieClip;
private var _demotionMessagePopup:MovieClip;
private var _joeyPopup:MovieClip;
private var _welcomeRoomURI:String;
private var _redemptionList:Array;
private var _currRedemECard:ECard;
private var _clothingIcon:LayerBitmap;
private var _clothingIconHelper:SimpleIcon;
private var _denIconHelper:DenItemHelper;
private var _avtView:AvatarView;
private var _extendingMembershipJAGMsgId:int;
private var _numPetsToCreate:int;
private var _numPetCallbacks:int;
private var _numDiamondsReceiving:int;
private var _diamondECards:Array;
private var _diamondRedeemPopup:MovieClip;
private var _numJumpGemsReceiving:int;
private var _jumpGemsECards:Array;
private var _isFromDailySpin:Boolean;
public function StartupPopups()
{
super();
}
public function init(initPopupLayer:DisplayLayer, isFromDailySpin:Boolean = false) : void
{
this._popupLayer = initPopupLayer;
this._loadTheseMediaItems = new Array();
this._mediaViews = new Array();
this._popupImages = new Array();
this._redemptionList = new Array();
this._diamondECards = [];
this._jumpGemsECards = [];
this._imageBeingLoaded = false;
this._isFromDailySpin = isFromDailySpin;
RoomManagerWorld.instance.callback_InitialDataRequest = this.requestInitialData;
if(gMainFrame.clientInfo.numRedemptionCards > 0 || !gMainFrame.userInfo.isMember && gMainFrame.clientInfo.numAJHQGiftCards > 0 || this._isFromDailySpin)
{
ECardXtCommManager.sendECardListRequest(this.redemptionCardsRequest);
this._loadTheseMediaItems.push(this.PROMOTION_CODE);
}
else
{
this.setupAndLoadAllPopups();
}
}
private function setupAndLoadAllPopups() : void
{
var popupsMediaHelper:MediaHelper = null;
if(!this._isFromDailySpin)
{
if(Boolean(gMainFrame.userInfo.isMember && gMainFrame.clientInfo.numDaysLeftOnSubscription > 0 && gMainFrame.clientInfo.numDaysLeftOnSubscription < 6 && GuiManager.sharedObj) && (Boolean(GuiManager.sharedObj.data.expiration == null || GuiManager.sharedObj.data.expiration + 86400000 <= new Date().millisecondsUTC)) && gMainFrame.clientInfo.dbUserId % 2 == 0)
{
this._loadTheseMediaItems.push(this.EXPIRING_MESSAGE);
}
if(Boolean(gMainFrame.clientInfo.accountTypeChanged) && Boolean(gMainFrame.userInfo.isMember) || this._extendingMembershipJAGMsgId > 0)
{
this._loadTheseMediaItems.push(this.NEW_MEMBER);
}
if(!gMainFrame.userInfo.isMember && AvatarSwitch.availSlotFlags == 0)
{
this._loadTheseMediaItems.push(this.DEMOTION_MESSAGE);
}
if(GuiManager.wasInFFM)
{
this._loadTheseMediaItems.push(this.PLAYER_ENGAGEMENT);
}
}
for(var i:int = 0; i < this._loadTheseMediaItems.length; i++)
{
popupsMediaHelper = new MediaHelper();
popupsMediaHelper.init(this._loadTheseMediaItems[i],this.popupsMediaCallback,true);
this._mediaViews[i] = popupsMediaHelper;
}
if(this._loadTheseMediaItems.length == 0)
{
DarkenManager.showLoadingSpiral(false);
this.requestInitialData();
this.destroy();
}
}
private function popupsMediaCallback(img:MovieClip) : void
{
var i:int = 0;
if(Boolean(img))
{
for(i = 0; i < this._loadTheseMediaItems.length; i++)
{
if(img.mediaHelper.id == this._loadTheseMediaItems[i])
{
this._popupImages[i] = img;
break;
}
}
this.loadNextPopup();
}
}
public function requestInitialData() : void
{
if(Boolean(gMainFrame.clientInfo.hasOnlineBuddies) && Utility.canBuddy())
{
BuddyList.startBuddyListBtnGlow();
}
if(this._loadTheseMediaItems.length == 0)
{
if(Boolean(gMainFrame.userInfo.isMember) && gMainFrame.userInfo.userVarCache.getUserVarValueById(Achievement.MEMBER_NEW) == -1)
{
AchievementXtCommManager.requestSetUserVar(Achievement.MEMBER_NEW,1);
}
GuiManager.guiStartupChecks();
}
if(gMainFrame.clientInfo.numUnreadECards > 0)
{
ECardManager.unreadCount = gMainFrame.clientInfo.numUnreadECards;
}
}
public function setWelcomeRoomName(name:String) : void
{
this._welcomeRoomURI = name;
}
private function destroy() : void
{
var i:int = 0;
SBTracker.flush();
if(Boolean(this._welcomeRoomURI))
{
SBTracker.trackPageview(this._welcomeRoomURI);
}
if(Boolean(this._mediaViews))
{
for(i = 0; i < this._mediaViews.length; i++)
{
this._mediaViews[i].destroy();
this._mediaViews[i] = null;
}
}
RoomManagerWorld.instance.callback_InitialDataRequest = null;
this._expiringPopup = null;
this._codePopup = null;
this._welcomePopup = null;
this._loginBonusPopup = null;
this._newMemberPopup = null;
this._demotionMessagePopup = null;
this._imageBeingLoaded = false;
this._loadTheseMediaItems = null;
this._mediaViews = null;
this._popupImages = null;
}
private function loadNextPopup(doStartUpChecks:Boolean = true) : void
{
var i:int = 0;
if(!this._loadTheseMediaItems)
{
return;
}
if(this._loadTheseMediaItems.length > 0 && this._popupImages.length > 0 && !this._imageBeingLoaded)
{
i = 0;
if(i < this._loadTheseMediaItems.length)
{
while(true)
{
if(Boolean(this._popupImages[i]))
{
switch(this._loadTheseMediaItems[i])
{
case this.PROMOTION_CODE:
this._imageBeingLoaded = true;
this._currRedemECard = this._redemptionList[0];
if(Boolean(this._currRedemECard))
{
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/promotionCode/#" + this._currRedemECard.msg,-1,SBTracker.TYPE_EVENT);
this.loadRedemptionImage(this._currRedemECard);
}
break;
case this.EXPIRING_MESSAGE:
this._imageBeingLoaded = true;
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/expiration/" + gMainFrame.clientInfo.numDaysLeftOnSubscription);
this.createExpiringPopup(this._popupImages[i]);
break;
case this.WELCOME_POPUP:
this._imageBeingLoaded = true;
this.createWelcomePopup(this._popupImages[i]);
break;
case this.NEW_MEMBER:
this._imageBeingLoaded = true;
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/newMember",-1,SBTracker.TYPE_EVENT);
this.createNewMemberPopup(this._popupImages[i]);
break;
case this.DEMOTION_MESSAGE:
this._imageBeingLoaded = true;
this._imageToLoad = this._popupImages[i];
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/demotion/page1");
this.createDemotionPopup(this._imageToLoad);
break;
case this.PLAYER_ENGAGEMENT:
this._imageBeingLoaded = true;
this._imageToLoad = this._popupImages[i];
SBTracker.trackPageview("/game/play/popup/playerEngagement",-1,SBTracker.TYPE_EVENT);
this.createPlayerEngagement(this._imageToLoad);
}
if(this._imageBeingLoaded)
{
this._loadTheseMediaItems.splice(i,1);
this._popupImages.splice(i,1);
break;
}
}
break;
}
}
}
else if(this._loadTheseMediaItems.length == 0)
{
if(Boolean(gMainFrame.userInfo.isMember) && gMainFrame.userInfo.userVarCache.getUserVarValueById(Achievement.MEMBER_NEW) == -1)
{
AchievementXtCommManager.requestSetUserVar(Achievement.MEMBER_NEW,1);
}
if(doStartUpChecks)
{
GuiManager.guiStartupChecks();
}
this.destroy();
}
}
private function redemptionCardsRequest(list:Array) : void
{
var currCard:ECard = null;
for(var i:int = 0; i < list.length; i++)
{
currCard = list[i];
if(currCard.isRedemptionJAG)
{
if(currCard.type == ECard.TYPE_SUBSCRIPTION)
{
this._extendingMembershipJAGMsgId = currCard.msgId;
}
else if(currCard.type == ECard.TYPE_DIAMOND)
{
if(currCard.giftColor != 0)
{
this._redemptionList.push(list[i]);
}
else
{
if(this._numDiamondsReceiving == 0)
{
this._redemptionList.push(list[i]);
}
else
{
this._diamondECards.push(list[i]);
}
this._numDiamondsReceiving += int(currCard.giftId);
}
}
else if(currCard.type == ECard.TYPE_GEMS)
{
if(currCard.stampMediaId > 0)
{
if(currCard.stampMediaId == 1)
{
if(this._numJumpGemsReceiving == 0)
{
this._redemptionList.push(list[i]);
}
else
{
this._jumpGemsECards.push(list[i]);
}
this._numJumpGemsReceiving += int(currCard.giftId);
}
}
else
{
this._redemptionList.push(list[i]);
}
}
else
{
this._redemptionList.push(list[i]);
}
}
}
if(this._redemptionList.length <= 0)
{
for(i = 0; i < this._loadTheseMediaItems.length; i++)
{
if(this._loadTheseMediaItems[i] == this.PROMOTION_CODE)
{
this._loadTheseMediaItems.splice(i,1);
break;
}
}
}
this.setupAndLoadAllPopups();
}
private function createExpiringPopup(img:MovieClip) : void
{
if(Boolean(img))
{
GuiManager.setSharedObj("expiration",new Date().millisecondsUTC);
this._expiringPopup = MovieClip(img.getChildAt(0)).expiringMemberPopup;
this._expiringPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.popupMouseDownHandler,false,0,true);
this._expiringPopup["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler,false,0,true);
this._expiringPopup["renewBtn"].addEventListener(MouseEvent.MOUSE_DOWN,this.onRenew,false,0,true);
if(gMainFrame.clientInfo.numDaysLeftOnSubscription > 1)
{
LocalizationManager.translateIdAndInsert(this._expiringPopup.daysTxt,11119,gMainFrame.clientInfo.numDaysLeftOnSubscription);
}
else
{
LocalizationManager.translateIdAndInsert(this._expiringPopup.daysTxt,11118,gMainFrame.clientInfo.numDaysLeftOnSubscription);
}
this._expiringPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._expiringPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._popupLayer.addChild(this._expiringPopup.parent.parent);
this._expiringPopup.scaleX = this._expiringPopup.scaleY = 0.1;
new GTween(this._expiringPopup,0.25,{
"scaleX":1.2,
"scaleY":1.2
},{
"ease":Circular.easeIn,
"onComplete":this.onExpiringPopupTweenComplete
});
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._expiringPopup.parent.parent);
}
}
private function createWelcomePopup(img:MovieClip) : void
{
if(Boolean(img))
{
this._welcomePopup = img;
this._welcomePopup.getChildAt(0)["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler,false,0,true);
this._welcomePopup.addEventListener(MouseEvent.MOUSE_DOWN,this.popupMouseDownHandler,false,0,true);
this._welcomePopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._welcomePopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._popupLayer.addChild(this._welcomePopup);
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._welcomePopup);
}
}
private function createNewMemberPopup(img:MovieClip) : void
{
if(Boolean(img))
{
this._newMemberPopup = MovieClip(img.getChildAt(0)).newMemberPopup;
this._newMemberPopup["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler,false,0,true);
if(this._extendingMembershipJAGMsgId > 0)
{
this._newMemberPopup["c"].p1.visible = false;
this._newMemberPopup["c"].p2.visible = false;
}
else
{
this._newMemberPopup["c"].p2.visible = false;
this._newMemberPopup["c"].p3.visible = false;
this._newMemberPopup["c"].p1.features.addEventListener(MouseEvent.MOUSE_DOWN,this.newMemberFeaturesBtn,false,0,true);
this._newMemberPopup["c"].p2.back.addEventListener(MouseEvent.MOUSE_DOWN,this.newMemberBackBtn,false,0,true);
}
this._newMemberPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.popupMouseDownHandler,false,0,true);
this._newMemberPopup.parent.parent.x = MainFrame.VIEW_WIDTH * 0.5;
this._newMemberPopup.parent.parent.y = MainFrame.VIEW_HEIGHT * 0.5;
this._popupLayer.addChild(this._newMemberPopup.parent.parent);
this._newMemberPopup.scaleX = this._newMemberPopup.scaleY = 0.1;
new GTween(this._newMemberPopup,0.25,{
"scaleX":1.2,
"scaleY":1.2
},{
"ease":Circular.easeIn,
"onComplete":this.onNewMemberTweenComplete
});
DarkenManager.showLoadingSpiral(false);
DarkenManager.darken(this._newMemberPopup.parent.parent);
}
}
private function onDiamondRedeemPopupLoaded(img:MovieClip) : void
{
var avt:Avatar = null;
var avtView:AvatarView = null;
var posPoint:Point = null;
if(Boolean(img))
{
DarkenManager.showLoadingSpiral(false);
this._diamondRedeemPopup = MovieClip(img.getChildAt(0));
this._diamondRedeemPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.popupMouseDownHandler,false,0,true);
this._diamondRedeemPopup.saveBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSaveDiamonds,false,0,true);
this._diamondRedeemPopup.redeemBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onRedeemDiamonds,false,0,true);
this._diamondRedeemPopup.diamondItem = DiamondXtCommManager.getDiamondItem(img.passback.diamondDef);
this._diamondRedeemPopup.numDiamondsReceived = img.passback.numDiamondsReceived;
avt = AvatarUtility.creationAvatars[AvatarUtility.findAvatarIndexByType(this._diamondRedeemPopup.diamondItem.refDefId)];
avtView = new AvatarView();
avtView.init(avt);
avtView.playAnim(LayerAnim.AN_BBCARD,false,LayerAnim.PLAY_ONE_SHOT,null);
if(Boolean(this._diamondRedeemPopup))
{
this._diamondRedeemPopup.avatarName = LocalizationManager.translateIdOnly(gMainFrame.userInfo.getAvatarDefByAvType(this._diamondRedeemPopup.diamondItem.refDefId).titleStrRef);
LocalizationManager.translateIdAndInsert(this._diamondRedeemPopup.txt,11385,this._diamondRedeemPopup.avatarName);
}
posPoint = AvatarUtility.getAnimalItemWindowOffset(this._diamondRedeemPopup.diamondItem.refDefId);
avtView.x = posPoint.x;
avtView.y = posPoint.y;
this._diamondRedeemPopup.itemLayer.addChild(avtView);
this._diamondRedeemPopup.x = MainFrame.VIEW_WIDTH * 0.5;
this._diamondRedeemPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
this._popupLayer.addChild(this._diamondRedeemPopup);
DarkenManager.darken(this._diamondRedeemPopup);
}
}
private function destroyDiamondRedeemPopup(evt:MouseEvent = null) : void
{
var o:Object = null;
if(Boolean(evt))
{
evt.stopPropagation();
SBOkPopup.destroyInParentChain(evt.target.parent);
}
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(this._currRedemECard.msgId,false,this.onGiftAcceptRejectResponse);
this._diamondRedeemPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.popupMouseDownHandler);
this._diamondRedeemPopup.saveBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSaveDiamonds);
this._diamondRedeemPopup.redeemBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onRedeemDiamonds);
for(var i:int = 0; i < this._diamondRedeemPopup.itemLayer.numChildren; i++)
{
o = this._diamondRedeemPopup.itemLayer.getChildAt(0);
if(o is AvatarView)
{
o.destroy(true);
o = null;
break;
}
}
DarkenManager.unDarken(this._diamondRedeemPopup);
this._popupLayer.removeChild(this._diamondRedeemPopup);
this._diamondRedeemPopup = null;
this._imageBeingLoaded = false;
this.loadNextPopup();
}
private function onNewMemberTweenComplete(tween:GTween) : void
{
new GTween(this._newMemberPopup,0.3,{
"scaleX":1,
"scaleY":1
},{"ease":Quadratic.easeIn});
}
private function onExpiringPopupTweenComplete(tween:GTween) : void
{
new GTween(this._expiringPopup,0.3,{
"scaleX":1,
"scaleY":1
},{"ease":Quadratic.easeIn});
}
private function createPlayerEngagement(img:MovieClip) : void
{
GuiManager.initPlayerEngagement(this.loadNextPopup);
}
private function createDemotionPopup(img:MovieClip) : void
{
GuiManager.initDemotionMessage(this.loadNextPopup);
}
private function checkRedemptionStatus() : void
{
GuiManager.destroyPromotionalPopup();
if(this._redemptionList.length > 0)
{
this._currRedemECard = this._redemptionList[0];
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/promotionCode/#" + this._currRedemECard.msg,-1,SBTracker.TYPE_EVENT);
this.loadRedemptionImage(this._currRedemECard);
}
else
{
this._imageBeingLoaded = false;
this.loadNextPopup();
}
}
private function setupGiftPopup(img:Sprite) : void
{
var giftName:String = null;
var splitMsg:Array = null;
DarkenManager.showLoadingSpiral(false);
var onGiftCloseMsg:String = "";
var tempMsg:String = this._currRedemECard.msg;
if(this._currRedemECard.type == ECard.TYPE_DEN_ROOM || this._currRedemECard.type == ECard.TYPE_AVT)
{
splitMsg = tempMsg.split("|");
if(splitMsg.length == 5)
{
onGiftCloseMsg = LocalizationManager.translateIdAndInsertOnly(int(splitMsg[1]),LocalizationManager.translateIdOnly(int(splitMsg[2])),Utility.convertNumberToString(int(splitMsg[3])),LocalizationManager.translateIdOnly(int(splitMsg[4])));
}
else if(splitMsg.length == 4)
{
onGiftCloseMsg = LocalizationManager.translateIdAndInsertOnly(int(splitMsg[1]),LocalizationManager.translateIdOnly(int(splitMsg[2])),LocalizationManager.translateIdOnly(int(splitMsg[3])));
}
}
var popupType:int = this._currRedemECard.isAJHQGift ? GiftPopup.POPUP_TYPE_HQ : GiftPopup.POPUP_TYPE_PROMO;
if(this._currRedemECard.type == ECard.TYPE_DIAMOND)
{
giftName = LocalizationManager.translateIdAndInsertOnly(this._numDiamondsReceiving > 1 ? LocalizationManager.DIAMONDS_CAPITALIZED : LocalizationManager.DIAMOND_CAPITALIZED,this._numDiamondsReceiving);
}
else
{
giftName = this._currRedemECard.giftName;
}
GuiManager.openGiftPopup(img,giftName,this._currRedemECard.giftId,this._currRedemECard.type,this.keepGiftCallback,this.rejectGiftCallback,this.checkRedemptionStatus,GiftPopup.buttonsTypeForECardType(this._currRedemECard.type),onGiftCloseMsg,popupType,tempMsg,true);
this._redemptionList.splice(0,1);
}
private function keepPetCallback() : void
{
var msgId:int = this._currRedemECard.msgId;
if(!GuiManager.closePromoPopup())
{
this._redemptionList.splice(0,1);
++this._numPetCallbacks;
if(this._numPetCallbacks == this._numPetsToCreate)
{
this.checkRedemptionStatus();
}
}
}
private function keepGiftCallback() : void
{
var i:int = 0;
var msgId:int = this._currRedemECard.msgId;
var type:int = this._currRedemECard.type;
var stampMediaId:int = this._currRedemECard.stampMediaId;
if(!GuiManager.closePromoPopup())
{
this.checkRedemptionStatus();
}
DarkenManager.showLoadingSpiral(true);
if(type == ECard.TYPE_DIAMOND)
{
for(i = 0; i < this._diamondECards.length; i++)
{
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(this._diamondECards[i].msgId,true,this.onGiftAcceptRejectResponse);
}
this._diamondECards = null;
this._numDiamondsReceiving = 0;
}
else if(type == ECard.TYPE_GEMS)
{
if(stampMediaId > 0)
{
if(stampMediaId == 1)
{
for(i = 0; i < this._jumpGemsECards.length; i++)
{
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(this._jumpGemsECards[i].msgId,true,this.onGiftAcceptRejectResponse);
}
this._jumpGemsECards = null;
this._numJumpGemsReceiving = 0;
}
}
}
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(msgId,true,this.onGiftAcceptRejectResponse);
}
private function rejectGiftCallback() : void
{
var i:int = 0;
var msgId:int = this._currRedemECard.msgId;
var type:int = this._currRedemECard.type;
var stampMediaId:int = this._currRedemECard.stampMediaId;
if(!GuiManager.closePromoPopup())
{
this.checkRedemptionStatus();
}
DarkenManager.showLoadingSpiral(true);
if(type == ECard.TYPE_DIAMOND)
{
for(i = 0; i < this._diamondECards.length; i++)
{
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(this._diamondECards[i].msgId,false,this.onGiftAcceptRejectResponse);
}
this._diamondECards = null;
this._numDiamondsReceiving = 0;
}
else if(type == ECard.TYPE_GEMS)
{
if(stampMediaId > 0)
{
if(stampMediaId == 1)
{
for(i = 0; i < this._jumpGemsECards.length; i++)
{
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(this._jumpGemsECards[i].msgId,false,this.onGiftAcceptRejectResponse);
}
this._jumpGemsECards = null;
this._numJumpGemsReceiving = 0;
}
}
}
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(msgId,false,this.onGiftAcceptRejectResponse);
}
private function onGiftAcceptRejectResponse(msgId:int, status:Boolean) : void
{
DarkenManager.showLoadingSpiral(false);
ECardManager.onDeleteResponse([msgId],true);
}
private function onExtendingMembershipResponse(msgId:int, status:Boolean) : void
{
ECardManager.onDeleteResponse([msgId],true);
}
private function loadRedemptionImage(currCard:ECard) : void
{
var def:Object = null;
var mh:MediaHelper = null;
var denRoomDef:Object = null;
var mh1:MediaHelper = null;
var avt:Avatar = null;
if(currCard.type == ECard.TYPE_CLOTHING)
{
this._clothingIcon = new LayerBitmap();
this._clothingIconHelper = new SimpleIcon();
this._clothingIconHelper.init(this._clothingIcon,currCard.giftColor,currCard.giftId,1,true,false,this.clothingIconReceived);
}
else if(currCard.type == ECard.TYPE_DEN_ACC || currCard.type == ECard.TYPE_DEN_AUDIO)
{
def = DenXtCommManager.getDenItemDef(currCard.giftId);
if(!def)
{
return;
}
this._denIconHelper = new DenItemHelper();
this._denIconHelper.init(uint(currCard.giftId << 16 | DenItem.getIconId(def.sortCat)),this.denIconReceived,currCard.giftColor);
}
else if(currCard.type == ECard.TYPE_GEMS || currCard.type == ECard.TYPE_DIAMOND)
{
mh = new MediaHelper();
if(currCard.giftColor != 0)
{
mh.init(DIAMOND_ANIMAL_REDEEM_ID,this.onDiamondRedeemPopupLoaded,{
"diamondDef":currCard.giftColor,
"numDiamondsReceived":currCard.giftId
});
this._mediaViews.push(mh);
}
else
{
mh.init(currCard.type == ECard.TYPE_GEMS ? uint(GEMS_MEDIA_ID) : uint(DIAMOND_MEDIA_ID),this.onMediaHelperIconReceived,currCard.stampMediaId);
this._mediaViews.push(mh);
}
}
else if(currCard.type == ECard.TYPE_DEN_ROOM)
{
denRoomDef = gMainFrame.userInfo.getDenRoomDefByDefId(currCard.giftId);
if(!denRoomDef)
{
trace("Error loading image for denRoomDefId=" + currCard.giftId);
return;
}
mh1 = new MediaHelper();
mh1.init(denRoomDef.mediaId,this.onMediaHelperIconReceived);
this._mediaViews.push(mh1);
}
else if(currCard.type == ECard.TYPE_AVT)
{
avt = AvatarManager.getDefaultAvatarByDefId(currCard.giftId);
if(!avt)
{
trace("Error loading avatar using avDefId=" + currCard.giftId);
return;
}
this._avtView = new AvatarView();
this._avtView.init(avt);
this._avtView.playAnim(LayerAnim.AN_BBCARD,false,LayerAnim.PLAY_ONE_SHOT,this.avatarViewReceived);
}
else if(currCard.type == ECard.TYPE_PET)
{
++this._numPetsToCreate;
if(currCard.stampMediaId > 0)
{
GuiManager.openJumpPopup(true,this.onJumpPopupClose,null,currCard.giftId);
}
else
{
PetManager.openPetFinder(PetManager.petNameForDefId(currCard.giftId),this.keepPetCallback,true);
}
}
else if(currCard.type == ECard.TYPE_SUBSCRIPTION)
{
}
}
private function avatarViewReceived(la:LayerAnim, animId:int) : void
{
var img:Sprite = new Sprite();
img.addChild(this._avtView);
var offset:Point = BuddyCard.getAvOffsetByDefId(this._avtView.avTypeId);
this._avtView.x = offset.x;
this._avtView.y = offset.y;
this.setupGiftPopup(img);
}
private function clothingIconReceived() : void
{
var img:Sprite = new Sprite();
img.addChild(this._clothingIcon);
img.x = -img.width * 0.5;
img.y = -img.height * 0.5;
this.setupGiftPopup(img);
}
private function denIconReceived(helper:DenItemHelper) : void
{
var img:Sprite = null;
var scale:Number = NaN;
if(Boolean(helper) && Boolean(helper.displayObject))
{
img = new Sprite();
scale = DenItem.WIND_MED_SIZE / Math.max(helper.displayObject.width,helper.displayObject.height);
helper.displayObject.width *= scale;
helper.displayObject.height *= scale;
img.addChild(helper.displayObject);
img.x = -img.width * 0.5;
img.y = -img.height * 0.5;
this.setupGiftPopup(img);
}
}
private function onMediaHelperIconReceived(img:MovieClip) : void
{
if(img.passback > 0)
{
if(img.passback == 1)
{
GuiManager.openJumpPopup(false,this.onJumpPopupClose,img,this._numJumpGemsReceiving);
}
}
else
{
this.setupGiftPopup(img);
}
}
private function onJumpPopupClose(isJoey:Boolean, currGiftId:int, gemsImage:MovieClip = null) : void
{
if(isJoey)
{
PetManager.openPetFinder(PetManager.petNameForDefId(currGiftId),this.keepPetCallback,true);
}
else
{
this._redemptionList.splice(0,1);
this.keepGiftCallback();
}
}
private function popupCloseHandler(m:MouseEvent) : void
{
var popup:MovieClip = null;
if(Boolean(m))
{
m.stopPropagation();
}
if(Boolean(m.currentTarget.parent))
{
popup = m.currentTarget.root;
if(this._extendingMembershipJAGMsgId > 0)
{
ECardXtCommManager.sendECardAcceptDiscardGiftRequest(this._extendingMembershipJAGMsgId,false,this.onExtendingMembershipResponse);
this._extendingMembershipJAGMsgId = 0;
}
DarkenManager.unDarken(popup);
popup.visible = false;
popup = null;
this._imageBeingLoaded = false;
this.loadNextPopup();
}
}
private function popupMouseDownHandler(m:MouseEvent) : void
{
m.stopPropagation();
}
private function newMemberFeaturesBtn(m:MouseEvent) : void
{
m.stopPropagation();
SBTracker.push();
SBTracker.trackPageview("/game/play/popup/newMemberFeatures",-1,SBTracker.TYPE_EVENT);
m.currentTarget.parent.parent.p1.visible = false;
m.currentTarget.parent.parent.p2.visible = true;
}
private function newMemberBackBtn(m:MouseEvent) : void
{
m.stopPropagation();
SBTracker.pop();
m.currentTarget.parent.parent.p1.visible = true;
m.currentTarget.parent.parent.p2.visible = false;
}
private function onRenew(evt:MouseEvent) : void
{
evt.stopPropagation();
SBTracker.trackPageview("/game/play/popup/demotion/renew");
var url:String = gMainFrame.clientInfo.websiteURL + "membership";
var request:URLRequest = new URLRequest(url);
try
{
navigateToURL(request,"_blank");
}
catch(e:Error)
{
}
}
private function onSaveDiamonds(evt:MouseEvent) : void
{
evt.stopPropagation();
new SBOkPopup(this._popupLayer,LocalizationManager.translateIdAndInsertOnly(14802,this._diamondRedeemPopup.numDiamondsReceived),true,this.destroyDiamondRedeemPopup);
}
private function onRedeemDiamonds(evt:MouseEvent) : void
{
evt.stopPropagation();
AvatarSwitch.addAvatar(AvatarSwitch.avatars.length,false,this.onAvatarAdded,false,false,this._diamondRedeemPopup.diamondItem.refDefId,true,Item.DIAMOND_CURRENCY,this._diamondRedeemPopup.diamondItem.value,GenericListXtCommManager.REDEMPTION_STORE_LIST_ID,this._diamondRedeemPopup.diamondItem.defId);
}
private function onAvatarAdded(status:int) : void
{
if(status == 1)
{
this.destroyDiamondRedeemPopup();
}
else if(status == -1)
{
new SBOkPopup(this._popupLayer,LocalizationManager.translateIdAndInsertOnly(11382,this._diamondRedeemPopup.avatarName),true,this.destroyDiamondRedeemPopup);
}
else
{
new SBOkPopup(this._popupLayer,LocalizationManager.translateIdOnly(11225),true,this.destroyDiamondRedeemPopup);
}
}
}
}
@@ -0,0 +1,24 @@
package gui
{
public class SwitchManager
{
public static const NUM_DEN_ROOM_SLOTS:int = 20;
public static const NUM_AVATAR_SLOTS:int = 28;
public function SwitchManager()
{
super();
}
public function init() : void
{
}
public function destroy() : void
{
}
}
}
@@ -0,0 +1,12 @@
package gui
{
public class ToolTipBigPopup extends ToolTipPopup
{
public function ToolTipBigPopup()
{
super();
}
}
}
Loaded 100 of 7925 files, more files were not shown because too many files have changed in this diff. Show more