mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,407 @@
|
||||
package ecard
|
||||
{
|
||||
import den.DenItem;
|
||||
import den.DenXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.text.TextField;
|
||||
import gui.ECardInbox;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class ECard
|
||||
{
|
||||
|
||||
public static const TYPE_STANDARD:int = 0;
|
||||
|
||||
public static const TYPE_CLOTHING:int = 1;
|
||||
|
||||
public static const TYPE_BUDDY:int = 2;
|
||||
|
||||
public static const TYPE_DEN_ACC:int = 3;
|
||||
|
||||
public static const TYPE_GEMS:int = 4;
|
||||
|
||||
public static const TYPE_DEN_ROOM:int = 5;
|
||||
|
||||
public static const TYPE_AVT:int = 6;
|
||||
|
||||
public static const TYPE_SUBSCRIPTION:int = 7;
|
||||
|
||||
public static const TYPE_PET:int = 8;
|
||||
|
||||
public static const TYPE_DIAMOND:int = 9;
|
||||
|
||||
public static const TYPE_DEN_AUDIO:int = 99;
|
||||
|
||||
public static const MESSAGE_TYPE_BUBBLECHAT:int = 1;
|
||||
|
||||
public static const MESSAGE_TYPE_LIMITEDCHAT:int = 2;
|
||||
|
||||
public static const SENDER_USER:int = 0;
|
||||
|
||||
public static const SENDER_VOICE:int = 1;
|
||||
|
||||
public static const SENDER_REDEM:int = 2;
|
||||
|
||||
private var _msgId:int;
|
||||
|
||||
private var _senderUserName:String;
|
||||
|
||||
private var _cardMediaId:int;
|
||||
|
||||
private var _stampMediaId:int;
|
||||
|
||||
private var _isRead:Boolean;
|
||||
|
||||
private var _msg:String;
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _secondaryType:int;
|
||||
|
||||
private var _giftId:int;
|
||||
|
||||
private var _giftColor:uint;
|
||||
|
||||
private var _giftName:String;
|
||||
|
||||
private var _senderType:int;
|
||||
|
||||
private var _senderSGAccountType:int;
|
||||
|
||||
private var _senderNameBarData:int;
|
||||
|
||||
private var _userNameModerationFlag:int;
|
||||
|
||||
private var _cardImg:MovieClip;
|
||||
|
||||
private var _cardImgHelper:MediaHelper;
|
||||
|
||||
private var _stampImg:MovieClip;
|
||||
|
||||
private var _stampImgHelper:MediaHelper;
|
||||
|
||||
private var _acceptBtn:MovieClip;
|
||||
|
||||
private var _rejectBtn:MovieClip;
|
||||
|
||||
private var _memberNameBar:MovieClip;
|
||||
|
||||
private var _nonMemberNameBar:MovieClip;
|
||||
|
||||
private var _nonMemberUserName:TextField;
|
||||
|
||||
private var _charBox:MovieClip;
|
||||
|
||||
private var _buddyButtonsLoadedCallback:Function;
|
||||
|
||||
public function ECard()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(msgId:int, senderUserName:String, cardMediaId:int, stampMediaId:int, isRead:Boolean, msg:String, type:int, giftId:int, giftColor:uint, giftName:String, senderAcctType:int, senderNameBarData:int, secondaryType:int, senderType:int, userNameModerationFlag:int) : void
|
||||
{
|
||||
this._msgId = msgId;
|
||||
this._senderUserName = senderUserName;
|
||||
this._cardMediaId = cardMediaId;
|
||||
this._stampMediaId = stampMediaId;
|
||||
this._isRead = isRead;
|
||||
this._msg = msg;
|
||||
this._giftId = giftId;
|
||||
this._giftColor = giftColor;
|
||||
this._giftName = giftName;
|
||||
this._senderSGAccountType = senderAcctType;
|
||||
this._senderNameBarData = senderNameBarData;
|
||||
this._secondaryType = secondaryType;
|
||||
this._senderType = senderType;
|
||||
this._userNameModerationFlag = userNameModerationFlag;
|
||||
if(type == TYPE_DEN_ACC)
|
||||
{
|
||||
if(DenXtCommManager.getDenItemDef(this._giftId).sortCat == DenItem.SORT_AUDIO)
|
||||
{
|
||||
this._type = TYPE_DEN_AUDIO;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._type = type;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._type = type;
|
||||
}
|
||||
this._stampImg = new MovieClip();
|
||||
this._cardImg = new MovieClip();
|
||||
}
|
||||
|
||||
public function get msgId() : int
|
||||
{
|
||||
return this._msgId;
|
||||
}
|
||||
|
||||
public function get senderUserName() : String
|
||||
{
|
||||
return this._senderUserName;
|
||||
}
|
||||
|
||||
public function set senderUserName(value:String) : void
|
||||
{
|
||||
this._senderUserName = value;
|
||||
}
|
||||
|
||||
public function get senderModeratedUserName() : String
|
||||
{
|
||||
if(this._userNameModerationFlag > 0)
|
||||
{
|
||||
return this._senderUserName;
|
||||
}
|
||||
return LocalizationManager.translateIdOnly(LocalizationManager.NEW_JAMMER_USERNAME);
|
||||
}
|
||||
|
||||
public function get cardMediaId() : int
|
||||
{
|
||||
return this._cardMediaId;
|
||||
}
|
||||
|
||||
public function get stampMediaId() : int
|
||||
{
|
||||
return this._stampMediaId;
|
||||
}
|
||||
|
||||
public function get isRead() : Boolean
|
||||
{
|
||||
return this._isRead;
|
||||
}
|
||||
|
||||
public function set isRead(value:Boolean) : void
|
||||
{
|
||||
this._isRead = value;
|
||||
}
|
||||
|
||||
public function get msg() : String
|
||||
{
|
||||
return this._msg;
|
||||
}
|
||||
|
||||
public function set msg(newMsg:String) : void
|
||||
{
|
||||
this._msg = newMsg;
|
||||
}
|
||||
|
||||
public function get isBuddy() : Boolean
|
||||
{
|
||||
return this._type == TYPE_BUDDY;
|
||||
}
|
||||
|
||||
public function get isGift() : Boolean
|
||||
{
|
||||
return this._type == TYPE_CLOTHING || this._type >= TYPE_DEN_ACC;
|
||||
}
|
||||
|
||||
public function get giftId() : int
|
||||
{
|
||||
return this._giftId;
|
||||
}
|
||||
|
||||
public function get giftColor() : uint
|
||||
{
|
||||
return this._giftColor;
|
||||
}
|
||||
|
||||
public function get giftName() : String
|
||||
{
|
||||
return this._giftName;
|
||||
}
|
||||
|
||||
public function set giftName(value:String) : void
|
||||
{
|
||||
this._giftName = value;
|
||||
}
|
||||
|
||||
public function get isSenderMember() : Boolean
|
||||
{
|
||||
return this._senderSGAccountType >= Utility.PREMIUM_MEMBER;
|
||||
}
|
||||
|
||||
public function get isSenderArchived() : Boolean
|
||||
{
|
||||
return this._senderSGAccountType == Utility.ACCOUNT_TYPE_ARCHIVED;
|
||||
}
|
||||
|
||||
public function get senderSGAccountType() : int
|
||||
{
|
||||
return this._senderSGAccountType;
|
||||
}
|
||||
|
||||
public function get isFromUser() : Boolean
|
||||
{
|
||||
return this._senderType == SENDER_USER;
|
||||
}
|
||||
|
||||
public function get isFromVoice() : Boolean
|
||||
{
|
||||
return this._senderType == SENDER_VOICE;
|
||||
}
|
||||
|
||||
public function get isStartupJAG() : Boolean
|
||||
{
|
||||
return this._senderType == SENDER_REDEM || !gMainFrame.userInfo.isMember && this.isAJHQGift;
|
||||
}
|
||||
|
||||
public function get isRedemptionJAG() : Boolean
|
||||
{
|
||||
if(this.isStartupJAG && (this.giftId > 0 || this.type == ECard.TYPE_GEMS || this.type == ECard.TYPE_SUBSCRIPTION || this.type == ECard.TYPE_DIAMOND))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get isAJHQGift() : Boolean
|
||||
{
|
||||
return this.isFromVoice && this._giftId > 0;
|
||||
}
|
||||
|
||||
public function get type() : int
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public function set type(value:int) : void
|
||||
{
|
||||
this._type = value;
|
||||
}
|
||||
|
||||
public function get secondaryType() : int
|
||||
{
|
||||
return this._secondaryType;
|
||||
}
|
||||
|
||||
public function get nameBarData() : int
|
||||
{
|
||||
return this._senderNameBarData;
|
||||
}
|
||||
|
||||
public function set nameBarData(value:int) : void
|
||||
{
|
||||
this._senderNameBarData = value;
|
||||
}
|
||||
|
||||
public function get cardImg() : MovieClip
|
||||
{
|
||||
if(this._cardImg.numChildren == 0)
|
||||
{
|
||||
ECardInbox.loadingSpiral.visible = true;
|
||||
this._cardImgHelper = new MediaHelper();
|
||||
this._cardImgHelper.init(this._cardMediaId,this.cardImgReceived);
|
||||
}
|
||||
else if(Boolean(ECardInbox.loadingSpiral))
|
||||
{
|
||||
ECardInbox.loadingSpiral.visible = false;
|
||||
}
|
||||
return this._cardImg;
|
||||
}
|
||||
|
||||
public function get stampImg() : MovieClip
|
||||
{
|
||||
if(this._type != TYPE_BUDDY && !this.isFromVoice)
|
||||
{
|
||||
if(this._stampImg.numChildren == 0)
|
||||
{
|
||||
this._stampImgHelper = new MediaHelper();
|
||||
this._stampImgHelper.init(this._stampMediaId,this.stampImgReceived);
|
||||
}
|
||||
}
|
||||
return this._stampImg;
|
||||
}
|
||||
|
||||
public function get acceptBtn() : MovieClip
|
||||
{
|
||||
return this._acceptBtn;
|
||||
}
|
||||
|
||||
public function get rejectBtn() : MovieClip
|
||||
{
|
||||
return this._rejectBtn;
|
||||
}
|
||||
|
||||
public function get memberNameBar() : MovieClip
|
||||
{
|
||||
return this._memberNameBar;
|
||||
}
|
||||
|
||||
public function get nonMemberNameBar() : MovieClip
|
||||
{
|
||||
return this._nonMemberNameBar;
|
||||
}
|
||||
|
||||
public function get nonMemberUserName() : TextField
|
||||
{
|
||||
return this._nonMemberUserName;
|
||||
}
|
||||
|
||||
public function get charBox() : MovieClip
|
||||
{
|
||||
return this._charBox;
|
||||
}
|
||||
|
||||
public function setBuddyButtonsLoadedCallback(callback:Function) : void
|
||||
{
|
||||
if(this._type == TYPE_BUDDY)
|
||||
{
|
||||
this._buddyButtonsLoadedCallback = callback;
|
||||
}
|
||||
}
|
||||
|
||||
private function cardImgReceived(cardImg:MovieClip) : void
|
||||
{
|
||||
this._cardImg.addChild(cardImg);
|
||||
if(Boolean(cardImg.userNameTxt))
|
||||
{
|
||||
cardImg.userNameTxt.text = this._senderUserName;
|
||||
}
|
||||
if(this._type == TYPE_BUDDY)
|
||||
{
|
||||
if(Boolean(cardImg.okBtn))
|
||||
{
|
||||
this._acceptBtn = cardImg.okBtn;
|
||||
}
|
||||
if(Boolean(cardImg.cancelBtn))
|
||||
{
|
||||
this._rejectBtn = cardImg.cancelBtn;
|
||||
}
|
||||
if(Boolean(cardImg.member))
|
||||
{
|
||||
this._memberNameBar = cardImg.member;
|
||||
}
|
||||
if(Boolean(cardImg.nonmember))
|
||||
{
|
||||
this._nonMemberNameBar = cardImg.nonmember;
|
||||
}
|
||||
if(Boolean(cardImg.userName_txt))
|
||||
{
|
||||
this._nonMemberUserName = cardImg.userName_txt;
|
||||
}
|
||||
if(Boolean(cardImg.charBox))
|
||||
{
|
||||
this._charBox = cardImg.charBox;
|
||||
}
|
||||
if(this._buddyButtonsLoadedCallback != null)
|
||||
{
|
||||
this._buddyButtonsLoadedCallback();
|
||||
}
|
||||
}
|
||||
if(Boolean(ECardInbox.loadingSpiral))
|
||||
{
|
||||
ECardInbox.loadingSpiral.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function stampImgReceived(stampImg:MovieClip) : void
|
||||
{
|
||||
this._stampImg.addChild(stampImg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package ecard
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class ECardImageBase
|
||||
{
|
||||
|
||||
private var _mediaId:int;
|
||||
|
||||
private var _img:MovieClip;
|
||||
|
||||
private var _img2:MovieClip;
|
||||
|
||||
private var _imgHelper:MediaHelper;
|
||||
|
||||
private var _imgHelper2:MediaHelper;
|
||||
|
||||
private var _onImageLoadedCallback:Function;
|
||||
|
||||
public function ECardImageBase()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initMediaId:int, onImageLoadedCallback:Function = null) : void
|
||||
{
|
||||
this._mediaId = initMediaId;
|
||||
this._onImageLoadedCallback = onImageLoadedCallback;
|
||||
this._imgHelper = new MediaHelper();
|
||||
this._imgHelper.init(this._mediaId,this.imgReceived);
|
||||
this._imgHelper2 = new MediaHelper();
|
||||
this._imgHelper2.init(this._mediaId,this.img2Received);
|
||||
}
|
||||
|
||||
private function imgReceived(img:MovieClip) : void
|
||||
{
|
||||
this._img = img;
|
||||
this._imgHelper.destroy();
|
||||
this._imgHelper = null;
|
||||
if(Boolean(this._img2) && this._onImageLoadedCallback != null)
|
||||
{
|
||||
this._onImageLoadedCallback();
|
||||
this._onImageLoadedCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function img2Received(img2:MovieClip) : void
|
||||
{
|
||||
this._img2 = img2;
|
||||
this._imgHelper2.destroy();
|
||||
this._imgHelper2 = null;
|
||||
if(Boolean(this._img) && this._onImageLoadedCallback != null)
|
||||
{
|
||||
this._onImageLoadedCallback();
|
||||
this._onImageLoadedCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function get img() : MovieClip
|
||||
{
|
||||
return this._img;
|
||||
}
|
||||
|
||||
public function get img2() : MovieClip
|
||||
{
|
||||
return this._img2;
|
||||
}
|
||||
|
||||
public function get mediaId() : int
|
||||
{
|
||||
return this._mediaId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
package ecard
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
import gui.DarkenManager;
|
||||
import gui.ECardCreation;
|
||||
import gui.ECardInbox;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class ECardManager
|
||||
{
|
||||
|
||||
private static var _inbox:Array;
|
||||
|
||||
private static var _cardMediaIds:Array;
|
||||
|
||||
private static var _stampMediaIds:Array;
|
||||
|
||||
private static var _cardIdObjects:Array;
|
||||
|
||||
private static var _eCardInbox:ECardInbox;
|
||||
|
||||
private static var _eCardCreation:ECardCreation;
|
||||
|
||||
private static var _glowTimer:Timer;
|
||||
|
||||
private static var _hudECardBtn:MovieClip;
|
||||
|
||||
private static var _guiLayer:DisplayLayer;
|
||||
|
||||
private static var _eCardInboxAndCreation:MovieClip;
|
||||
|
||||
private static var _unreadCount:int;
|
||||
|
||||
private static var _isFirstTime:Boolean;
|
||||
|
||||
private static var _mediaHelper:MediaHelper;
|
||||
|
||||
private static const ECARD_INBOX_CREATION_MEDIA_ID:int = 1353;
|
||||
|
||||
public function ECardManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(initGuiLayer:DisplayLayer, initECardBtn:MovieClip, rebuild:Boolean = false) : void
|
||||
{
|
||||
_guiLayer = initGuiLayer;
|
||||
_hudECardBtn = initECardBtn;
|
||||
_hudECardBtn.glow.visible = false;
|
||||
_hudECardBtn.addEventListener(MouseEvent.MOUSE_DOWN,eCardBtnDownHandler,false,0,true);
|
||||
if(!rebuild)
|
||||
{
|
||||
_glowTimer = new Timer(5000);
|
||||
_glowTimer.addEventListener(TimerEvent.TIMER,glowTimerHandler,false,0,true);
|
||||
_inbox = new Array();
|
||||
_isFirstTime = true;
|
||||
_unreadCount = 0;
|
||||
_hudECardBtn.newEcardCount.visible = false;
|
||||
_hudECardBtn.newEcardCount.eCardCountTxt.text = "";
|
||||
ECardXtCommManager._deleteResponseCallback = onDeleteResponse;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hudECardBtn.newEcardCount.visible = _unreadCount > 0;
|
||||
_hudECardBtn.newEcardCount.eCardCountTxt.text = _unreadCount;
|
||||
}
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
ECardXtCommManager._deleteResponseCallback = null;
|
||||
}
|
||||
|
||||
public static function processECardList(paramList:Array, unreadECardsCount:int) : void
|
||||
{
|
||||
_inbox = paramList.concat();
|
||||
unreadCount = unreadECardsCount;
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
_eCardInbox.reloadInbox(_inbox);
|
||||
}
|
||||
}
|
||||
|
||||
public static function processECardPush(msg:ECard) : void
|
||||
{
|
||||
if(msg.isAJHQGift && !gMainFrame.userInfo.isMember)
|
||||
{
|
||||
return;
|
||||
}
|
||||
inbox.push(msg);
|
||||
if(!msg.isRead)
|
||||
{
|
||||
++unreadCount;
|
||||
}
|
||||
}
|
||||
|
||||
public static function processECardUpdate(msgId:int, newMsg:String) : void
|
||||
{
|
||||
var tempECard:ECard = null;
|
||||
for(var j:int = 0; j < _inbox.length; j++)
|
||||
{
|
||||
tempECard = _inbox[j];
|
||||
if(tempECard != null && tempECard.msgId == msgId)
|
||||
{
|
||||
tempECard.msg = newMsg;
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
_eCardInbox.reloadInbox(_inbox);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function get inbox() : Array
|
||||
{
|
||||
return _inbox;
|
||||
}
|
||||
|
||||
public static function onCardsLoaded(glId:int, mediaIds:Array, locStrs:Array) : void
|
||||
{
|
||||
_cardMediaIds = mediaIds;
|
||||
}
|
||||
|
||||
public static function onStampsLoaded(glId:int, mediaIds:Array, locStrs:Array) : void
|
||||
{
|
||||
_stampMediaIds = mediaIds;
|
||||
}
|
||||
|
||||
private static function eCardBtnDownHandler(evt:MouseEvent) : void
|
||||
{
|
||||
if(!evt.currentTarget.isGray)
|
||||
{
|
||||
if(!_eCardInboxAndCreation)
|
||||
{
|
||||
createInboxAndCreationPopup("inbox");
|
||||
}
|
||||
else
|
||||
{
|
||||
_eCardInbox = new ECardInbox();
|
||||
_eCardInbox.init(_guiLayer,_inbox,createCard,onECardInboxClose);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onECardInboxClose() : void
|
||||
{
|
||||
_hudECardBtn.downToUpState();
|
||||
if(Boolean(_eCardCreation))
|
||||
{
|
||||
_eCardCreation.destroy();
|
||||
_eCardCreation = null;
|
||||
}
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
_eCardInbox.destroy();
|
||||
_eCardInbox = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function eCardVisibility() : Boolean
|
||||
{
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
return _eCardInbox.visibility || _eCardCreation.visibility;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function closeECard() : void
|
||||
{
|
||||
onECardInboxClose();
|
||||
}
|
||||
|
||||
public static function createCard(toUserName:String, moderatedToUserName:String, currUserAccountType:int, backBtnEnabled:Boolean = true) : void
|
||||
{
|
||||
if(Boolean(_eCardCreation))
|
||||
{
|
||||
_eCardCreation.destroy();
|
||||
_eCardCreation = null;
|
||||
}
|
||||
else if(_eCardInboxAndCreation != null)
|
||||
{
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
_eCardInbox.showHide(true);
|
||||
}
|
||||
_eCardCreation = new ECardCreation();
|
||||
if(backBtnEnabled)
|
||||
{
|
||||
_eCardCreation.init(_guiLayer,toUserName,moderatedToUserName,currUserAccountType,_cardMediaIds,_stampMediaIds,onCreateCardBackBtn,onCreateCardClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eCardCreation.init(_guiLayer,toUserName,moderatedToUserName,currUserAccountType,_cardMediaIds,_stampMediaIds,onCreateCardBackBtn,onCreateCardClose,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
createInboxAndCreationPopup("create",{
|
||||
"toUserName":toUserName,
|
||||
"moderatedToUserName":moderatedToUserName,
|
||||
"toAccountType":currUserAccountType,
|
||||
"backBtnEnabled":backBtnEnabled
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static function createInboxAndCreationPopup(type:String, vars:Object = null) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(ECARD_INBOX_CREATION_MEDIA_ID,onMediaItemLoaded,{
|
||||
"type":type,
|
||||
"vars":vars
|
||||
});
|
||||
}
|
||||
|
||||
private static function onMediaItemLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(Boolean(img))
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_eCardInboxAndCreation = MovieClip(img.getChildAt(0));
|
||||
_eCardInboxAndCreation.x = MainFrame.VIEW_WIDTH * 0.5;
|
||||
_eCardInboxAndCreation.y = MainFrame.VIEW_HEIGHT * 0.5;
|
||||
_guiLayer.addChild(_eCardInboxAndCreation);
|
||||
DarkenManager.darken(_eCardInboxAndCreation);
|
||||
if(img.passback.type == "inbox")
|
||||
{
|
||||
_eCardInbox = new ECardInbox();
|
||||
_eCardInbox.init(_guiLayer,_inbox,createCard,onECardInboxClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eCardCreation = new ECardCreation();
|
||||
if(Boolean(img.passback.vars.backBtnEnabled))
|
||||
{
|
||||
_eCardCreation.init(_guiLayer,img.passback.vars.toUserName,img.passback.vars.moderatedToUserName,img.passback.vars.toAccountType,_cardMediaIds,_stampMediaIds,onCreateCardBackBtn,onCreateCardClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eCardCreation.init(_guiLayer,img.passback.vars.toUserName,img.passback.vars.moderatedToUserName,img.passback.vars.toAccountType,_cardMediaIds,_stampMediaIds,onCreateCardBackBtn,onCreateCardClose,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onCreateCardBackBtn(destroyInbox:Boolean) : void
|
||||
{
|
||||
if(Boolean(_eCardCreation))
|
||||
{
|
||||
_eCardCreation.destroy();
|
||||
_eCardCreation = null;
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
if(destroyInbox)
|
||||
{
|
||||
_hudECardBtn.downToUpState();
|
||||
_eCardInbox.destroy();
|
||||
_eCardInbox = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_eCardInbox.showHide(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onCreateCardClose() : void
|
||||
{
|
||||
if(Boolean(_eCardCreation))
|
||||
{
|
||||
_eCardCreation.destroy();
|
||||
_eCardCreation = null;
|
||||
}
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
_hudECardBtn.downToUpState();
|
||||
_eCardInbox.destroy();
|
||||
_eCardInbox = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function onDeleteResponse(msgIds:Array, status:Boolean) : void
|
||||
{
|
||||
var tempECard:ECard = null;
|
||||
var i:int = 0;
|
||||
var j:int = 0;
|
||||
var unreadCount:int = 0;
|
||||
var k:int = 0;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
_eCardInbox.onDeleteResponse(msgIds,status);
|
||||
}
|
||||
else if(status)
|
||||
{
|
||||
for(i = 0; i < msgIds.length; i++)
|
||||
{
|
||||
for(j = 0; j < _inbox.length; j++)
|
||||
{
|
||||
tempECard = _inbox[j];
|
||||
if(tempECard != null && tempECard.msgId == msgIds[i])
|
||||
{
|
||||
_inbox.splice(j,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(status)
|
||||
{
|
||||
for(k = 0; k < _inbox.length; k++)
|
||||
{
|
||||
tempECard = _inbox[k];
|
||||
if(Boolean(tempECard) && !tempECard.isRead)
|
||||
{
|
||||
unreadCount++;
|
||||
}
|
||||
}
|
||||
_unreadCount = unreadCount;
|
||||
if(_unreadCount > 0)
|
||||
{
|
||||
_hudECardBtn.newEcardCount.eCardCountTxt.text = _unreadCount;
|
||||
_hudECardBtn.newEcardCount.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hudECardBtn.newEcardCount.visible = false;
|
||||
_hudECardBtn.newEcardCount.eCardCountTxt.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function glowTimerHandler(te:TimerEvent) : void
|
||||
{
|
||||
_glowTimer.stop();
|
||||
if(Boolean(_hudECardBtn))
|
||||
{
|
||||
_hudECardBtn.glow.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function get unreadCount() : int
|
||||
{
|
||||
return _unreadCount;
|
||||
}
|
||||
|
||||
public static function set unreadCount(value:int) : void
|
||||
{
|
||||
if(value > _unreadCount)
|
||||
{
|
||||
if(_glowTimer.running)
|
||||
{
|
||||
_glowTimer.stop();
|
||||
}
|
||||
if(!_eCardCreation)
|
||||
{
|
||||
_glowTimer.start();
|
||||
if(Boolean(_hudECardBtn))
|
||||
{
|
||||
_hudECardBtn.glow.visible = true;
|
||||
}
|
||||
AJAudio.playMailReceivedSound();
|
||||
if(Boolean(_eCardInbox))
|
||||
{
|
||||
if(_inbox.length == 1)
|
||||
{
|
||||
_eCardInbox.reloadInbox(inbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eCardInbox.reloadInbox();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_unreadCount = value;
|
||||
if(Boolean(_hudECardBtn))
|
||||
{
|
||||
if(_unreadCount > 0)
|
||||
{
|
||||
_hudECardBtn.newEcardCount.eCardCountTxt.text = value;
|
||||
_hudECardBtn.newEcardCount.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hudECardBtn.newEcardCount.visible = false;
|
||||
_hudECardBtn.newEcardCount.eCardCountTxt.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function get eCardInboxAndCreation() : MovieClip
|
||||
{
|
||||
return _eCardInboxAndCreation;
|
||||
}
|
||||
|
||||
public static function get isFirstTime() : Boolean
|
||||
{
|
||||
return _isFirstTime;
|
||||
}
|
||||
|
||||
public static function set isFirstTime(value:Boolean) : void
|
||||
{
|
||||
_isFirstTime = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
package ecard
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import gui.BuddyManager;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.SafeChatManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class ECardXtCommManager
|
||||
{
|
||||
|
||||
private static var _requestCallback:Function;
|
||||
|
||||
private static var _readResponseCallback:Function;
|
||||
|
||||
private static var _sendResponseCallback:Function;
|
||||
|
||||
public static var _deleteResponseCallback:Function;
|
||||
|
||||
public static var _giftResponseCallback:Function;
|
||||
|
||||
private static var _jaggedPlayers:Object;
|
||||
|
||||
private static var NUM_JAGS_PER_NON_BUDDY_PER_SESSION:int = 5;
|
||||
|
||||
private static var NUM_JAGS_PER_BUDDY_PER_SESSION:int = 25;
|
||||
|
||||
public function ECardXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_jaggedPlayers = new Object();
|
||||
}
|
||||
|
||||
public static function sendECardListRequest(requestCallback:Function = null) : void
|
||||
{
|
||||
var includeRedemptions:int = 0;
|
||||
if(requestCallback != null)
|
||||
{
|
||||
includeRedemptions = 1;
|
||||
_requestCallback = requestCallback;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("el",[includeRedemptions]);
|
||||
}
|
||||
|
||||
public static function sendECardReadRequest(msgId:int, responseCallback:Function = null) : void
|
||||
{
|
||||
if(!gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_readResponseCallback = responseCallback;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("er",[msgId]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendECardSendRequest(toUserName:String, cardTypeId:int, stampTypeId:int, messageType:int, msg:String, type:int, giftItemIdx:int = -1, responseCallback:Function = null) : Boolean
|
||||
{
|
||||
if(_jaggedPlayers[toUserName] == null)
|
||||
{
|
||||
_jaggedPlayers[toUserName] = 0;
|
||||
}
|
||||
var limit:int = BuddyManager.isBuddy(toUserName) ? NUM_JAGS_PER_BUDDY_PER_SESSION : NUM_JAGS_PER_NON_BUDDY_PER_SESSION;
|
||||
if(_jaggedPlayers[toUserName] < limit)
|
||||
{
|
||||
++_jaggedPlayers[toUserName];
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_sendResponseCallback = responseCallback;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("es",[toUserName,cardTypeId,stampTypeId,messageType,msg,type,giftItemIdx]);
|
||||
return true;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14961,toUserName));
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function sendECardDeleteRequest(msgId:int, responseCallback:Function = null) : void
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_deleteResponseCallback = responseCallback;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("ed",[msgId]);
|
||||
}
|
||||
|
||||
public static function sendECardBuddyRequest(msgId:int, acceptBuddyRequest:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("eb",[msgId,acceptBuddyRequest ? 1 : 0]);
|
||||
}
|
||||
|
||||
public static function sendECardAcceptDiscardGiftRequest(msgId:int, acceptGift:Boolean, responseCallback:Function) : void
|
||||
{
|
||||
if(!gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_giftResponseCallback = responseCallback;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("eg",[msgId,acceptGift ? 1 : 0]);
|
||||
}
|
||||
else if(responseCallback != null)
|
||||
{
|
||||
responseCallback(0,true);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleXtReply(evt:SFEvent) : void
|
||||
{
|
||||
var data:Object = evt.obj;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
switch(data[0])
|
||||
{
|
||||
case "el":
|
||||
eCardListResponse(data);
|
||||
break;
|
||||
case "er":
|
||||
eCardReadResponse(data);
|
||||
break;
|
||||
case "ed":
|
||||
eCardDeleteResponse(data);
|
||||
break;
|
||||
case "es":
|
||||
eCardSendResponse(data);
|
||||
break;
|
||||
case "eg":
|
||||
eCardGiftResponse(data);
|
||||
break;
|
||||
case "eb":
|
||||
eCardBuddyResponse(data);
|
||||
break;
|
||||
case "ep":
|
||||
eCardPushHandler(data);
|
||||
break;
|
||||
case "eu":
|
||||
eCardUpdateHandler(data);
|
||||
break;
|
||||
default:
|
||||
throw new Error("ECardXtCommManager: Received illegal cmd: " + data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardListResponse(data:Object) : void
|
||||
{
|
||||
var eCard:ECard = null;
|
||||
var numECards:int = int(data[2]);
|
||||
var eCards:Array = new Array(numECards);
|
||||
if(numECards == -1)
|
||||
{
|
||||
numECards = 0;
|
||||
}
|
||||
var unreadCount:int = 0;
|
||||
var j:int = 3;
|
||||
for(var i:int = 0; i < numECards; i++)
|
||||
{
|
||||
eCard = new ECard();
|
||||
eCard.init(int(data[j++]),data[j++],int(data[j++]),int(data[j++]),data[j++] == "1",data[j++],int(data[j++]),int(data[j++]),uint(data[j++]),data[j++],int(data[j++]),int(data[j++]),int(data[j++]),int(data[j++]),int(data[j++]));
|
||||
if(Boolean(eCard.msg.match("(^[0-9]{1,2},[0-9]{1,2}$)|(^[0-9]{1,2}$)")))
|
||||
{
|
||||
eCard.msg = SafeChatManager.safeChatStringForCode(eCard.msg,SafeChatManager.TREE_ECARDTEXT);
|
||||
}
|
||||
if(eCard.type == ECard.TYPE_GEMS)
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdAndInsertOnly(eCard.giftName == "1" ? LocalizationManager.GEM_CAPITALIZED : LocalizationManager.GEMS_CAPITALIZED,Utility.convertNumberToString(int(eCard.giftName)));
|
||||
}
|
||||
else if(eCard.type == ECard.TYPE_DIAMOND)
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdAndInsertOnly(eCard.giftName == "1" ? LocalizationManager.DIAMOND_CAPITALIZED : LocalizationManager.DIAMONDS_CAPITALIZED,Utility.convertNumberToString(int(eCard.giftName)));
|
||||
}
|
||||
else if(eCard.type == ECard.TYPE_DEN_ROOM)
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdAndInsertOnly(15000,LocalizationManager.translateIdOnly(int(eCard.giftName)));
|
||||
}
|
||||
else
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdOnly(int(eCard.giftName));
|
||||
}
|
||||
if(eCard.isFromVoice)
|
||||
{
|
||||
eCard.senderUserName = LocalizationManager.translateIdOnly(int(eCard.senderUserName));
|
||||
}
|
||||
eCards[i] = eCard;
|
||||
if(!eCard.isRead && !(eCard.isAJHQGift && !gMainFrame.userInfo.isMember))
|
||||
{
|
||||
unreadCount++;
|
||||
}
|
||||
}
|
||||
ECardManager.processECardList(eCards,unreadCount);
|
||||
if(_requestCallback != null)
|
||||
{
|
||||
_requestCallback(eCards);
|
||||
_requestCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardReadResponse(data:Object) : void
|
||||
{
|
||||
if(_readResponseCallback != null)
|
||||
{
|
||||
_readResponseCallback(int(data[2]),data[3] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardDeleteResponse(data:Object) : void
|
||||
{
|
||||
var status:Boolean = data[2] == "1" ? true : false;
|
||||
var numDeleted:int = int(data[3]);
|
||||
var j:int = 4;
|
||||
var items:Array = new Array(numDeleted);
|
||||
for(var i:int = 0; i < numDeleted; i++)
|
||||
{
|
||||
items[i] = data[j++];
|
||||
}
|
||||
if(_deleteResponseCallback != null)
|
||||
{
|
||||
_deleteResponseCallback(items,status);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardSendResponse(data:Object) : void
|
||||
{
|
||||
var status:Boolean = data[2] == "1" ? true : false;
|
||||
if(_sendResponseCallback != null)
|
||||
{
|
||||
_sendResponseCallback(status);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardGiftResponse(data:Object) : void
|
||||
{
|
||||
if(_giftResponseCallback != null)
|
||||
{
|
||||
_giftResponseCallback(int(data[2]),data[3] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardBuddyResponse(data:Object) : void
|
||||
{
|
||||
if(data[2] == -1)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14692));
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardPushHandler(data:Object) : void
|
||||
{
|
||||
var eCard:ECard = new ECard();
|
||||
var j:int = 2;
|
||||
eCard.init(int(data[j++]),data[j++],int(data[j++]),int(data[j++]),data[j++] == "1",data[j++],int(data[j++]),int(data[j++]),uint(data[j++]),data[j++],int(data[j++]),int(data[j++]),int(data[j++]),int(data[j++]),int(data[j++]));
|
||||
if(Boolean(eCard.msg.match("(^[0-9]{1,2},[0-9]{1,2}$)|(^[0-9]{1,2}$)")))
|
||||
{
|
||||
eCard.msg = SafeChatManager.safeChatStringForCode(eCard.msg,SafeChatManager.TREE_ECARDTEXT);
|
||||
}
|
||||
if(eCard.type == ECard.TYPE_GEMS)
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdAndInsertOnly(eCard.giftName == "1" ? LocalizationManager.GEM_CAPITALIZED : LocalizationManager.GEMS_CAPITALIZED,Utility.convertNumberToString(int(eCard.giftName)));
|
||||
}
|
||||
else if(eCard.type == ECard.TYPE_DIAMOND)
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdAndInsertOnly(eCard.giftName == "1" ? LocalizationManager.DIAMOND_CAPITALIZED : LocalizationManager.DIAMONDS_CAPITALIZED,Utility.convertNumberToString(int(eCard.giftName)));
|
||||
}
|
||||
else if(eCard.type == ECard.TYPE_DEN_ROOM)
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdAndInsertOnly(15000,LocalizationManager.translateIdOnly(int(eCard.giftName)));
|
||||
}
|
||||
else
|
||||
{
|
||||
eCard.giftName = LocalizationManager.translateIdOnly(int(eCard.giftName));
|
||||
}
|
||||
if(eCard.isFromVoice)
|
||||
{
|
||||
eCard.senderUserName = LocalizationManager.translateIdOnly(int(eCard.senderUserName));
|
||||
}
|
||||
ECardManager.processECardPush(eCard);
|
||||
}
|
||||
|
||||
private static function eCardUpdateHandler(data:Object) : void
|
||||
{
|
||||
ECardManager.processECardUpdate(data[2],data[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user