diff --git a/swf-src/AJClient.as b/swf-src/AJClient.as index 03eb0f0..d4fb25d 100644 --- a/swf-src/AJClient.as +++ b/swf-src/AJClient.as @@ -15,6 +15,9 @@ package import com.sbi.popup.SBStandardPopup; import com.sbi.popup.SBYesNoPopup; import createAccountFlow.CreateAccount; + import flash.display.Bitmap; + import flash.display.BitmapData; + import flash.display.Loader; import flash.display.MovieClip; import flash.display.Shape; import flash.display.DisplayObject; @@ -22,10 +25,13 @@ package import flash.events.Event; import flash.geom.ColorTransform; import flash.geom.Matrix; + import flash.utils.ByteArray; import flash.geom.Point; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.events.TimerEvent; + import flash.net.FileFilter; + import flash.net.FileReference; import flash.net.URLLoader; import flash.net.URLRequest; import flash.text.Font; @@ -34,6 +40,7 @@ package import flash.events.UncaughtErrorEvent; import flash.external.ExternalInterface; import flash.system.Capabilities; + import flash.system.LoaderContext; import flash.system.Security; import flash.system.System; import flash.ui.Mouse; @@ -44,6 +51,8 @@ package import gamePlayFlow.GamePlay; import gskinner.motion.GTween; import gui.DarkenManager; + import gui.ChatBalloon; + import gui.EmoticonUtility; import gui.GuiManager; import loadProgress.LoadProgress; import loader.DefPacksDefHelper; @@ -96,13 +105,17 @@ package // signed-in role may do ("xsp" from the server; empty for players). private var _moderate:Sprite; - private var _moderateContent:MovieClip; + private var _moderateContent:Sprite; + + private var _moderateTitle:TextField; private var _moderateName:String; private var _moderateReason:int; - private var _moderateMessageBar:MovieClip; + private var _moderateInput:TextField; + + private var _moderateHint:TextField; private var _moderateButtons:Array; @@ -305,6 +318,7 @@ package } gMainFrame.stage.addEventListener("keyDown",onFinderKey,true,1000); gMainFrame.stage.addEventListener("keyDown",onFinderKey,false,1000); + startEmojiButton(); } public static function openTool(param1:int) : void @@ -319,6 +333,10 @@ package { _toolsInstance.showChatFilter(true); } + else if(param1 == 2) + { + _toolsInstance.showItemMaker(true); + } else { _toolsInstance.showItemFinder(true); @@ -519,6 +537,20 @@ package try { var _loc2_:Array = JSON.parse(String(param1[3])) as Array; + for each(var _loc3_:Object in _loc2_) + { + // a picture of its own (uploaded by its maker): its version + if(_loc3_.art) + { + _customArt[String(param1[2]) + ":" + _loc3_.id] = String(_loc3_.art); + _customArtMode[String(param1[2]) + ":" + _loc3_.id] = _loc3_.artMode == "texture" ? "texture" : "sticker"; + } + else + { + delete _customArt[String(param1[2]) + ":" + _loc3_.id]; + delete _customArtMode[String(param1[2]) + ":" + _loc3_.id]; + } + } if(String(param1[2]) == "den") { DenXtCommManager.addDenItemDefs(_loc2_); @@ -534,6 +566,238 @@ package } } + // custom items' own pictures (lib/itemart.js on the server): "kind:id" + // -> version, from the def rows ("xdi"). the picture stands in for the + // item's icon, and for a den item also for the item placed in a den. + private static var _customArt:Object = {}; + + // how a custom clothing item with a picture is worn ("artMode" in its + // def row): "sticker", the picture itself where the item would be, or + // "texture", the item's own shape painted with the picture. + private static var _customArtMode:Object = {}; + + // the pictures as bitmaps, for wearing: "kind:id" -> {bmp, art, waiting} + private static var _artBitmaps:Object = {}; + + // the look a worn item has, or null for one drawn as the game draws it + public static function customArtMode(param1:String, param2:int) : String + { + return _customArt[param1 + ":" + param2] == null ? null : _customArtMode[param1 + ":" + param2]; + } + + // what makes a painted frame of it different from its base's, for a + // cache key ("" for none) + public static function customArtKey(param1:String, param2:int) : String + { + var _loc3_:String = _customArt[param1 + ":" + param2]; + return _loc3_ == null ? "" : param2 + ":" + _loc3_ + ":" + _customArtMode[param1 + ":" + param2]; + } + + // the picture as a bitmap, or null while it loads (then `param3`, an + // object with invalidate(), is told when it has: it paints again). + public static function customArtBitmap(param1:String, param2:int, param3:Object = null) : BitmapData + { + var _loc4_:String = param1 + ":" + param2; + var _loc5_:String = _customArt[_loc4_]; + var _loc6_:Object = _artBitmaps[_loc4_]; + if(_loc5_ == null) + { + return null; + } + if(_loc6_ != null && _loc6_.art == _loc5_) + { + if(_loc6_.bmp == null && param3 != null && _loc6_.waiting.indexOf(param3) == -1) + { + _loc6_.waiting.push(param3); + } + return _loc6_.bmp; + } + _loc6_ = _artBitmaps[_loc4_] = {"bmp":null,"art":_loc5_,"waiting":param3 != null ? [param3] : []}; + var _loc7_:Loader = new Loader(); + var _loc8_:Object = _loc6_; + _loc7_.contentLoaderInfo.addEventListener("complete",function(param1:Event):void + { + if(_loc7_.content is Bitmap) + { + _loc8_.bmp = Bitmap(_loc7_.content).bitmapData; + } + for each(var _loc2_:Object in _loc8_.waiting) + { + try + { + if("artArrived" in _loc2_) + { + _loc2_.artArrived(); + } + else + { + _loc2_.invalidate(); + } + } + catch(e:Error) + { + } + } + _loc8_.waiting = []; + }); + _loc7_.contentLoaderInfo.addEventListener("ioError",function(param1:Event):void + { + _loc8_.waiting = []; + }); + // its pixels are read (worn as a sticker or a texture): from another + // address that takes the server's /crossdomain.xml + _loc7_.load(new URLRequest(customArtUrl(param1,param2)),new LoaderContext(true)); + return null; + } + + // the picture's address, or null when the item has none. + public static function customArtUrl(param1:String, param2:int) : String + { + var _loc3_:String = _customArt[param1 + ":" + param2]; + return _loc3_ == null ? null : gMainFrame.clientInfo.websiteURL + "itemart/" + param1 + "/" + param2 + ".png?v=" + encodeURIComponent(_loc3_); + } + + // loads a picture into `param2`, fitted in a `param3` square: centred on + // its origin, or (`param4`) standing on it, as a den item does. then + // `param5`, if any. a picture that does not load leaves it empty. + // pictures loadArt has loaded, by address, drawn again from these + // rather than fetched and decoded again: emoji in chat bubbles, items' + // icons in long lists. those asked for while one loads wait for it. + // past ART_CACHE_MAX pictures it starts afresh (a picture shown keeps + // its own). + private static const ART_CACHE_MAX:int = 400; + + private static var _artCache:Object = {}; + + private static var _artCacheCount:int = 0; + + private static var _artLoading:Object = {}; + + public static function loadArt(param1:String, param2:Sprite, param3:int, param4:Boolean, param5:Function = null) : void + { + var url:String = param1; + var place:Function = function(param1:BitmapData):void + { + var _loc2_:Bitmap = null; + var _loc3_:Number = NaN; + if(param1 != null) + { + _loc2_ = new Bitmap(param1,"auto",true); + _loc3_ = Math.min(1,param3 / Math.max(1,param1.width),param3 / Math.max(1,param1.height)); + _loc2_.scaleX = _loc2_.scaleY = _loc3_; + _loc2_.x = -int(param1.width * _loc3_ * 0.5); + _loc2_.y = param4 ? -int(param1.height * _loc3_) : -int(param1.height * _loc3_ * 0.5); + param2.addChild(_loc2_); + } + if(param5 != null) + { + param5(); + } + }; + if(_artCache[url] != null) + { + place(_artCache[url]); + return; + } + if(_artLoading[url] != null) + { + _artLoading[url].push({"place":place,"sprite":param2,"side":param3,"standing":param4,"then":param5}); + return; + } + _artLoading[url] = []; + var shared:Loader = new Loader(); + var loaded:Function = function(param1:Event):void + { + var _loc2_:BitmapData = null; + var _loc3_:Array = _artLoading[url]; + shared.contentLoaderInfo.removeEventListener("complete",loaded); + shared.contentLoaderInfo.removeEventListener("ioError",notLoaded); + delete _artLoading[url]; + try + { + _loc2_ = shared.content is Bitmap ? Bitmap(shared.content).bitmapData : null; + } + catch(e:Error) + { + _loc2_ = null; + } + if(_loc2_ == null) + { + // not to be shared (another site's, without its leave): each + // has a loader of its own, as before + loadArtUncached(url,param2,param3,param4,param5); + for each(var _loc4_:Object in _loc3_) + { + loadArtUncached(url,_loc4_.sprite,_loc4_.side,_loc4_.standing,_loc4_.then); + } + return; + } + if(_artCacheCount >= ART_CACHE_MAX) + { + _artCache = {}; + _artCacheCount = 0; + } + _artCache[url] = _loc2_; + _artCacheCount++; + place(_loc2_); + for each(var _loc5_:Object in _loc3_) + { + _loc5_.place(_loc2_); + } + }; + var notLoaded:Function = function(param1:Event):void + { + var _loc2_:Array = _artLoading[url]; + shared.contentLoaderInfo.removeEventListener("complete",loaded); + shared.contentLoaderInfo.removeEventListener("ioError",notLoaded); + delete _artLoading[url]; + place(null); + for each(var _loc3_:Object in _loc2_) + { + _loc3_.place(null); + } + }; + shared.contentLoaderInfo.addEventListener("complete",loaded); + shared.contentLoaderInfo.addEventListener("ioError",notLoaded); + shared.load(new URLRequest(url),new LoaderContext(true)); + } + + private static function loadArtUncached(param1:String, param2:Sprite, param3:int, param4:Boolean, param5:Function = null) : void + { + var _loc6_:Loader = new Loader(); + var done:Function = function(param1:Event):void + { + var _loc2_:Number = NaN; + _loc6_.contentLoaderInfo.removeEventListener("complete",done); + _loc6_.contentLoaderInfo.removeEventListener("ioError",failed); + if(_loc6_.content is Bitmap) + { + Bitmap(_loc6_.content).smoothing = true; + } + _loc2_ = Math.min(1,param3 / Math.max(1,_loc6_.contentLoaderInfo.width),param3 / Math.max(1,_loc6_.contentLoaderInfo.height)); + _loc6_.scaleX = _loc6_.scaleY = _loc2_; + _loc6_.x = -int(_loc6_.contentLoaderInfo.width * _loc2_ * 0.5); + _loc6_.y = param4 ? -int(_loc6_.contentLoaderInfo.height * _loc2_) : -int(_loc6_.contentLoaderInfo.height * _loc2_ * 0.5); + param2.addChild(_loc6_); + if(param5 != null) + { + param5(); + } + }; + var failed:Function = function(param1:Event):void + { + _loc6_.contentLoaderInfo.removeEventListener("complete",done); + _loc6_.contentLoaderInfo.removeEventListener("ioError",failed); + if(param5 != null) + { + param5(); + } + }; + _loc6_.contentLoaderInfo.addEventListener("complete",done); + _loc6_.contentLoaderInfo.addEventListener("ioError",failed); + _loc6_.load(new URLRequest(param1)); + } + // "xsp": [.., .., role, permissions]. sent at login to staff only: their // role and what it allows, comma separated (the server's lib/roles.js). public static function onStaff(param1:Object) : void @@ -575,6 +839,98 @@ package new SBOkPopup(GuiManager.guiLayer,String(param1[2])); } + // "xgt": [.., .., x, y, same room]: staff moving a player (summon, + // goto) puts them on that spot: now when in the room already ("1"), + // else on spawning in the room they are sent to next ("0"). with no + // spot, the one kept is forgotten (the move failed). + public static function onStaffGoto(param1:Object) : void + { + var _loc2_:RoomManagerWorld = RoomManagerWorld.instance; + if(_loc2_ == null) + { + return; + } + if(param1.length < 5) + { + _loc2_.setGotoSpawnPoint("default"); + return; + } + if(String(param1[4]) == "1") + { + _loc2_.teleportPlayer(int(param1[2]),int(param1[3]),true); + } + else + { + _loc2_.setGotoSpawnLocation(int(param1[2]),int(param1[3])); + } + } + + // whether this player is invisible staff (lib/world.js setInvisible), + // for the staff window's button. + public static var staffInvisible:Boolean = false; + + // "xiv": [.., .., sfsId, 1 | 0]: an animal of invisible staff, which + // only staff are shown, drawn half see-through (this player's own too). + public static function onInvisible(param1:Object) : void + { + var _loc2_:int = int(param1[2]); + var _loc3_:Boolean = String(param1[3]) == "1"; + var _loc4_:AvatarWorldView = AvatarManager.avatarViewList != null ? AvatarManager.avatarViewList[_loc2_] as AvatarWorldView : null; + if(_loc2_ == AvatarManager.playerSfsUserId) + { + staffInvisible = _loc3_; + } + if(_loc4_ != null) + { + _loc4_.alpha = _loc3_ ? 0.5 : 1; + } + } + + // typing (lib/world.js xty): this player's chat box says so as it + // changes (gui.ChatHistory), again every TYPING_RESEND ms while it goes + // on, and once when it is emptied; a line sent counts as stopping. + private static const TYPING_RESEND:int = 4000; + + private static var _typingSent:Boolean = false; + + private static var _typingSentAt:int = 0; + + public static function noteTyping(param1:String) : void + { + var _loc2_:Boolean = param1 != null && param1.replace(/\s+/g,"").length > 0; + if(gMainFrame.clientInfo.invisMode || staffInvisible) + { + return; + } + if(_loc2_ && (!_typingSent || getTimer() - _typingSentAt > TYPING_RESEND)) + { + gMainFrame.server.setXtObject_Str("xty",[1]); + _typingSent = true; + _typingSentAt = getTimer(); + } + else if(!_loc2_ && _typingSent) + { + gMainFrame.server.setXtObject_Str("xty",[0]); + _typingSent = false; + } + } + + // a line was sent: every other game drops the "..." when it arrives. + public static function typingSent() : void + { + _typingSent = false; + } + + // "xty": [.., .., sfsId, 1 | 0]: another player typing, or not. + public static function onTyping(param1:Object) : void + { + var _loc2_:AvatarWorldView = AvatarManager.avatarViewList != null ? AvatarManager.avatarViewList[int(param1[2])] as AvatarWorldView : null; + if(_loc2_ != null && int(param1[2]) != AvatarManager.playerSfsUserId) + { + _loc2_.setTyping(String(param1[3]) == "1"); + } + } + // "xyn": [.., .., id, text]. A yes-or-no box; the answer goes back as // "xyn" [id, 1 | 0]. public static function askYesNo(param1:Object) : void @@ -2037,58 +2393,214 @@ package // which the server runs as if typed: lib/commands.js, its permission // checks and log included); only the ones the role allows are shown. // the window closes and the server's answer comes as a message box. + // a warning's reason, as the server knows it, and its chip. with text + // in the box, Warn sends that text as the warning ("custom": what the + // player is shown) and the reason is not used. private static const MODERATE_REASONS:Array = ["behavior","bullying","personal","scamming"]; - private static const MODERATE_REASON_NAMES:Array = ["Inappropriate behavior","Bullying","Personal information","Scamming"]; + private static const MODERATE_REASON_NAMES:Array = ["Behavior","Bullying","Personal info","Scamming"]; + + // the window's look: flat, dark, rounded, in the game's font. + private static const MOD_W:int = 560; + + private static const MOD_H:int = 432; + + private static const MOD_PAD:int = 24; + + private static const MOD_BG:uint = 0x1C1D24; + + private static const MOD_EDGE:uint = 0x34364A; + + private static const MOD_FIELD:uint = 0x272934; + + private static const MOD_MUTED:uint = 0x9A9DB0; + + private static const MOD_GREY:uint = 0x3A3D4E; + + private static const MOD_AMBER:uint = 0xE0A030; + + private static const MOD_BLUE:uint = 0x3D7BF0; + + private static const MOD_PURPLE:uint = 0x8B5CF6; + + private static const MOD_TEAL:uint = 0x14A38B; + + private static const MOD_RED:uint = 0xE0475B; + + // text in the game's font (embedded when the game has it). + public static function modText(param1:String, param2:int, param3:uint, param4:Boolean = true) : TextField + { + var _loc5_:TextField = new TextField(); + _loc5_.embedFonts = hasGameFont(); + _loc5_.selectable = false; + _loc5_.mouseEnabled = false; + _loc5_.autoSize = "left"; + _loc5_.defaultTextFormat = new TextFormat("CCDigitalDelivery",param2,param3,param4); + _loc5_.text = param1; + return _loc5_; + } + + // a flat button: a rounded box of colour `param6`, its label centred. + private function modButton(param1:String, param2:String, param3:Number, param4:Number, param5:Number, param6:uint, param7:String) : Sprite + { + var _loc8_:Sprite = new Sprite(); + _loc8_.name = param1; + _loc8_.x = param3; + _loc8_.y = param4; + _loc8_.buttonMode = true; + _loc8_.useHandCursor = true; + _loc8_.mouseChildren = false; + var _loc9_:TextField = modText(param2,14,0xFFFFFF); + _loc9_.name = "label"; + _loc8_.addChild(_loc9_); + paintFlatButton(_loc8_,param5,param6); + _loc8_.addEventListener("mouseDown",onModerateButton); + _loc8_.addEventListener("mouseOver",onFlatHover); + _loc8_.addEventListener("mouseOut",onFlatHover); + _moderateContent.addChild(_loc8_); + _moderateButtons.push({ + "clip":_loc8_, + "permission":param7 + }); + return _loc8_; + } + + // draws a flat button `param2` wide in colour `param3`, its label + // ("label") centred in it. also for the settings menu's own windows. + public static function paintFlatButton(param1:Sprite, param2:Number, param3:uint) : void + { + var _loc4_:TextField = param1.getChildByName("label") as TextField; + param1.graphics.clear(); + param1.graphics.beginFill(param3); + param1.graphics.drawRoundRect(0,0,param2,34,14,14); + param1.graphics.endFill(); + if(_loc4_ != null) + { + _loc4_.x = int((param2 - _loc4_.width) * 0.5); + _loc4_.y = int((34 - _loc4_.height) * 0.5); + } + } + + private static function modSetLabel(param1:Sprite, param2:String) : void + { + var _loc3_:TextField = param1.getChildByName("label") as TextField; + var _loc4_:Number = param1.width; + _loc3_.text = param2; + _loc3_.x = int((_loc4_ - _loc3_.width) * 0.5); + } + + public static function onFlatHover(param1:MouseEvent) : void + { + Sprite(param1.currentTarget).alpha = param1.type == "mouseOver" ? 0.82 : 1; + } + + private function modSection(param1:String, param2:Number) : void + { + var _loc3_:TextField = modText(param1.toUpperCase(),11,MOD_MUTED); + _loc3_.x = MOD_PAD; + _loc3_.y = param2; + _moderateContent.addChild(_loc3_); + } private function buildModerate() : void { - var _loc1_:MovieClip = GETDEFINITIONBYNAME("ReportRulesPopupSkin"); - var _loc2_:int = 1; + var _loc1_:Number = (MOD_W - MOD_PAD * 2 - 20) / 3; // a column's width + var _loc2_:Array = [MOD_PAD,MOD_PAD + _loc1_ + 10,MOD_PAD + (_loc1_ + 10) * 2]; + var _loc3_:Sprite = null; + var _loc4_:Number = MOD_PAD; + var _loc5_:int = 0; _moderate = new Sprite(); - _moderate.graphics.beginFill(0,0.45); + _moderate.graphics.beginFill(0,0.55); _moderate.graphics.drawRect(0,0,900,550); _moderate.graphics.endFill(); - var _loc3_:Sprite = new Sprite(); - _loc3_.x = 450; - _loc3_.y = 275; - _moderate.addChild(_loc3_); - _loc3_.addChild(_loc1_); - _moderateContent = GETDEFINITIONBYNAME("ReportRulesPopupContent"); - _moderateContent.x = _loc1_.c.x; - _moderateContent.y = _loc1_.c.y; - _loc3_.addChild(_moderateContent); - _loc1_.bx.addEventListener("mouseDown",onModerateCloseClick); - while(_loc2_ <= 5) - { - _moderateContent["ruleTxt" + _loc2_].visible = false; - _moderateContent["ruleBodyTxt" + _loc2_].visible = false; - _loc2_++; - } - var _loc4_:TextField = _moderateContent.ruleBodyTxt1; - _loc4_.visible = true; - _loc4_.wordWrap = true; - _loc4_.x = -245; - _loc4_.y = -150; - _loc4_.width = 490; - _loc4_.height = 40; - _loc4_.text = "What you do here is written down under your name, as in the moderator panel."; + _moderateContent = new Sprite(); + _moderateContent.x = int((900 - MOD_W) * 0.5); + _moderateContent.y = int((550 - MOD_H) * 0.5); + // a soft shadow, then the panel + _moderateContent.graphics.beginFill(0,0.35); + _moderateContent.graphics.drawRoundRect(0,6,MOD_W,MOD_H,26,26); + _moderateContent.graphics.endFill(); + _moderateContent.graphics.lineStyle(1,MOD_EDGE); + _moderateContent.graphics.beginFill(MOD_BG); + _moderateContent.graphics.drawRoundRect(0,0,MOD_W,MOD_H,26,26); + _moderateContent.graphics.endFill(); + _moderate.addChild(_moderateContent); _moderateButtons = []; - // a row each: warn (the reason cycles), a message, chat, moving them. - moderateButton("reason","",-150,-88,"player.warn"); - moderateButton("warn","Warn",90,-88,"player.warn"); - _moderateMessageBar = finderSearchBar(-247,-56,330,"Message to show them",null,200,false); - _moderateContent.addChild(_moderateMessageBar); - moderateButton("message","Send",150,-52,"player.warn"); - moderateButton("silence 1","Silence 1 hour",-160,12,"chat.silence"); - moderateButton("silence 24","Silence 1 day",0,12,"chat.silence"); - moderateButton("silence off","Lift silence",160,12,"chat.silence"); - moderateButton("summon","Bring here",-160,72,"player.summon"); - moderateButton("goto","Go to them",0,72,"player.goto"); - moderateButton("kick","Disconnect",160,72,"player.kick"); - // their warnings, and taking back the latest (one given by mistake) - moderateButton("warnings","Warnings",-80,132,"player.warn"); - moderateButton("unwarn","Take back warning",80,132,"player.warn"); + _moderateTitle = modText("",22,0xFFFFFF); + _moderateTitle.x = MOD_PAD; + _moderateTitle.y = 18; + _moderateContent.addChild(_moderateTitle); + var _loc6_:TextField = modText("Everything here is logged under your name.",12,MOD_MUTED,false); + _loc6_.x = MOD_PAD; + _loc6_.y = 50; + _moderateContent.addChild(_loc6_); + // the close button: a round grey X + _loc3_ = new Sprite(); + _loc3_.name = "close"; + _loc3_.buttonMode = true; + _loc3_.useHandCursor = true; + _loc3_.graphics.beginFill(MOD_GREY); + _loc3_.graphics.drawCircle(0,0,15); + _loc3_.graphics.endFill(); + _loc3_.graphics.lineStyle(2.5,0xFFFFFF); + _loc3_.graphics.moveTo(-5,-5); + _loc3_.graphics.lineTo(5,5); + _loc3_.graphics.moveTo(5,-5); + _loc3_.graphics.lineTo(-5,5); + _loc3_.x = MOD_W - MOD_PAD - 6; + _loc3_.y = 32; + _loc3_.addEventListener("mouseDown",onModerateCloseClick); + _loc3_.addEventListener("mouseOver",onFlatHover); + _loc3_.addEventListener("mouseOut",onFlatHover); + _moderateContent.addChild(_loc3_); + // warn: a chip for each reason, and Warn + modSection("Warn",84); + _loc5_ = 0; + while(_loc5_ < MODERATE_REASONS.length) + { + _loc3_ = modButton("reason" + _loc5_,MODERATE_REASON_NAMES[_loc5_],_loc4_,102,_loc5_ == 2 ? 104 : 82,MOD_GREY,"player.warn"); + _loc4_ += _loc3_.width + 8; + _loc5_++; + } + modButton("warn","Warn",_loc2_[2] + _loc1_ - 120,102,120,MOD_AMBER,"player.warn"); + // the text: a message, or the warning in the staff member's words + modSection("Message, or your own warning",150); + var _loc7_:Sprite = new Sprite(); + _loc7_.x = MOD_PAD; + _loc7_.y = 168; + _loc7_.graphics.lineStyle(1,MOD_EDGE); + _loc7_.graphics.beginFill(MOD_FIELD); + _loc7_.graphics.drawRoundRect(0,0,_loc2_[2] - MOD_PAD - 10,34,14,14); + _loc7_.graphics.endFill(); + _moderateContent.addChild(_loc7_); + _moderateHint = modText("Type here, then Send it or press Warn",13,0x6E7187,false); + _moderateHint.x = 12; + _moderateHint.y = int((34 - _moderateHint.height) * 0.5); + _loc7_.addChild(_moderateHint); + _moderateInput = new TextField(); + _moderateInput.embedFonts = hasGameFont(); + _moderateInput.type = "input"; + _moderateInput.defaultTextFormat = new TextFormat("CCDigitalDelivery",14,0xFFFFFF,false); + _moderateInput.maxChars = 200; + _moderateInput.x = 10; + _moderateInput.y = 7; + _moderateInput.width = _loc2_[2] - MOD_PAD - 30; + _moderateInput.height = 22; + _moderateInput.addEventListener("change",onModerateTyped); + _loc7_.addChild(_moderateInput); + modButton("message","Send",_loc2_[2],168,_loc1_,MOD_BLUE,"player.warn"); + modSection("Chat",218); + modButton("silence 1","Silence 1 hour",_loc2_[0],236,_loc1_,MOD_PURPLE,"chat.silence"); + modButton("silence 24","Silence 1 day",_loc2_[1],236,_loc1_,MOD_PURPLE,"chat.silence"); + modButton("silence off","Lift silence",_loc2_[2],236,_loc1_,MOD_GREY,"chat.silence"); + modSection("Move",286); + modButton("summon","Bring here",_loc2_[0],304,_loc1_,MOD_TEAL,"player.summon"); + modButton("goto","Go to them",_loc2_[1],304,_loc1_,MOD_TEAL,"player.goto"); + modButton("kick","Disconnect",_loc2_[2],304,_loc1_,MOD_RED,"player.kick"); + modSection("Record, and you",354); + modButton("warnings","Warnings",_loc2_[0],372,_loc1_,MOD_GREY,"player.warn"); + modButton("unwarn","Undo warning",_loc2_[1],372,_loc1_,MOD_GREY,"player.warn"); + modButton("invisible","Go invisible",_loc2_[2],372,_loc1_,MOD_GREY,"staff.invisible"); _moderate.addEventListener("mouseDown",onFinderMouse); _moderate.addEventListener("mouseUp",onFinderMouse); _moderate.addEventListener("click",onFinderMouse); @@ -2097,19 +2609,10 @@ package addChild(_moderate); } - private function moderateButton(param1:String, param2:String, param3:Number, param4:Number, param5:String) : void + private function onModerateTyped(param1:Event) : void { - var _loc6_:MovieClip = GETDEFINITIONBYNAME("introBtnCont"); - _loc6_.x = param3; - _loc6_.y = param4; - _loc6_.name = param1; - finderButtonText(_loc6_,param2); - _loc6_.addEventListener("mouseDown",onModerateButton); - _moderateContent.addChild(_loc6_); - _moderateButtons.push({ - "clip":_loc6_, - "permission":param5 - }); + _moderateHint.visible = _moderateInput.text.length == 0; + showModerateReason(); } private function showModerate(param1:String) : void @@ -2120,22 +2623,35 @@ package } _moderateName = param1; _moderateReason = 0; - _moderateContent.titleTxt.text = "Moderate " + param1; - _moderateMessageBar.searchTxt.text = ""; - _moderateMessageBar.txt.visible = true; + _moderateTitle.text = "Moderate " + param1; + _moderateInput.text = ""; + _moderateHint.visible = true; for each(var _loc2_:Object in _moderateButtons) { _loc2_.clip.visible = staffMay(_loc2_.permission); } - _moderateMessageBar.visible = staffMay("player.warn"); + _moderateInput.parent.visible = staffMay("player.warn"); + modSetLabel(_moderateContent.getChildByName("invisible") as Sprite,staffInvisible ? "Be seen" : "Go invisible"); showModerateReason(); _moderate.visible = true; setChildIndex(_moderate,numChildren - 1); } + // the chosen reason's chip is lit; with text typed none is (the text is + // the warning), and Warn says so. private function showModerateReason() : void { - finderButtonText(_moderateContent.getChildByName("reason") as MovieClip,MODERATE_REASON_NAMES[_moderateReason]); + var _loc1_:Boolean = _moderateInput.text.replace(/^\s+|\s+$/g,"").length > 0; + var _loc2_:int = 0; + var _loc3_:Sprite = null; + while(_loc2_ < MODERATE_REASONS.length) + { + _loc3_ = _moderateContent.getChildByName("reason" + _loc2_) as Sprite; + paintFlatButton(_loc3_,_loc3_.width,!_loc1_ && _loc2_ == _moderateReason ? MOD_AMBER : MOD_GREY); + _loc3_.alpha = _loc1_ ? 0.45 : 1; + _loc2_++; + } + modSetLabel(_moderateContent.getChildByName("warn") as Sprite,_loc1_ ? "Warn with text" : "Warn"); } private function hideModerate() : void @@ -2156,25 +2672,35 @@ package private function onModerateButton(param1:MouseEvent) : void { param1.stopPropagation(); - var _loc2_:String = MovieClip(param1.currentTarget).name; + var _loc2_:String = Sprite(param1.currentTarget).name; var _loc3_:String = null; - if(_loc2_ == "reason") + if(_loc2_.indexOf("reason") == 0) { - _moderateReason = (_moderateReason + 1) % MODERATE_REASONS.length; + _moderateReason = int(_loc2_.substr(6)); showModerateReason(); return; } - if(_loc2_ == "warn") + if(_loc2_ == "invisible") + { + gMainFrame.server.setXtObject_Str("xiv",[]); + hideModerate(); + return; + } + // "%" ends a field of the message: left out. + _loc3_ = _moderateInput.text.split("%").join("").replace(/^\s+|\s+$/g,""); + if(_loc2_ == "warn" && _loc3_.length > 0) + { + gMainFrame.server.setXtObject_Str("xmd",["warn",_moderateName,"custom",_loc3_]); + } + else if(_loc2_ == "warn") { gMainFrame.server.setXtObject_Str("xmd",["warn",_moderateName,MODERATE_REASONS[_moderateReason]]); } else if(_loc2_ == "message") { - // "%" ends a field of the message: left out. - _loc3_ = _moderateMessageBar.searchTxt.text.split("%").join("").replace(/^\s+|\s+$/g,""); if(_loc3_.length == 0) { - gMainFrame.stage.focus = _moderateMessageBar.searchTxt; + gMainFrame.stage.focus = _moderateInput; return; } gMainFrame.server.setXtObject_Str("xmd",["message",_moderateName,_loc3_]); @@ -2189,7 +2715,970 @@ package } hideModerate(); } - + + // ---- emoji in chat. the game's text box takes nothing from Windows' + // emoji panel, so they are put in from here: a button at the end of the + // chat box opens a grid of them (Twemoji's pictures, from the server's + // /emoji/), and ":name:" in a line becomes the emoji when it is sent + // (unless it is one of the game's own emote codes, which win). the + // bubble draws them (gui.ChatBalloon). each is its name and its code + // points in hex, as Twemoji names its pictures. + private static const EMOJI_LIST:String = "smile:1f604,grin:1f601,joy:1f602,rofl:1f923,smiley:1f603,wink:1f609,blush:1f60a,innocent:1f607," + + "heart_eyes:1f60d,kissing_heart:1f618,star_struck:1f929,partying:1f973,sunglasses:1f60e,nerd:1f913,thinking:1f914," + + "neutral:1f610,expressionless:1f611,rolling_eyes:1f644,smirk:1f60f,relieved:1f60c,sleeping:1f634,yum:1f60b," + + "tongue:1f61b,zany:1f92a,shush:1f92b,cry:1f622,sob:1f62d,pleading:1f97a,angry:1f620,rage:1f621,scream:1f631," + + "flushed:1f633,cold:1f976,hot:1f975,skull:1f480,ghost:1f47b,alien:1f47d,robot:1f916,clown:1f921,poop:1f4a9," + + "thumbsup:1f44d,thumbsdown:1f44e,clap:1f44f,wave:1f44b,ok_hand:1f44c,pray:1f64f,muscle:1f4aa,raised_hands:1f64c," + + "v:270c,point_up:261d,eyes:1f440,heart:2764,orange_heart:1f9e1,yellow_heart:1f49b,green_heart:1f49a," + + "blue_heart:1f499,purple_heart:1f49c,black_heart:1f5a4,white_heart:1f90d,broken_heart:1f494,sparkling_heart:1f496," + + "two_hearts:1f495,fire:1f525,sparkles:2728,star:2b50,zap:26a1,boom:1f4a5,rainbow:1f308,sunny:2600,cloud:2601," + + "snowflake:2744,moon:1f319,tada:1f389,confetti:1f38a,balloon:1f388,gift:1f381,crown:1f451,gem:1f48e,trophy:1f3c6," + + "100:1f4af,check:2705,x:274c,warning:26a0,question:2753,exclamation:2757,music:1f3b5,video_game:1f3ae,dog:1f436," + + "cat:1f431,wolf:1f43a,fox:1f98a,bunny:1f430,bear:1f43b,panda:1f43c,tiger:1f42f,lion:1f981,monkey:1f435," + + "penguin:1f427,koala:1f428,horse:1f434,unicorn:1f984,owl:1f989,frog:1f438,turtle:1f422,snake:1f40d,dolphin:1f42c," + + "whale:1f433,shark:1f988,octopus:1f419,butterfly:1f98b,bee:1f41d,cherry_blossom:1f338,rose:1f339,sunflower:1f33b," + + "tree:1f333,cactus:1f335,mushroom:1f344,apple:1f34e,pizza:1f355,hamburger:1f354,fries:1f35f,cake:1f382,cookie:1f36a," + + "ice_cream:1f366,candy:1f36c,coffee:2615,house:1f3e0,rocket:1f680,ocean:1f30a,earth:1f30d,pumpkin:1f383," + + "christmas_tree:1f384,snowman:2603,crystal_ball:1f52e,magic:1fa84,paw:1f43e,feather:1fab6,leaf:1f343,four_leaf:1f340"; + + private static const EMOJI_COLUMNS:int = 14; + + private static const EMOJI_CELL:int = 26; + + private static var _emojiTable:Array; // [{name, hex, chars}] + + private static var _emojiByName:Object; + + private var _emojiButton:Sprite; + + private var _emojiPanel:Sprite; + + private var _emojiHint:TextField; + + private var _emojiField:TextField; + + private var _emojiCaret:int = -1; + + private var _emojiTimer:Timer; + + // the characters of code points in hex ("1f468-200d-1f469") + public static function charsOfHex(param1:String) : String + { + var _loc2_:String = ""; + var _loc3_:int = 0; + for each(var _loc4_:String in param1.split("-")) + { + _loc3_ = parseInt(_loc4_,16); + if(_loc3_ > 0xFFFF) + { + _loc3_ -= 0x10000; + _loc2_ += String.fromCharCode(0xD800 + (_loc3_ >> 10),0xDC00 + (_loc3_ & 0x3FF)); + } + else + { + _loc2_ += String.fromCharCode(_loc3_); + } + } + return _loc2_; + } + + private static function emojiTable() : Array + { + if(_emojiTable == null) + { + _emojiTable = []; + _emojiByName = {}; + for each(var _loc1_:String in EMOJI_LIST.split(",")) + { + var _loc2_:Array = _loc1_.split(":"); + var _loc3_:Object = {"name":_loc2_[0],"hex":_loc2_[1],"chars":charsOfHex(_loc2_[1])}; + _emojiTable.push(_loc3_); + _emojiByName[_loc3_.name] = _loc3_.chars; + } + } + return _emojiTable; + } + + // a line about to be sent: each ":name:" of an emoji above becomes it, + // but not the game's own emote codes (":happy:", ":joy:"), which the + // bubble shows as the game's. + public static function emojiShortcodes(param1:String) : String + { + if(param1.indexOf(":") == -1) + { + return param1; + } + emojiTable(); + return param1.replace(/:([a-z0-9_]{1,30}):/g,function(param1:String, param2:String, ... rest):String + { + if(EmoticonUtility.doesStringMatchAnEmote(param1) || _emojiByName[param2] == null) + { + return param1; + } + return _emojiByName[param2]; + }); + } + + // a line about to be sent, its emoji as "\{1f600}" (their pictures' + // names): the game's socket carries characters past U+FFFF badly, and + // these are plain letters. the bubble draws them (gui.ChatBalloon). + public static function emojiToTokens(param1:String) : String + { + var _loc2_:String = ""; + var _loc3_:int = 0; + var _loc4_:int = 0; + while(_loc3_ < param1.length) + { + _loc4_ = ChatBalloon.emojiLength(param1,_loc3_); + if(_loc4_ > 0) + { + _loc2_ += "\\{" + ChatBalloon.emojiName(param1.substr(_loc3_,_loc4_)) + "}"; + _loc3_ += _loc4_; + } + else + { + _loc2_ += param1.charAt(_loc3_); + _loc3_++; + } + } + return _loc2_; + } + + // a line for the chat history's list, which has no pictures: each emoji + // as its name (":fire:"), or ":emoji:" for one not in the grid. + public static function emojiAsNames(param1:String) : String + { + if(param1.indexOf("\\{") == -1) + { + return param1; + } + emojiTable(); + return param1.replace(/\\\{([0-9a-f]{2,6}(?:-[0-9a-f]{2,6}){0,9})\}/g,function(param1:String, param2:String, ... rest):String + { + for each(var _loc4_:Object in _emojiTable) + { + if(_loc4_.hex == param2 || ChatBalloon.emojiName(_loc4_.chars) == param2) + { + return ":" + _loc4_.name + ":"; + } + } + return ":emoji:"; + }); + } + + private function startEmojiButton() : void + { + _emojiTimer = new Timer(500); + _emojiTimer.addEventListener("timer",placeEmojiButton); + _emojiTimer.start(); + gMainFrame.stage.addEventListener("mouseDown",onEmojiStageDown,false,0,true); + } + + private static function shownOnStage(param1:DisplayObject) : Boolean + { + if(param1 == null || param1.stage == null) + { + return false; + } + while(param1 != null) + { + if(!param1.visible) + { + return false; + } + param1 = param1.parent; + } + return true; + } + + // the button, kept at the right end of the chat box while it is shown + private function placeEmojiButton(param1:Event = null) : void + { + var _loc2_:TextField = null; + var _loc3_:Point = null; + try + { + _loc2_ = GuiManager.chatHist != null ? GuiManager.chatHist.chatMsgText : null; + } + catch(e:Error) + { + _loc2_ = null; + } + if(_emojiButton == null) + { + _emojiButton = new Sprite(); + _emojiButton.buttonMode = true; + _emojiButton.useHandCursor = true; + _emojiButton.graphics.lineStyle(2,8349508); + _emojiButton.graphics.beginFill(16774084); + _emojiButton.graphics.drawCircle(0,0,12); + _emojiButton.graphics.endFill(); + var _loc4_:Sprite = new Sprite(); + _loc4_.mouseEnabled = false; + _loc4_.mouseChildren = false; + loadArt(gMainFrame.clientInfo.websiteURL + "emoji/1f600.png",_loc4_,17,false); + _emojiButton.addChild(_loc4_); + _emojiButton.addEventListener("mouseDown",onEmojiButton); + addChild(_emojiButton); + } + var _loc5_:Boolean = shownOnStage(_loc2_) && _loc2_.type == "input"; + _emojiButton.visible = _loc5_; + if(!_loc5_) + { + if(_emojiPanel != null) + { + _emojiPanel.visible = false; + } + return; + } + // the box gives up room for it once + if(_emojiField != _loc2_) + { + _emojiField = _loc2_; + _loc2_.width = Math.max(60,_loc2_.width - 28); + } + _loc3_ = globalToLocal(_loc2_.localToGlobal(new Point(_loc2_.width,_loc2_.height * 0.5))); + _emojiButton.x = int(_loc3_.x + 15); + _emojiButton.y = int(_loc3_.y); + if(getChildIndex(_emojiButton) < numChildren - 1 && (_emojiPanel == null || !_emojiPanel.visible)) + { + setChildIndex(_emojiButton,numChildren - 1); + } + } + + private function onEmojiButton(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_emojiPanel == null) + { + buildEmojiPanel(); + } + _emojiCaret = _emojiField != null && gMainFrame.stage.focus == _emojiField ? _emojiField.caretIndex : -1; + _emojiPanel.visible = !_emojiPanel.visible; + if(_emojiPanel.visible) + { + _emojiPanel.x = int(Math.max(4,_emojiButton.x + 14 - _emojiPanel.width)); + _emojiPanel.y = int(Math.max(4,_emojiButton.y - 18 - _emojiPanel.height)); + setChildIndex(_emojiPanel,numChildren - 1); + setChildIndex(_emojiButton,numChildren - 1); + } + } + + private function buildEmojiPanel() : void + { + var _loc1_:Array = emojiTable(); + var _loc2_:int = Math.ceil(_loc1_.length / EMOJI_COLUMNS); + var _loc3_:int = EMOJI_COLUMNS * EMOJI_CELL + 12; + var _loc4_:int = _loc2_ * EMOJI_CELL + 36; + var _loc5_:int = 0; + _emojiPanel = new Sprite(); + _emojiPanel.graphics.lineStyle(2,8349508); + _emojiPanel.graphics.beginFill(16774084); + _emojiPanel.graphics.drawRoundRect(0,0,_loc3_,_loc4_,14,14); + _emojiPanel.graphics.endFill(); + while(_loc5_ < _loc1_.length) + { + var _loc6_:Sprite = new Sprite(); + _loc6_.name = "emoji" + _loc5_; + _loc6_.x = 6 + (_loc5_ % EMOJI_COLUMNS) * EMOJI_CELL + EMOJI_CELL * 0.5; + _loc6_.y = 6 + Math.floor(_loc5_ / EMOJI_COLUMNS) * EMOJI_CELL + EMOJI_CELL * 0.5; + _loc6_.graphics.beginFill(3184463,0); + _loc6_.graphics.drawRoundRect(-EMOJI_CELL * 0.5,-EMOJI_CELL * 0.5,EMOJI_CELL,EMOJI_CELL,8,8); + _loc6_.graphics.endFill(); + _loc6_.buttonMode = true; + _loc6_.useHandCursor = true; + _loc6_.mouseChildren = false; + loadArt(gMainFrame.clientInfo.websiteURL + "emoji/" + _loc1_[_loc5_].hex + ".png",_loc6_,20,false); + _loc6_.addEventListener("mouseDown",onEmojiPick); + _loc6_.addEventListener("mouseOver",onEmojiHover); + _loc6_.addEventListener("mouseOut",onEmojiHover); + _emojiPanel.addChild(_loc6_); + _loc5_++; + } + _emojiHint = new TextField(); + _emojiHint.embedFonts = hasGameFont(); + _emojiHint.selectable = false; + _emojiHint.mouseEnabled = false; + _emojiHint.defaultTextFormat = new TextFormat("CCDigitalDelivery",12,6045213,true); + _emojiHint.width = _loc3_ - 16; + _emojiHint.height = 20; + _emojiHint.x = 8; + _emojiHint.y = _loc4_ - 26; + _emojiHint.text = "Or type its name, as :fire: or :heart:"; + _emojiPanel.addChild(_emojiHint); + _emojiPanel.visible = false; + addChild(_emojiPanel); + } + + private function onEmojiHover(param1:MouseEvent) : void + { + var _loc2_:Sprite = Sprite(param1.currentTarget); + var _loc3_:Object = emojiTable()[int(_loc2_.name.substr(5))]; + _loc2_.alpha = param1.type == "mouseOver" ? 0.7 : 1; + _emojiHint.text = param1.type == "mouseOver" ? ":" + _loc3_.name + ":" : "Or type its name, as :fire: or :heart:"; + } + + // an emoji into the chat box, where its cursor was + private function onEmojiPick(param1:MouseEvent) : void + { + param1.stopPropagation(); + var _loc2_:Object = emojiTable()[int(Sprite(param1.currentTarget).name.substr(5))]; + var _loc3_:TextField = _emojiField; + if(_loc3_ == null || _loc3_.text.length + _loc2_.chars.length > _loc3_.maxChars && _loc3_.maxChars > 0) + { + return; + } + var _loc4_:int = _emojiCaret >= 0 && _emojiCaret <= _loc3_.text.length ? _emojiCaret : _loc3_.text.length; + _loc3_.replaceText(_loc4_,_loc4_,_loc2_.chars); + _emojiCaret = _loc4_ + _loc2_.chars.length; + gMainFrame.stage.focus = _loc3_; + _loc3_.setSelection(_emojiCaret,_emojiCaret); + _loc3_.dispatchEvent(new Event("change")); + } + + // a click anywhere else closes the grid + private function onEmojiStageDown(param1:MouseEvent) : void + { + if(_emojiPanel != null && _emojiPanel.visible && !_emojiPanel.contains(param1.target as DisplayObject) && !_emojiButton.contains(param1.target as DisplayObject)) + { + _emojiPanel.visible = false; + } + } + + // ---- the Item Maker (the settings menu): a player's own item made from + // one of the game's (the server's lib/playeritems.js), in the look of the + // game's own windows, as the Item Giver is. two pages: making one (the + // game's items, looked up as the Item Giver does, "base=1": only those + // that can be copied) and the player's own (rename, a picture of its own, + // delete). the server answers "xcm" [ok, what to say, left today, left + // in all, the player's items as JSON]; a picture goes over HTTP + // (POST /api/itemart, lib/itemart.js). + private static const MAKER_ROWS:int = 5; + + private var _maker:Sprite; + + private var _makerContent:MovieClip; + + private var _makerMode:String = "make"; + + private var _makerKind:String = "clothing"; + + private var _makerStatus:TextField; + + private var _makerSearchBar:MovieClip; + + private var _makerNameBar:MovieClip; + + private var _makerKindButton:MovieClip; + + private var _makerRowsSprite:Sprite; + + private var _makerResults:Array = []; + + private var _makerMine:Array = []; + + private var _makerPage:int = 0; + + private var _makerChosen:Object; + + private var _makerLeft:String = ""; + + private var _makerButtons:Object = {}; + + private var _makerFile:FileReference; + + private var _makerUploading:Object; + + private var _makerIcons:Array = []; + + // "xcm": the server's answer, for the Item Maker if it is open. + public static function onItemMaker(param1:Object) : void + { + if(_toolsInstance != null) + { + try + { + _toolsInstance.makerAnswer(param1); + } + catch(e:Error) + { + GlobalErrorCatch.reportToServer("item maker: " + e + "\n" + e.getStackTrace()); + } + } + } + + // a button of the game's, at param3, param4; `param5` says which pages + // show it. + private function makerButton(param1:String, param2:String, param3:Number, param4:Number, param5:String, param6:Number = 1) : MovieClip + { + var _loc7_:MovieClip = GETDEFINITIONBYNAME("introBtnCont"); + _loc7_.name = param1; + _loc7_.x = param3; + _loc7_.y = param4; + _loc7_.scaleX = _loc7_.scaleY = param6; + finderButtonText(_loc7_,param2); + // the file picker opens only for a click + _loc7_.addEventListener(param1 == "picture" ? "click" : "mouseDown",onMakerButton); + _makerContent.addChild(_loc7_); + _makerButtons[param1] = {"clip":_loc7_,"pages":param5}; + return _loc7_; + } + + private function buildItemMaker() : void + { + var _loc1_:MovieClip = GETDEFINITIONBYNAME("ReportRulesPopupSkin"); + var _loc2_:int = 1; + var _loc3_:MovieClip = null; + _maker = new Sprite(); + _maker.graphics.beginFill(0,0.45); + _maker.graphics.drawRect(0,0,900,550); + _maker.graphics.endFill(); + var _loc4_:Sprite = new Sprite(); + _loc4_.x = 450; + _loc4_.y = 275; + _maker.addChild(_loc4_); + _loc4_.addChild(_loc1_); + _makerContent = GETDEFINITIONBYNAME("ReportRulesPopupContent"); + _makerContent.x = _loc1_.c.x; + _makerContent.y = _loc1_.c.y; + _loc4_.addChild(_makerContent); + _loc1_.bx.addEventListener("mouseDown",function(param1:MouseEvent):void + { + param1.stopPropagation(); + showItemMaker(false); + }); + while(_loc2_ <= 5) + { + _makerContent["ruleTxt" + _loc2_].visible = false; + _makerContent["ruleBodyTxt" + _loc2_].visible = false; + _loc2_++; + } + _makerContent.titleTxt.text = "Item Maker"; + _makerStatus = _makerContent.ruleBodyTxt1; + _makerStatus.visible = true; + _makerStatus.wordWrap = true; + _makerStatus.x = -245; + _makerStatus.y = -116; + _makerStatus.width = 490; + _makerStatus.height = 44; + // the bars and the kind, over the list + _makerSearchBar = finderSearchBar(-247,-160,212,"Search the game's items",null,40,true); + _makerContent.addChild(_makerSearchBar); + _makerKindButton = makerButton("kind","Clothing",-30,-156,"make"); + _makerNameBar = finderSearchBar(93,-160,156,"Your item's name","A-Za-z0-9 '&!?.,:()#+\\-",40,false); + _makerContent.addChild(_makerNameBar); + _makerRowsSprite = new Sprite(); + _makerRowsSprite.y = -54; + _makerContent.addChild(_makerRowsSprite); + _loc3_ = GETDEFINITIONBYNAME("arrow_l_btnContOld"); + _loc3_.x = -228; + _loc3_.y = 166; + _loc3_.name = "prev"; + _loc3_.addEventListener("mouseDown",onMakerButton); + _makerContent.addChild(_loc3_); + _loc3_ = GETDEFINITIONBYNAME("arrow_r_btnContOld"); + _loc3_.x = 228; + _loc3_.y = 166; + _loc3_.name = "next"; + _loc3_.addEventListener("mouseDown",onMakerButton); + _makerContent.addChild(_loc3_); + // making one + makerButton("make","Make it",-175,148,"make"); + makerButton("mine","My items",-58,148,"make"); + makerButton("search","Search",59,148,"make"); + // their own: what the bar's name, a picture or a delete does to the one chosen + makerButton("rename","Rename",-215,148,"mine",0.72); + makerButton("picture","Picture",-128,148,"mine",0.72); + makerButton("look","Look",-41,148,"mine",0.72); + makerButton("delete","Delete",46,148,"mine",0.72); + makerButton("back","Make more",133,148,"mine",0.72); + _maker.addEventListener("mouseDown",onFinderMouse); + _maker.addEventListener("mouseUp",onFinderMouse); + _maker.addEventListener("click",onFinderMouse); + _maker.addEventListener("mouseWheel",onFinderMouse); + _maker.visible = false; + addChild(_maker); + } + + private function showItemMaker(param1:Boolean) : void + { + if(!param1) + { + if(_maker != null) + { + _maker.visible = false; + } + gMainFrame.stage.focus = null; + return; + } + if(_maker == null) + { + buildItemMaker(); + } + _makerChosen = null; + _makerNameBar.searchTxt.text = ""; + _makerNameBar.txt.visible = true; + makerMode("make"); + _maker.visible = true; + setChildIndex(_maker,numChildren - 1); + gMainFrame.stage.focus = _makerSearchBar.searchTxt; + gMainFrame.server.setXtObject_Str("xcm",["info"]); + makerSearch(); + } + + private function makerMode(param1:String) : void + { + _makerMode = param1; + _makerPage = 0; + _makerChosen = null; + for each(var _loc2_:Object in _makerButtons) + { + _loc2_.clip.visible = String(_loc2_.pages).indexOf(param1) != -1; + } + _makerSearchBar.visible = param1 == "make"; + _makerNameBar.txt.text = param1 == "make" ? "Your item's name" : "New name"; + makerSay(param1 == "make" ? "Choose one of the game's items, name it, then Make it. " + _makerLeft : "Choose one of your items: rename it (type the name first), give it a picture, change its Look (worn as the picture, or its shape painted with it), or delete it."); + makerRows(); + } + + private function makerSay(param1:String) : void + { + _makerStatus.text = param1; + } + + private function makerSearch() : void + { + var _loc1_:URLLoader = new URLLoader(); + _loc1_.addEventListener("complete",onMakerResults,false,0,false); + _loc1_.addEventListener("ioError",onMakerFailed,false,0,false); + _loc1_.addEventListener("securityError",onMakerFailed,false,0,false); + _loc1_.load(new URLRequest(gMainFrame.clientInfo.websiteURL + "api/search?base=1&kind=" + _makerKind + "&q=" + encodeURIComponent(_makerSearchBar.searchTxt.text) + + "&username=" + encodeURIComponent(gMainFrame.server.userName) + "&token=" + encodeURIComponent(gMainFrame.clientInfo.authToken))); + } + + private function onMakerFailed(param1:Event) : void + { + makerSay("That did not work. Try again."); + } + + private function onMakerResults(param1:Event) : void + { + try + { + _makerResults = JSON.parse(param1.target.data).results as Array; + } + catch(e:Error) + { + _makerResults = null; + } + if(_makerResults == null) + { + _makerResults = []; + } + _makerPage = 0; + if(_makerMode == "make") + { + makerRows(); + if(_makerResults.length == 0) + { + makerSay("Nothing found. Try another word."); + } + } + } + + private function makerList() : Array + { + return _makerMode == "make" ? _makerResults : _makerMine; + } + + // the page of the list shown: a row of the game's for each, its icon + // (a custom item's own picture, when it has one) beside it. + private function makerRows() : void + { + var _loc1_:Array = makerList(); + var _loc2_:int = _makerPage * MAKER_ROWS; + var _loc3_:MovieClip = null; + var _loc4_:Object = null; + while(_makerRowsSprite.numChildren > 0) + { + _makerRowsSprite.removeChildAt(0); + } + _makerIcons = []; + while(_loc2_ < _loc1_.length && _loc2_ < _makerPage * MAKER_ROWS + MAKER_ROWS) + { + _loc4_ = _loc1_[_loc2_]; + _loc3_ = GETDEFINITIONBYNAME("textBtnCont"); + _loc3_.x = -40; + _loc3_.y = (_loc2_ - _makerPage * MAKER_ROWS) * 40; + _loc3_.name = "row" + _loc2_; + _loc3_.currTxt.mouseEnabled = false; + var _loc5_:Boolean = _makerChosen != null && _makerChosen.id == _loc4_.id && _makerChosen.kind == _loc4_.kind; + _loc3_.currTxt.text = (_loc5_ ? "> " : "") + makerShort(String(_loc4_.name || "(no name)"),24) + (_makerMode == "mine" ? (_loc4_.waiting == "item" ? " (waiting)" : _loc4_.waiting == "picture" ? " (picture waiting)" : _loc4_.art ? (_loc4_.kind == "clothing" ? (_loc4_.artMode == "texture" ? " (texture)" : " (sticker)") : " (picture)") : "") : " #" + _loc4_.id); + _loc3_.addEventListener("mouseDown",onMakerButton); + _makerRowsSprite.addChild(_loc3_); + _makerRowsSprite.addChild(finderPreview(_loc4_,_loc2_,186,_loc3_.y)); + _loc2_++; + } + if(_makerMode == "mine" && _loc1_.length == 0) + { + makerSay("You have not made any items yet. " + _makerLeft); + } + } + + private static function makerShort(param1:String, param2:int) : String + { + return param1.length > param2 ? param1.substr(0,param2 - 3) + "..." : param1; + } + + public function makerAnswer(param1:Object) : void + { + if(_maker == null) + { + return; + } + var _loc2_:String = String(param1[3]); + try + { + _makerMine = JSON.parse(String(param1[6])) as Array; + } + catch(e:Error) + { + _makerMine = null; + } + if(_makerMine == null) + { + _makerMine = []; + } + _makerMine.reverse(); // the newest first + // the one chosen on this page, as it is now (its look, its picture) + if(_makerMode == "mine" && _makerChosen != null) + { + var _loc6_:Object = _makerChosen; + _makerChosen = null; + for each(var _loc7_:Object in _makerMine) + { + if(_loc7_.kind == _loc6_.kind && _loc7_.id == _loc6_.id) + { + _makerChosen = _loc7_; + } + } + } + _makerLeft = "You can make " + int(param1[4]) + " more today (" + int(param1[5]) + " in all)."; + if(_loc2_.length > 0) + { + makerSay(_loc2_); + } + else if(_makerMode == "make") + { + makerSay("Choose one of the game's items, name it, then Make it. " + _makerLeft); + } + if(String(param1[2]) == "1" && _loc2_.length > 0) + { + _makerNameBar.searchTxt.text = ""; + _makerNameBar.txt.visible = true; + _makerChosen = null; + } + if(_makerMode == "mine") + { + makerRows(); + } + } + + private function makerName() : String + { + return _makerNameBar.searchTxt.text.split("%").join("").replace(/^\s+|\s+$/g,""); + } + + private function onMakerButton(param1:MouseEvent) : void + { + param1.stopPropagation(); + var _loc2_:String = DisplayObject(param1.currentTarget).name; + var _loc3_:Object = null; + if(_loc2_.indexOf("row") == 0) + { + _makerChosen = makerList()[int(_loc2_.substr(3))]; + if(_makerChosen != null && _makerMode == "make" && _makerNameBar.searchTxt.text.length == 0) + { + _makerNameBar.searchTxt.text = String(_makerChosen.name || "").replace(/[^A-Za-z0-9 '&!?.,:()#+\-]/g,"").substr(0,40); + _makerNameBar.txt.visible = _makerNameBar.searchTxt.text.length == 0; + } + if(_makerChosen != null) + { + makerSay((_makerMode == "make" ? "Making it from " : "Chosen: ") + _makerChosen.name + "."); + } + makerRows(); + } + else if(_loc2_ == "kind") + { + _makerKind = _makerKind == "clothing" ? "den" : "clothing"; + finderButtonText(_makerKindButton,_makerKind == "clothing" ? "Clothing" : "Den items"); + _makerChosen = null; + makerSearch(); + } + else if(_loc2_ == "search") + { + makerSearch(); + } + else if(_loc2_ == "prev" || _loc2_ == "next") + { + _makerPage = Math.max(0,Math.min(_makerPage + (_loc2_ == "next" ? 1 : -1),Math.ceil(makerList().length / MAKER_ROWS) - 1)); + makerRows(); + } + else if(_loc2_ == "mine") + { + makerMode("mine"); + } + else if(_loc2_ == "back") + { + makerMode("make"); + makerSearch(); + } + else if(_makerChosen == null) + { + makerSay(_makerMode == "make" ? "Choose one of the game's items first." : "Choose one of your items first."); + } + else if(_loc2_ == "make") + { + if(makerName().length == 0) + { + gMainFrame.stage.focus = _makerNameBar.searchTxt; + makerSay("Type a name for it first."); + return; + } + makerSay("Making it..."); + gMainFrame.server.setXtObject_Str("xcm",["make",_makerChosen.kind,_makerChosen.id,makerName()]); + } + else if(_loc2_ == "rename") + { + if(makerName().length == 0) + { + gMainFrame.stage.focus = _makerNameBar.searchTxt; + makerSay("Type the new name in the box first."); + return; + } + gMainFrame.server.setXtObject_Str("xcm",["rename",_makerChosen.kind,_makerChosen.id,makerName()]); + } + else if(_loc2_ == "delete") + { + _loc3_ = _makerChosen; + new SBYesNoPopup(GuiManager.guiLayer,"Delete " + _loc3_.name + "? It goes from everyone who has it.",true,function(param1:Object):void + { + if(param1.status) + { + gMainFrame.server.setXtObject_Str("xcm",["delete",_loc3_.kind,_loc3_.id]); + } + },0); + } + else if(_loc2_ == "picture") + { + makerPickPicture(_makerChosen); + } + // how a clothing item with a picture is worn: the picture itself + // (a sticker) or the item's shape painted with it (a texture) + else if(_loc2_ == "look") + { + if(_makerChosen.kind != "clothing" || !_makerChosen.art) + { + makerSay(_makerChosen.kind != "clothing" ? "A den item stands as its picture." : "Give it a picture first."); + return; + } + gMainFrame.server.setXtObject_Str("xcm",["look",_makerChosen.kind,_makerChosen.id,_makerChosen.artMode == "texture" ? "sticker" : "texture"]); + } + } + + // the picture: chosen from this computer, read, and sent as it is (the + // server checks it and takes out what does not belong in it). + private function makerPickPicture(param1:Object) : void + { + _makerUploading = param1; + _makerFile = new FileReference(); + _makerFile.addEventListener("select",function(param1:Event):void + { + makerSay("Reading the picture..."); + _makerFile.load(); + }); + _makerFile.addEventListener("complete",onMakerPictureRead); + _makerFile.addEventListener("ioError",onMakerFailed); + try + { + _makerFile.browse([new FileFilter("Pictures (PNG, JPEG, GIF, BMP)","*.png;*.jpg;*.jpeg;*.gif;*.bmp")]); + } + catch(e:Error) + { + makerSay("The picture could not be chosen here. Use your account page on the website instead."); + } + } + + // the picture read: sent as it is when the server takes it so (a PNG, + // JPEG or GIF small enough, or a BMP, which the server makes a PNG); one + // too big is drawn smaller here and sent as a PNG. + private static const MAKER_PICTURE_SIDE:int = 512; + + private static const MAKER_PICTURE_BYTES:int = 300 * 1024; + + private function onMakerPictureRead(param1:Event) : void + { + var _loc2_:ByteArray = _makerFile.data; + if(/\.bmp$/i.test(String(_makerFile.name))) + { + makerSendPicture(_loc2_); + return; + } + var _loc3_:Loader = new Loader(); + _loc3_.contentLoaderInfo.addEventListener("complete",function(param1:Event):void + { + var _loc2_:BitmapData = _loc3_.content is Bitmap ? Bitmap(_loc3_.content).bitmapData : null; + if(_loc2_ == null) + { + makerSay("That picture could not be read. Try a PNG, JPEG or GIF."); + } + else if(_loc2_.width <= MAKER_PICTURE_SIDE && _loc2_.height <= MAKER_PICTURE_SIDE && _makerFile.data.length <= MAKER_PICTURE_BYTES) + { + makerSendPicture(_makerFile.data); + } + else + { + makerSay("Making the picture smaller..."); + makerSendPicture(shrunkPng(_loc2_)); + } + }); + _loc3_.contentLoaderInfo.addEventListener("ioError",function(param1:Event):void + { + makerSay("That picture could not be read. Try a PNG, JPEG or GIF."); + }); + _loc3_.loadBytes(_loc2_); + } + + // a PNG of the picture fitted in MAKER_PICTURE_SIDE, smaller until it is + // no more than MAKER_PICTURE_BYTES + private static function shrunkPng(param1:BitmapData) : ByteArray + { + var _loc2_:ByteArray = null; + for each(var _loc3_:int in [MAKER_PICTURE_SIDE,384,256,128]) + { + var _loc4_:Number = Math.min(1,_loc3_ / param1.width,_loc3_ / param1.height); + var _loc5_:BitmapData = new BitmapData(Math.max(1,Math.round(param1.width * _loc4_)),Math.max(1,Math.round(param1.height * _loc4_)),true,0); + _loc5_.draw(param1,new Matrix(_loc4_,0,0,_loc4_),null,null,null,true); + _loc2_ = encodePng(_loc5_); + _loc5_.dispose(); + if(_loc2_.length <= MAKER_PICTURE_BYTES) + { + break; + } + } + return _loc2_; + } + + private static var _crcTable:Array; + + private static function crc32(param1:ByteArray, param2:int, param3:int) : uint + { + var _loc4_:uint = 0; + var _loc5_:int = 0; + var _loc6_:int = 0; + if(_crcTable == null) + { + _crcTable = []; + while(_loc5_ < 256) + { + _loc4_ = _loc5_; + _loc6_ = 0; + while(_loc6_ < 8) + { + _loc4_ = (_loc4_ & 1) != 0 ? uint(0xEDB88320 ^ (_loc4_ >>> 1)) : uint(_loc4_ >>> 1); + _loc6_++; + } + _crcTable[_loc5_] = _loc4_; + _loc5_++; + } + } + _loc4_ = 0xFFFFFFFF; + _loc5_ = param2; + while(_loc5_ < param3) + { + _loc4_ = uint(_crcTable[(_loc4_ ^ param1[_loc5_]) & 0xFF] ^ (_loc4_ >>> 8)); + _loc5_++; + } + return uint(_loc4_ ^ 0xFFFFFFFF); + } + + private static function pngChunk(param1:ByteArray, param2:uint, param3:ByteArray) : void + { + param1.writeUnsignedInt(param3 == null ? 0 : param3.length); + var _loc4_:int = int(param1.position); + param1.writeUnsignedInt(param2); + if(param3 != null) + { + param1.writeBytes(param3); + } + param1.writeUnsignedInt(crc32(param1,_loc4_,int(param1.position))); + } + + // a PNG (RGBA, 8 bits a channel) of `param1` + public static function encodePng(param1:BitmapData) : ByteArray + { + var _loc2_:ByteArray = new ByteArray(); + var _loc3_:ByteArray = new ByteArray(); + var _loc4_:ByteArray = new ByteArray(); + var _loc5_:int = 0; + var _loc6_:int = 0; + var _loc7_:uint = 0; + _loc2_.writeUnsignedInt(0x89504E47); + _loc2_.writeUnsignedInt(0x0D0A1A0A); + _loc3_.writeInt(param1.width); + _loc3_.writeInt(param1.height); + _loc3_.writeByte(8); + _loc3_.writeByte(6); + _loc3_.writeByte(0); + _loc3_.writeByte(0); + _loc3_.writeByte(0); + pngChunk(_loc2_,0x49484452,_loc3_); + while(_loc5_ < param1.height) + { + _loc4_.writeByte(0); + _loc6_ = 0; + while(_loc6_ < param1.width) + { + _loc7_ = param1.getPixel32(_loc6_,_loc5_); + _loc4_.writeUnsignedInt(uint((_loc7_ & 0xFFFFFF) << 8 | _loc7_ >>> 24)); + _loc6_++; + } + _loc5_++; + } + _loc4_.compress(); + pngChunk(_loc2_,0x49444154,_loc4_); + pngChunk(_loc2_,0x49454E44,null); + return _loc2_; + } + + private function makerSendPicture(param1:ByteArray) : void + { + var _loc2_:URLRequest = new URLRequest(gMainFrame.clientInfo.websiteURL + "api/itemart?kind=" + _makerUploading.kind + "&id=" + _makerUploading.id + + "&token=" + encodeURIComponent(gMainFrame.clientInfo.authToken)); + _loc2_.method = "POST"; + _loc2_.contentType = "application/octet-stream"; + _loc2_.data = param1; + var _loc3_:URLLoader = new URLLoader(); + _loc3_.addEventListener("complete",function(param1:Event):void + { + var _loc2_:Object = null; + try + { + _loc2_ = JSON.parse(param1.target.data); + } + catch(e:Error) + { + _loc2_ = {"error":"That did not work. Try again."}; + } + makerSay(_loc2_.ok ? String(_loc2_.ok) : String(_loc2_.error)); + gMainFrame.server.setXtObject_Str("xcm",["info"]); + }); + _loc3_.addEventListener("ioError",onMakerFailed); + _loc3_.addEventListener("securityError",onMakerFailed); + makerSay("Sending the picture..."); + _loc3_.load(_loc2_); + } + private function onFinderKey(param1:KeyboardEvent) : void { if(param1.eventPhase == 3) @@ -2197,6 +3686,31 @@ package return; } var _loc2_:Boolean = _finder != null && _finder.visible; + // the Item Maker and the staff's window: Esc closes them, Enter + // searches (in the Item Maker's search box), and no key gets past + // them to the game (which would take typing for its chat bar). + if(_maker != null && _maker.visible) + { + if(param1.keyCode == 27) + { + showItemMaker(false); + } + else if(param1.keyCode == 13 && gMainFrame.stage.focus == _makerSearchBar.searchTxt) + { + makerSearch(); + } + param1.stopImmediatePropagation(); + return; + } + if(_moderate != null && _moderate.visible) + { + if(param1.keyCode == 27) + { + hideModerate(); + } + param1.stopImmediatePropagation(); + return; + } // the rules: Esc closes them as their X does if(_rulesWin != null && _rulesWin.visible) { diff --git a/swf-src/ActionManager.as b/swf-src/ActionManager.as index eb5b719..1487fab 100644 --- a/swf-src/ActionManager.as +++ b/swf-src/ActionManager.as @@ -47,6 +47,17 @@ package gui private var _names:Dictionary = new Dictionary(true); private var _swapBtn:MovieClip; + + // Whether the next (and currently selected) action is horizontally + // mirrored. The state is sent with the action to other players. + public var mirrorActions:Boolean = false; + + private var _lastAction:Sprite; + + // sitting facing forward (":sitS:", AvatarWorldView's animation 1): the + // "Forward" in the middle of the four arrows. its action sprite is a + // class of the client's own (SitForwardAction), not of the HUD's art. + private static const SIT_FORWARD:String = "SitForwardAction"; private const ACTIONWINDOW_DIM_ALPHA:Number = 0.5; @@ -309,6 +320,7 @@ package gui _loc12_.addEventListener("mouseDown",actionClickHandler,false,0,true); _loc8_++; } + addSitDirectionButtons(_loc3_); } else if(_loc6_ >= 4) { @@ -393,6 +405,7 @@ package gui actionStrings["sleepAnim_btnCont"] = actionStrings["diveAnim_btnCont"] = [":sleep:",":dive:"]; actionStrings["hopAnim_btnCont"] = actionStrings["swirlAnim_btnCont"] = [":hop:",":swirl:"]; actionStrings["playAnim_btnCont"] = [":play:"]; + actionStrings[SIT_FORWARD] = [":sitS:"]; } private function setupTitleBanner() : void @@ -445,6 +458,110 @@ package gui return _loc2_.length > 1 ? _loc2_[_oceanShown ? 1 : 0] : _loc2_[0]; } + // Front and Back sit facing straight forward and straight away. Mirror + // replays whichever action was picked most recently in the other + // horizontal direction (including dance, sleep, hop and play). + private function addSitDirectionButtons(param1:MovieClip) : void + { + var _loc2_:Rectangle = param1.getBounds(param1); + var _loc3_:Number = _loc2_.x + _loc2_.width * 0.5; + var _loc4_:Number = _loc2_.y + _loc2_.height * 0.5; + var _loc5_:Sprite = addDirectionButton(param1,"Front",0,0,false); + var _loc6_:Sprite = addDirectionButton(param1,"Back",0,0,true); + var _loc7_:Number = _loc3_ - (_loc5_.width + 3 + _loc6_.width) * 0.5; + _loc5_.x = _loc7_; + _loc6_.x = _loc7_ + _loc5_.width + 3; + _loc5_.y = _loc6_.y = _loc4_ - 13; + var _loc8_:Sprite = actionPill("Mirror"); + var _loc9_:Sprite = actionHitTarget(_loc8_); + _loc9_.x = _loc3_ - _loc9_.width * 0.5; + _loc9_.y = _loc4_ + 3; + _loc9_.addEventListener("mouseDown",mirrorClickHandler,false,0,true); + _loc9_.addEventListener("mouseOver",function(param1:MouseEvent):void + { + _loc9_.alpha = 0.8; + },false,0,true); + _loc9_.addEventListener("mouseOut",function(param1:MouseEvent):void + { + _loc9_.alpha = 1; + },false,0,true); + param1.addChild(_loc9_); + } + + private function addDirectionButton(param1:MovieClip, param2:String, param3:Number, param4:Number, param5:Boolean) : Sprite + { + var _loc6_:Sprite = actionPill(param2); + var _loc7_:Sprite = actionHitTarget(_loc6_); + _loc7_.x = param3; + _loc7_.y = param4; + _loc7_.name = param5 ? "sitBackHit" : "sitFrontHit"; + _loc7_.addEventListener("mouseDown",sitDirectionClickHandler,false,0,true); + param1.addChild(_loc7_); + return _loc7_; + } + + // Keep the generated controls visually uniform. Invisible trailing + // spaces reserve the same room without changing the labels players see. + private function actionPill(param1:String) : Sprite + { + var _loc2_:String = param1 == "Front" ? "Front " : (param1 == "Back" ? "Back " : param1); + return AJClient.makePill(_loc2_,0x5CB82E,0x2C6E16,false,10); + } + + private function sitDirectionClickHandler(param1:MouseEvent) : void + { + param1.stopPropagation(); + // one sprite class for both; each sprite is named for the way it faces + var _loc2_:Sprite = new SitForwardAction(); + _names[_loc2_] = param1.currentTarget.name == "sitBackHit" ? ":sitN:" : ":sitS:"; + selectAction(_loc2_); + } + + // The sit artwork is itself a MovieClip with mouse children. A separate + // transparent hit target above it keeps our generated labels clickable. + private function actionHitTarget(param1:Sprite) : Sprite + { + var _loc2_:Sprite = new Sprite(); + _loc2_.graphics.beginFill(0,0); + _loc2_.graphics.drawRect(0,0,param1.width,param1.height); + _loc2_.graphics.endFill(); + _loc2_.addChild(param1); + _loc2_.buttonMode = true; + _loc2_.useHandCursor = true; + _loc2_.mouseEnabled = true; + _loc2_.mouseChildren = false; + return _loc2_; + } + + private function selectAction(param1:Sprite, param2:Boolean = false) : void + { + if(!actionBtn.isGray) + { + mirrorActions = param2; + _lastAction = param1; + setActionCallback(param1); + actionBtn.dispatchEvent(new MouseEvent("mouseDown")); + } + } + + private function mirrorClickHandler(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!actionBtn.isGray) + { + mirrorActions = !mirrorActions; + if(_lastAction) + { + setActionCallback(_lastAction); + } + } + } + + public function rememberAction(param1:Sprite) : void + { + _lastAction = param1; + } + public function getActionString(param1:Sprite) : String { if(_names[param1] != undefined) @@ -462,6 +579,12 @@ package gui public function matchActionString(param1:String, param2:Boolean = false) : Sprite { var _loc3_:int = 0; + if(param1 == ":sitS:" || param1 == ":sitN:") + { + var _loc9_:Sprite = new SitForwardAction(); + _names[_loc9_] = param1; + return _loc9_; + } var _loc4_:String = OTHER_SET_BUTTONS[param1]; var _loc5_:Sprite = null; if(_loc4_ && param2 && !playerHasSet(param1.indexOf("Swim") != -1)) @@ -565,7 +688,8 @@ package gui param1.stopPropagation(); if(!actionBtn.isGray && !param1.currentTarget.isGray) { - setActionCallback(new param1.currentTarget.constructor()); + _lastAction = new param1.currentTarget.constructor(); + setActionCallback(_lastAction); actionBtn.dispatchEvent(new MouseEvent("mouseDown")); param1.currentTarget.downToUpState(); } diff --git a/swf-src/AvatarUtility.as b/swf-src/AvatarUtility.as new file mode 100644 index 0000000..7678c4e --- /dev/null +++ b/swf-src/AvatarUtility.as @@ -0,0 +1,2161 @@ +package avatar +{ + import collection.AccItemCollection; + import com.sbi.bit.BitUtility; + import diamond.DiamondItem; + import diamond.DiamondXtCommManager; + import flash.events.MouseEvent; + import flash.geom.Point; + import gui.GuiManager; + import item.EquippedAvatars; + import item.Item; + import item.ItemXtCommManager; + + public class AvatarUtility + { + + public static const AVT_AVAIL_HIDDEN:int = 0; + + public static const AVT_AVAIL_ACTIVE:int = 1; + + public static const AVT_AVAIL_ENDANGERED:int = 2; + + public static const AVT_AVAIL_EXTINCT:int = 3; + + private static var _creationAvatars:Array; + + private static var _avatarDefInfo:Array; + + private static var _skippedIndexes:Array; + + private static var _avtMgrGetAvtByPerUserAvId:Function; + + private static var _numViewsLoaded:int; + + private static var _numNonMemberAvatars:Function; + + private static var _currDiamondAvatarStoreDefs:Array; + + private static var _diamondAvatarListData:Array; + + private static var _onAvatarListLoaded:Function; + + public function AvatarUtility() + { + super(); + } + + public static function init(param1:Function, param2:Function = null, param3:Boolean = true, param4:Function = null) : void + { + _avtMgrGetAvtByPerUserAvId = param1; + _numNonMemberAvatars = param2; + _onAvatarListLoaded = param4; + GenericListXtCommManager.requestGenericList(64,buildCreationAvatarViews,null,param3); + } + + public static function buildCreationAvatarViews(param1:Array, param2:Boolean = false, param3:Function = null) : void + { + var _loc13_:int = 0; + var _loc4_:int = 0; + var _loc21_:Avatar = null; + var _loc9_:int = 0; + var _loc17_:int = 0; + var _loc18_:Item = null; + var _loc15_:int = 0; + var _loc14_:int = 0; + var _loc16_:Object = null; + var _loc7_:Object = null; + var _loc12_:int = 0; + var _loc6_:Object = null; + var _loc19_:* = undefined; + var _loc8_:int = 0; + var _loc20_:CustomAvatarDef = null; + var _loc10_:int = 0; + if(param3 != null) + { + _onAvatarListLoaded = param3; + } + _skippedIndexes = []; + var _loc11_:int = int(param1.length); + var _loc5_:int = 0; + if(_creationAvatars) + { + if(_creationAvatars.length > 0) + { + _loc12_ = 0; + while(_loc12_ < _creationAvatars.length) + { + _creationAvatars[_loc12_].destroy(); + _loc12_++; + } + } + } + _avatarDefInfo = new Array(_loc11_); + _creationAvatars = []; + _loc14_ = 0; + _loc13_ = 0; + _loc4_ = 0; + while(_loc14_ < _loc11_) + { + _loc6_ = gMainFrame.userInfo.getAvatarDefByAvType(param1[_loc14_],false); + if(_loc6_) + { + if(isAvatarActive(_loc6_.availability) && (!param2 || param2 && !_loc6_.isMemOnly && !isExtinct(_loc6_.availability) && Utility.isLand(_loc6_.enviroTypeFlag))) + { + _loc17_ = int(param1[_loc14_]); + _avatarDefInfo[_loc4_ - _loc5_] = { + "isMemberOnly":_loc6_.isMemOnly, + "enviroFlag":_loc6_.enviroTypeFlag, + "recycleValue":Math.ceil(_loc6_.cost * 0.5), + "cost":(_loc6_.status == 2 ? Math.ceil(_loc6_.cost * 0.5) : _loc6_.cost), + "availability":_loc6_.availability, + "status":_loc6_.status, + "isDiamond":false, + "diamondItem":null, + "diamondCost":0 + }; + _loc21_ = new Avatar(); + _loc21_.init(0,0,"",_loc17_,[_loc6_.colorLayer1,_loc6_.colorLayer2,_loc6_.colorLayer3]); + if(!param2) + { + _loc16_ = ItemXtCommManager.getItemDef(_loc6_.defEyes); + _loc7_ = ItemXtCommManager.getItemDef(_loc6_.defPattern); + if(_loc16_ == null) + { + _skippedIndexes[_loc14_] = true; + _loc5_++; + _loc4_++; + _loc14_++; + continue; + } + _loc18_ = new Item(); + _loc18_.init(1,_loc13_++,0,EquippedAvatars.forced()); + _loc21_.inventoryBodyMod.addItem(_loc18_); + _loc21_.accStateShowAccessory(_loc18_); + _loc18_ = new Item(); + _loc18_.init(_loc16_.defId,_loc13_++,_loc16_.colors,EquippedAvatars.forced()); + _loc21_.inventoryBodyMod.addItem(_loc18_); + _loc21_.accStateShowAccessory(_loc18_); + if(_loc7_) + { + _loc18_ = new Item(); + _loc18_.init(_loc7_.defId,_loc13_++,_loc7_.colors,EquippedAvatars.forced()); + _loc21_.inventoryBodyMod.addItem(_loc18_); + _loc21_.accStateShowAccessory(_loc18_); + } + } + _creationAvatars.push(_loc21_); + _skippedIndexes[_loc14_] = false; + if(!param2) + { + _loc19_ = gMainFrame.userInfo.getCustomAvatarDefsByAvRefId(_loc17_); + if(_loc19_) + { + _loc8_ = 0; + while(_loc8_ < _loc19_.length) + { + _loc20_ = _loc19_[_loc8_]; + if(_loc20_) + { + _loc21_ = new Avatar(); + _loc21_.init(0,0,"",_loc20_.avatarRefId,[_loc20_.colorLayer1,_loc20_.colorLayer2,_loc20_.colorLayer3],_loc20_.defId); + _loc16_ = ItemXtCommManager.getItemDef(_loc20_.defEyes); + if(_loc16_ == null) + { + _skippedIndexes[_loc14_] = true; + } + else + { + _loc18_ = new Item(); + _loc18_.init(1,_loc13_++,0,EquippedAvatars.forced()); + _loc21_.inventoryBodyMod.addItem(_loc18_); + _loc21_.accStateShowAccessory(_loc18_); + _loc18_ = new Item(); + _loc18_.init(_loc16_.defId,_loc13_++,_loc16_.colors,EquippedAvatars.forced()); + _loc21_.inventoryBodyMod.addItem(_loc18_); + _loc21_.accStateShowAccessory(_loc18_); + _loc10_ = 0; + while(_loc10_ < _loc20_.patternRefIds.length) + { + _loc7_ = ItemXtCommManager.getItemDef(_loc20_.patternRefIds[_loc10_]); + if(_loc7_) + { + _loc18_ = new Item(); + _loc18_.init(_loc7_.defId,_loc13_++,_loc7_.colors,EquippedAvatars.forced()); + _loc21_.inventoryBodyMod.addItem(_loc18_); + _loc21_.accStateShowAccessory(_loc18_); + } + _loc10_++; + } + _creationAvatars.push(_loc21_); + _loc4_++; + _avatarDefInfo[_loc4_ - _loc5_] = { + "isMemberOnly":_loc20_.isMemOnly, + "enviroFlag":_loc20_.enviroTypeFlag, + "recycleValue":Math.ceil(_loc20_.cost * 0.5), + "cost":(_loc20_.status == 2 ? Math.ceil(_loc20_.cost * 0.5) : _loc20_.cost), + "availability":_loc20_.availability, + "status":_loc20_.status, + "isDiamond":false, + "diamondItem":null, + "diamondCost":0 + }; + } + } + _loc8_++; + } + if(_skippedIndexes[_loc14_]) + { + _loc5_++; + _loc4_++; + _loc14_++; + continue; + } + } + } + } + else + { + _skippedIndexes[_loc14_] = true; + _loc5_++; + } + } + else + { + _skippedIndexes[_loc14_] = true; + _loc5_++; + } + _loc4_++; + _loc14_++; + } + GenericListXtCommManager.requestGenericList(166,onCurrDiamondAvatarStoreList,null,true); + GenericListXtCommManager.requestGenericList(293,onDiamondAvatarListLoaded,null,true); + } + + private static function onCurrDiamondAvatarStoreList(param1:int, param2:Array) : void + { + _currDiamondAvatarStoreDefs = param2.slice(8); + if(_diamondAvatarListData != null) + { + onDiamondAvatarListLoaded(293,_diamondAvatarListData); + } + } + + private static function onDiamondAvatarListLoaded(param1:int, param2:Array) : void + { + var j:int; + var numItems:int; + var diamondItem:DiamondItem; + var avt:Avatar; + var avatarDef:Object; + var avatarRefId:int; + var i:int; + var glId:int = param1; + var cad:Array = param2; + if(_currDiamondAvatarStoreDefs != null) + { + j = 8; + numItems = int(cad[j++]); + i = 0; + while(i < numItems) + { + diamondItem = DiamondXtCommManager.getDiamondItem(int(cad[j++])); + if(diamondItem && (diamondItem.isAvatar || diamondItem.isAvatarCustom)) + { + if(diamondItem.isAvatarCustom) + { + avatarRefId = int(gMainFrame.userInfo.getCustomAvatarDefByAvType(diamondItem.refDefId).avatarRefId); + } + else + { + avatarRefId = diamondItem.refDefId; + } + avt = AvatarUtility._creationAvatars[AvatarUtility.findAvatarIndexByType(avatarRefId,diamondItem.isAvatarCustom ? diamondItem.refDefId : -1)]; + if(avt && (getAvatarDefIsViewable(avt,avt.customAvId != -1) || _currDiamondAvatarStoreDefs.some((function():* + { + var isSame:Function; + return isSame = function(param1:*, param2:int, param3:Array):Boolean + { + return int(param1) == diamondItem.defId; + }; + })()))) + { + avatarDef = findAvDefByType(avt.avTypeId,diamondItem.isAvatarCustom ? diamondItem.refDefId : -1); + avatarDef.diamondItem = diamondItem; + avatarDef.isDiamond = true; + } + } + i = i + 1; + } + if(_onAvatarListLoaded != null) + { + _onAvatarListLoaded(); + _onAvatarListLoaded = null; + } + } + else + { + _diamondAvatarListData = cad; + } + } + + public static function getAvatarDefIsViewable(param1:Avatar, param2:Boolean = false) : Boolean + { + var _loc3_:Number = Number(gMainFrame.userInfo.userVarCache.getUserVarValueById(param2 ? 410 : 287)); + _loc3_ |= 0; + param2 ? _loc3_ : 0; + var _loc4_:int = param2 ? param1.customAvId : param1.avTypeId; + return BitUtility.bitwiseAnd(_loc3_,BitUtility.leftShiftNumbers(_loc4_ - 1)) > 0; + } + + public static function getAvatarDefIsViewableWithAvId(param1:int, param2:int = -1) : Boolean + { + var _loc3_:Number = Number(gMainFrame.userInfo.userVarCache.getUserVarValueById(param2 != -1 ? 410 : 287)); + _loc3_ |= 0; + param2 != -1 ? _loc3_ : 0; + return BitUtility.bitwiseAnd(_loc3_,BitUtility.leftShiftNumbers(param2 != -1 ? param2 - 1 : param1 - 1)) > 0; + } + + public static function generateNew(param1:int, param2:Avatar = null, param3:String = null, param4:int = -1, param5:int = 0, param6:Function = null, param7:Boolean = false, param8:Boolean = false) : Avatar + { + var _loc9_:AvatarInfo = null; + var _loc10_:Avatar = null; + if(param2 == null && _avtMgrGetAvtByPerUserAvId != null) + { + _loc10_ = _avtMgrGetAvtByPerUserAvId(param3,param1); + } + if(!_loc10_) + { + if(param2) + { + _loc10_ = param2; + } + else + { + _loc10_ = new Avatar(); + } + if(_loc10_.userName == null) + { + if(param3 == null) + { + throw new Error("avt and paramUserName are both null!!!"); + } + _loc10_.userName = param3; + } + _loc9_ = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(param3,param1); + if(_loc9_ && _loc9_.uuid != "") + { + _loc10_.init(param1,_loc9_.avInvId,_loc9_.avName,_loc9_.type,_loc9_.colors,_loc9_.customAvId,null,_loc9_.userName,param4,param5); + getAvatarItemData(_loc10_,param6,_loc9_,param8); + } + else + { + _loc10_.init(param1,_loc9_ ? _loc9_.avInvId : -1,"",_loc9_ ? _loc9_.type : -1,[0,0,0],_loc9_ ? _loc9_.customAvId : -1,null,_loc10_.userName,param4); + if(param7 == false) + { + AvatarXtCommManager.requestADForAvatar(param1,true,param6,_loc10_); + } + } + } + return _loc10_; + } + + public static function getAvatarItemData(param1:Avatar, param2:Function = null, param3:AvatarInfo = null, param4:Boolean = false) : void + { + if(param1 == null || param1.perUserAvId < 0) + { + throw new Error("Invalid avatar!"); + } + if(param3 == null) + { + param3 = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(param1.userName,param1.perUserAvId); + if(param3 == null) + { + throw new Error("Invalid avatar or avInfo!"); + } + } + var _loc5_:AccItemCollection = null; + if(param4) + { + _loc5_ = param3.getFullItems(true); + } + else + { + _loc5_ = param3.getItems(true); + } + if(_loc5_ && _loc5_.length > 0 && param1.uuid != "") + { + param1.itemResponseIntegrate(_loc5_,param4); + } + else if(param1.uuid != "") + { + ItemXtCommManager.requestItemListForAvatar(null,param1,param1.userName.toLowerCase() == gMainFrame.userInfo.myUserName.toLowerCase() ? !ItemXtCommManager.hasRequestedFullItemList : false); + } + else + { + AvatarXtCommManager.requestADForAvatar(param1.perUserAvId,true,param2,param1,param4); + } + } + + public static function layerArrayForItemsAndColors(param1:AccItemCollection, param2:Array, param3:int, param4:int, param5:Boolean = false) : Array + { + var _loc7_:Object = null; + var _loc6_:* = 0; + var _loc8_:Array = []; + if(param1) + { + for each(var _loc9_:Item in param1.getCoreArray()) + { + if((_loc9_.layerId <= 3 || (param5 || _loc9_.enviroType == param4 || _loc9_.isLandAndOcean)) && _loc9_.getInUse(param3)) + { + if(_loc9_.layerId == 1) + { + _loc6_ = uint(param2[0]); + } + else if(_loc9_.layerId == 2) + { + _loc6_ = uint(param2[1]); + } + else if(_loc9_.layerId == 3) + { + _loc6_ = uint(param2[2]); + } + else + { + _loc6_ = _loc9_.color; + } + // "d": the item, for a custom one's own picture (LayerAnim, LayerBitmap) + _loc7_ = { + "l":_loc9_.accId, + "c":_loc6_, + "d":_loc9_.defId + }; + _loc8_.push(_loc7_); + } + } + } + return _loc8_; + } + + public static function getAvatarByIndex(param1:int) : Avatar + { + return _creationAvatars[param1]; + } + + public static function getAvatarDefByIndex(param1:int) : Object + { + if(_avatarDefInfo) + { + return _avatarDefInfo[param1]; + } + return null; + } + + public static function get numAvatarDefs() : int + { + if(_avatarDefInfo) + { + return _avatarDefInfo.length; + } + return 0; + } + + public static function get creationAvatarsList() : Array + { + return _creationAvatars; + } + + public static function findCreationAvatarByType(param1:int, param2:int) : Avatar + { + var _loc3_:int = 0; + _loc3_ = 0; + while(_loc3_ < _creationAvatars.length) + { + if(_creationAvatars[_loc3_] && _creationAvatars[_loc3_].avTypeId == param1 && _creationAvatars[_loc3_].customAvId == param2) + { + return _creationAvatars[_loc3_]; + } + _loc3_++; + } + return null; + } + + public static function findAvatarIndexByType(param1:int, param2:int) : int + { + var _loc3_:int = 0; + _loc3_ = 0; + while(_loc3_ < _creationAvatars.length) + { + if(_creationAvatars[_loc3_] && _creationAvatars[_loc3_].avTypeId == param1 && _creationAvatars[_loc3_].customAvId == param2) + { + return _loc3_; + } + _loc3_++; + } + return -1; + } + + public static function findAvDefByType(param1:int, param2:int) : Object + { + var _loc3_:int = findAvatarIndexByType(param1,param2); + if(_loc3_ != -1) + { + return _avatarDefInfo[_loc3_]; + } + return null; + } + + public static function numNonMemberAvatars() : int + { + if(_numNonMemberAvatars != null) + { + return _numNonMemberAvatars(); + } + return 0; + } + + private static function nameTypeScreenMouseDownHandler(param1:MouseEvent) : void + { + param1.stopPropagation(); + } + + public static function getAvatarHudPosition(param1:int) : Point + { + var _loc2_:Number = NaN; + var _loc3_:Number = NaN; + switch(param1) + { + case 1: + _loc3_ = 228; + _loc2_ = 220; + break; + case 2: + _loc3_ = 213; + _loc2_ = 318; + break; + case 35: + _loc3_ = 213; + _loc2_ = 308; + break; + case 4: + _loc3_ = 226; + _loc2_ = 217; + break; + case 5: + _loc3_ = 228; + _loc2_ = 220; + break; + case 6: + _loc3_ = 225; + _loc2_ = 215; + break; + case 7: + _loc3_ = 228; + _loc2_ = 216; + break; + case 8: + _loc3_ = 231; + _loc2_ = 216; + break; + case 13: + _loc3_ = 230; + _loc2_ = 216; + break; + case 15: + _loc3_ = 222; + _loc2_ = 216; + break; + case 16: + _loc3_ = 230; + _loc2_ = 216; + break; + case 18: + _loc3_ = 222; + _loc2_ = 213; + break; + case 19: + _loc3_ = 216; + _loc2_ = 250; + break; + case 20: + _loc3_ = 222; + _loc2_ = 245; + break; + case 17: + _loc3_ = 232; + _loc2_ = 216; + break; + case 23: + _loc3_ = 232; + _loc2_ = 220; + break; + case 22: + _loc3_ = 225; + _loc2_ = 237; + break; + case 24: + _loc3_ = 223; + _loc2_ = 217; + break; + case 21: + _loc3_ = 221; + _loc2_ = 249; + break; + case 26: + _loc3_ = 220; + _loc2_ = 215; + break; + case 25: + _loc3_ = 216; + _loc2_ = 218; + break; + case 28: + _loc3_ = 222; + _loc2_ = 222; + break; + case 29: + _loc3_ = 220; + _loc2_ = 223; + break; + case 30: + _loc3_ = 220; + _loc2_ = 212; + break; + case 31: + _loc3_ = 220; + _loc2_ = 215; + break; + case 27: + _loc3_ = 220; + _loc2_ = 212; + break; + case 3: + _loc3_ = 225; + _loc2_ = 220; + break; + case 9: + _loc3_ = 225; + _loc2_ = 220; + break; + case 10: + _loc3_ = 227; + _loc2_ = 220; + break; + case 11: + _loc3_ = 221; + _loc2_ = 218; + break; + case 12: + _loc3_ = 221; + _loc2_ = 218; + break; + case 14: + _loc3_ = 221; + _loc2_ = 215; + break; + case 32: + case 33: + _loc3_ = 224; + _loc2_ = 218; + break; + case 34: + _loc3_ = 224; + _loc2_ = 215; + break; + case 36: + _loc3_ = 224; + _loc2_ = 220; + break; + case 37: + _loc3_ = 219; + _loc2_ = 209; + break; + case 38: + _loc3_ = 219; + _loc2_ = 238; + break; + case 39: + _loc3_ = 240; + _loc2_ = 340; + break; + case 40: + _loc3_ = 235; + _loc2_ = 215; + break; + case 41: + case 42: + _loc3_ = 219; + _loc2_ = 219; + break; + case 43: + _loc3_ = 235; + _loc2_ = 216; + break; + case 44: + _loc3_ = 220; + _loc2_ = 214; + break; + case 45: + _loc3_ = 230; + _loc2_ = 310; + break; + case 46: + _loc3_ = 225; + _loc2_ = 305; + break; + case 47: + _loc3_ = 229; + _loc2_ = 305; + break; + case 49: + _loc3_ = 225; + _loc2_ = 350; + break; + case 48: + _loc3_ = 232; + _loc2_ = 215; + break; + case 50: + _loc3_ = 227; + _loc2_ = 215; + break; + case 51: + _loc3_ = 227; + _loc2_ = 217; + break; + case 52: + _loc3_ = 230; + _loc2_ = 219; + break; + case 53: + _loc3_ = 235; + _loc2_ = 215; + break; + default: + _loc3_ = 225; + _loc2_ = 200; + } + return new Point(_loc3_,_loc2_); + } + + public static function getAvatarViewPosition(param1:int) : Point + { + var _loc2_:Point = new Point(); + switch(param1) + { + case 1: + _loc2_.x = 137; + _loc2_.y = 85; + break; + case 2: + _loc2_.x = 120; + _loc2_.y = 150; + break; + case 35: + _loc2_.x = 120; + _loc2_.y = 140; + break; + case 4: + _loc2_.x = 136; + _loc2_.y = 85; + break; + case 5: + _loc2_.x = 133; + _loc2_.y = 85; + break; + case 6: + _loc2_.x = 131; + _loc2_.y = 90; + break; + case 7: + _loc2_.x = 136; + _loc2_.y = 95; + break; + case 8: + _loc2_.x = 140; + _loc2_.y = 85; + break; + case 13: + _loc2_.x = 125; + _loc2_.y = 95; + break; + case 15: + _loc2_.x = 127; + _loc2_.y = 130; + break; + case 16: + _loc2_.x = 134; + _loc2_.y = 80; + break; + case 18: + _loc2_.x = 131; + _loc2_.y = 75; + break; + case 19: + _loc2_.x = 125; + _loc2_.y = 90; + break; + case 20: + _loc2_.x = 127; + _loc2_.y = 120; + break; + case 17: + _loc2_.x = 140; + _loc2_.y = 100; + break; + case 23: + _loc2_.x = 130; + _loc2_.y = 100; + break; + case 22: + _loc2_.x = 125; + _loc2_.y = 117; + break; + case 24: + _loc2_.x = 129; + _loc2_.y = 95; + break; + case 21: + _loc2_.x = 128; + _loc2_.y = 95; + break; + case 26: + _loc2_.x = 124; + _loc2_.y = 110; + break; + case 25: + _loc2_.x = 123; + _loc2_.y = 115; + break; + case 28: + _loc2_.x = 129; + _loc2_.y = 99; + break; + case 29: + _loc2_.x = 127; + _loc2_.y = 115; + break; + case 30: + _loc2_.x = 127; + _loc2_.y = 115; + break; + case 31: + _loc2_.x = 127; + _loc2_.y = 115; + break; + case 27: + _loc2_.x = 127; + _loc2_.y = 110; + break; + case 3: + _loc2_.x = 130; + _loc2_.y = 100; + break; + case 9: + _loc2_.x = 140; + _loc2_.y = 100; + break; + case 10: + _loc2_.x = 134; + _loc2_.y = 97; + break; + case 11: + _loc2_.x = 130; + _loc2_.y = 97; + break; + case 12: + _loc2_.x = 127; + _loc2_.y = 90; + break; + case 14: + case 34: + _loc2_.x = 127; + _loc2_.y = 90; + break; + case 32: + case 33: + _loc2_.x = 130; + _loc2_.y = 115; + break; + case 36: + _loc2_.x = 125; + _loc2_.y = 95; + break; + case 37: + _loc2_.x = 125; + _loc2_.y = 90; + break; + case 38: + _loc2_.x = 128; + _loc2_.y = 110; + break; + case 39: + _loc2_.x = 135; + _loc2_.y = 225; + break; + case 40: + _loc2_.x = 145; + _loc2_.y = 80; + break; + case 41: + case 42: + _loc2_.x = 115; + _loc2_.y = 95; + break; + case 43: + _loc2_.x = 140; + _loc2_.y = 115; + break; + case 44: + _loc2_.x = 135; + _loc2_.y = 105; + break; + case 45: + _loc2_.x = 135; + _loc2_.y = 165; + break; + case 46: + _loc2_.x = 130; + _loc2_.y = 175; + break; + case 47: + _loc2_.x = 135; + _loc2_.y = 185; + break; + case 49: + _loc2_.x = 125; + _loc2_.y = 220; + break; + case 48: + _loc2_.x = 135; + _loc2_.y = 120; + break; + case 50: + _loc2_.x = 125; + _loc2_.y = 100; + break; + case 51: + _loc2_.x = 127; + _loc2_.y = 110; + break; + case 52: + _loc2_.x = 135; + _loc2_.y = 105; + break; + case 53: + _loc2_.x = 155; + _loc2_.y = 100; + break; + default: + _loc2_.x = 112; + _loc2_.y = 140; + } + return _loc2_; + } + + public static function getAvatarChatOffset(param1:int) : Point + { + var _loc2_:Point = new Point(); + if(GuiManager.isBeYourPetRoom()) + { + if(AvatarManager.playerAvatarWorldView) + { + _loc2_.x = 10; + _loc2_.y = -80; + } + else + { + _loc2_.x = 10; + _loc2_.y = -90; + } + } + else + { + switch(param1) + { + case 1: + _loc2_.x = 10; + _loc2_.y = -70; + break; + case 2: + _loc2_.x = 10; + _loc2_.y = -130; + break; + case 35: + _loc2_.x = 0; + _loc2_.y = -110; + break; + case 4: + _loc2_.x = 5; + _loc2_.y = -80; + break; + case 5: + _loc2_.x = -25; + _loc2_.y = -75; + break; + case 6: + _loc2_.x = -15; + _loc2_.y = -85; + break; + case 7: + _loc2_.x = -25; + _loc2_.y = -75; + break; + case 8: + _loc2_.x = -25; + _loc2_.y = -75; + break; + case 13: + _loc2_.x = -10; + _loc2_.y = -95; + break; + case 15: + _loc2_.x = -10; + _loc2_.y = -90; + break; + case 16: + _loc2_.x = -10; + _loc2_.y = -105; + break; + case 18: + _loc2_.x = -15; + _loc2_.y = -60; + break; + case 19: + _loc2_.x = -10; + _loc2_.y = -95; + break; + case 20: + _loc2_.x = -15; + _loc2_.y = -88; + break; + case 17: + _loc2_.x = -15; + _loc2_.y = -90; + break; + case 23: + _loc2_.x = -20; + _loc2_.y = -104; + break; + case 22: + _loc2_.x = -10; + _loc2_.y = -75; + break; + case 24: + _loc2_.x = -16; + _loc2_.y = -95; + break; + case 21: + _loc2_.x = -25; + _loc2_.y = -95; + break; + case 26: + _loc2_.x = -17; + _loc2_.y = -130; + break; + case 25: + _loc2_.x = -17; + _loc2_.y = -88; + break; + case 28: + _loc2_.x = -7; + _loc2_.y = -113; + break; + case 29: + _loc2_.x = -7; + _loc2_.y = -99; + break; + case 30: + _loc2_.x = -2; + _loc2_.y = -58; + break; + case 31: + _loc2_.x = 0; + _loc2_.y = -80; + break; + case 27: + _loc2_.x = -2; + _loc2_.y = -95; + break; + case 3: + _loc2_.x = -2; + _loc2_.y = -135; + break; + case 9: + _loc2_.x = -5; + _loc2_.y = -85; + break; + case 10: + _loc2_.x = -10; + _loc2_.y = -83; + break; + case 11: + _loc2_.x = -5; + _loc2_.y = -100; + break; + case 12: + _loc2_.x = -10; + _loc2_.y = -120; + break; + case 14: + _loc2_.x = -2; + _loc2_.y = -115; + break; + case 32: + case 33: + case 34: + _loc2_.x = -8; + _loc2_.y = -83; + break; + case 36: + _loc2_.x = -8; + _loc2_.y = -70; + break; + case 37: + case 38: + _loc2_.x = -8; + _loc2_.y = -73; + break; + case 39: + _loc2_.x = -20; + _loc2_.y = -110; + break; + case 40: + _loc2_.x = -28; + _loc2_.y = -85; + break; + case 41: + _loc2_.x = -5; + _loc2_.y = -110; + break; + case 42: + _loc2_.x = -20; + _loc2_.y = -110; + break; + case 43: + _loc2_.x = -20; + _loc2_.y = -110; + break; + case 44: + _loc2_.x = -10; + _loc2_.y = -90; + break; + case 45: + _loc2_.x = -10; + _loc2_.y = -115; + break; + case 46: + _loc2_.x = -5; + _loc2_.y = -85; + break; + case 47: + _loc2_.x = -5; + _loc2_.y = -95; + break; + case 49: + _loc2_.x = -5; + _loc2_.y = -155; + break; + case 48: + _loc2_.x = -10; + _loc2_.y = -65; + break; + case 51: + case 52: + case 53: + _loc2_.x = -10; + _loc2_.y = -110; + break; + case 50: + default: + _loc2_.x = -25; + _loc2_.y = -75; + } + } + return _loc2_; + } + + public static function getAvatarEmoteBgOffset(param1:int) : Point + { + var _loc2_:Point = new Point(); + if(GuiManager.isBeYourPetRoom()) + { + if(AvatarManager.playerAvatarWorldView) + { + _loc2_.x = -5; + _loc2_.y = -25; + } + else + { + _loc2_.x = -5; + _loc2_.y = -35; + } + } + else + { + switch(param1) + { + case 1: + _loc2_.x = -5; + _loc2_.y = -30; + break; + case 2: + _loc2_.x = -5; + _loc2_.y = -35; + break; + case 35: + _loc2_.x = -15; + _loc2_.y = -23; + break; + case 4: + _loc2_.x = -5; + _loc2_.y = -45; + break; + case 5: + _loc2_.x = 8; + _loc2_.y = -40; + break; + case 6: + _loc2_.x = 5; + _loc2_.y = -35; + break; + case 7: + _loc2_.x = -5; + _loc2_.y = -35; + break; + case 8: + _loc2_.x = -5; + _loc2_.y = -35; + break; + case 13: + _loc2_.x = -10; + _loc2_.y = -25; + break; + case 15: + _loc2_.x = 5; + _loc2_.y = -15; + break; + case 16: + _loc2_.x = 5; + _loc2_.y = -35; + break; + case 18: + _loc2_.x = 0; + _loc2_.y = -30; + break; + case 19: + _loc2_.x = 0; + _loc2_.y = -20; + break; + case 20: + _loc2_.x = 0; + _loc2_.y = -30; + break; + case 17: + _loc2_.x = 0; + _loc2_.y = -45; + break; + case 23: + _loc2_.x = 5; + _loc2_.y = -37; + break; + case 22: + case 24: + _loc2_.x = 0; + _loc2_.y = -30; + break; + case 21: + _loc2_.x = -5; + _loc2_.y = -55; + break; + case 26: + _loc2_.x = 5; + _loc2_.y = -42; + break; + case 25: + _loc2_.x = 10; + _loc2_.y = -33; + break; + case 28: + _loc2_.x = -1; + _loc2_.y = -35; + break; + case 29: + _loc2_.x = -1; + _loc2_.y = -15; + break; + case 30: + _loc2_.x = -8; + _loc2_.y = -24; + break; + case 31: + _loc2_.x = -6; + _loc2_.y = -30; + break; + case 27: + _loc2_.x = -8; + _loc2_.y = -28; + break; + case 3: + _loc2_.x = -8; + _loc2_.y = -30; + break; + case 9: + _loc2_.x = -5; + _loc2_.y = -33; + break; + case 10: + _loc2_.x = -10; + _loc2_.y = -33; + break; + case 11: + _loc2_.x = -10; + _loc2_.y = -33; + break; + case 12: + _loc2_.x = -10; + _loc2_.y = -40; + break; + case 14: + _loc2_.x = -2; + _loc2_.y = -33; + break; + case 32: + case 33: + case 34: + _loc2_.x = -10; + _loc2_.y = -28; + break; + case 36: + _loc2_.x = -10; + _loc2_.y = -35; + break; + case 37: + case 38: + _loc2_.x = -5; + _loc2_.y = -39; + break; + case 39: + _loc2_.x = -10; + _loc2_.y = -40; + break; + case 40: + _loc2_.x = -15; + _loc2_.y = -35; + break; + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + case 49: + case 48: + case 50: + case 51: + case 52: + case 53: + _loc2_.x = -5; + _loc2_.y = -35; + break; + case 49: + _loc2_.x = -5; + _loc2_.y = -80; + break; + default: + _loc2_.x = -5; + _loc2_.y = -45; + } + } + return _loc2_; + } + + public static function getAnimalItemWindowOffset(param1:int) : Point + { + var _loc2_:Point = new Point(); + switch(param1) + { + case 1: + _loc2_.x = 123; + _loc2_.y = 34; + break; + case 2: + _loc2_.x = 90; + _loc2_.y = 135; + break; + case 35: + _loc2_.x = 104; + _loc2_.y = 125; + break; + case 4: + _loc2_.x = 134; + _loc2_.y = 45; + break; + case 5: + _loc2_.x = 127; + _loc2_.y = 58; + break; + case 6: + _loc2_.x = 124; + _loc2_.y = 50; + break; + case 7: + _loc2_.x = 133; + _loc2_.y = 54; + break; + case 8: + _loc2_.x = 138; + _loc2_.y = 65; + break; + case 13: + _loc2_.x = 120; + _loc2_.y = 85; + break; + case 15: + _loc2_.x = 133; + _loc2_.y = 85; + break; + case 16: + _loc2_.x = 125; + _loc2_.y = 52; + break; + case 18: + _loc2_.x = 127; + _loc2_.y = 38; + break; + case 19: + _loc2_.x = 125; + _loc2_.y = 75; + break; + case 20: + _loc2_.x = 128; + _loc2_.y = 80; + break; + case 17: + _loc2_.x = 135; + _loc2_.y = 60; + break; + case 23: + _loc2_.x = 135; + _loc2_.y = 75; + break; + case 22: + _loc2_.x = 120; + _loc2_.y = 67; + break; + case 24: + _loc2_.x = 127; + _loc2_.y = 62; + break; + case 21: + case 36: + _loc2_.x = 122; + _loc2_.y = 62; + break; + case 26: + _loc2_.x = 122; + _loc2_.y = 78; + break; + case 25: + case 10: + _loc2_.x = 127; + _loc2_.y = 72; + break; + case 28: + _loc2_.x = 127; + _loc2_.y = 90; + break; + case 29: + _loc2_.x = 127; + _loc2_.y = 90; + break; + case 30: + _loc2_.x = 114; + _loc2_.y = 98; + break; + case 31: + _loc2_.x = 122; + _loc2_.y = 70; + break; + case 27: + _loc2_.x = 128; + _loc2_.y = 65; + break; + case 3: + _loc2_.x = 132; + _loc2_.y = 70; + break; + case 9: + _loc2_.x = 145; + _loc2_.y = 70; + break; + case 11: + _loc2_.x = 125; + _loc2_.y = 68; + break; + case 12: + _loc2_.x = 130; + _loc2_.y = 77; + break; + case 14: + case 34: + _loc2_.x = 122; + _loc2_.y = 68; + break; + case 32: + case 33: + _loc2_.x = 120; + _loc2_.y = 90; + break; + case 37: + _loc2_.x = 125; + _loc2_.y = 60; + break; + case 38: + _loc2_.x = 130; + _loc2_.y = 90; + break; + case 39: + _loc2_.x = 132; + _loc2_.y = 180; + break; + case 40: + _loc2_.x = 142; + _loc2_.y = 65; + break; + case 41: + _loc2_.x = 115; + _loc2_.y = 65; + break; + case 42: + _loc2_.x = 130; + _loc2_.y = 65; + break; + case 43: + _loc2_.x = 145; + _loc2_.y = 90; + break; + case 44: + _loc2_.x = 135; + _loc2_.y = 80; + break; + case 45: + _loc2_.x = 138; + _loc2_.y = 150; + break; + case 46: + _loc2_.x = 130; + _loc2_.y = 145; + break; + case 47: + _loc2_.x = 140; + _loc2_.y = 160; + break; + case 49: + _loc2_.x = 130; + _loc2_.y = 195; + break; + case 48: + _loc2_.x = 140; + _loc2_.y = 100; + break; + case 50: + _loc2_.x = 120; + _loc2_.y = 80; + break; + case 51: + _loc2_.x = 140; + _loc2_.y = 95; + break; + case 52: + _loc2_.x = 145; + _loc2_.y = 75; + break; + case 53: + _loc2_.x = 165; + _loc2_.y = 85; + break; + default: + _loc2_.x = 120; + _loc2_.y = 50; + } + return _loc2_; + } + + public static function getTalkingHeadOffset(param1:int) : Point + { + var _loc2_:Point = new Point(); + var _loc3_:int = param1; + _loc2_.x = 112; + _loc2_.y = 140; + return _loc2_; + } + + public static function getAvatarPhotoOffset(param1:int) : Point + { + var _loc2_:Point = new Point(); + switch(param1) + { + case 1: + _loc2_.x = -150; + _loc2_.y = -160; + break; + case 2: + _loc2_.x = -195; + _loc2_.y = -60; + break; + case 35: + _loc2_.x = -155; + _loc2_.y = -95; + break; + case 4: + _loc2_.x = -155; + _loc2_.y = -190; + break; + case 5: + _loc2_.x = -152; + _loc2_.y = -140; + break; + case 6: + _loc2_.x = -130; + _loc2_.y = -158; + break; + case 7: + _loc2_.x = -140; + _loc2_.y = -175; + break; + case 8: + _loc2_.x = -145; + _loc2_.y = -192; + break; + case 13: + _loc2_.x = -160; + _loc2_.y = -155; + break; + case 15: + _loc2_.x = -165; + _loc2_.y = -125; + break; + case 16: + _loc2_.x = -162; + _loc2_.y = -148; + break; + case 18: + _loc2_.x = -107; + _loc2_.y = -140; + break; + case 19: + _loc2_.x = -160; + _loc2_.y = -190; + break; + case 20: + _loc2_.x = -160; + _loc2_.y = -190; + break; + case 17: + _loc2_.x = -155; + _loc2_.y = -150; + break; + case 23: + _loc2_.x = -130; + _loc2_.y = -185; + break; + case 22: + _loc2_.x = -160; + _loc2_.y = -190; + break; + case 24: + _loc2_.x = -162; + _loc2_.y = -180; + break; + case 21: + _loc2_.x = -160; + _loc2_.y = -190; + break; + case 26: + _loc2_.x = -140; + _loc2_.y = -160; + break; + case 25: + _loc2_.x = -165; + _loc2_.y = -175; + break; + case 28: + _loc2_.x = -150; + _loc2_.y = -165; + break; + case 29: + _loc2_.x = -145; + _loc2_.y = -180; + break; + case 30: + _loc2_.x = -140; + _loc2_.y = -165; + break; + case 31: + _loc2_.x = -135; + _loc2_.y = -145; + break; + case 27: + _loc2_.x = -145; + _loc2_.y = -160; + break; + case 3: + _loc2_.x = -145; + _loc2_.y = -160; + break; + case 9: + _loc2_.x = -130; + _loc2_.y = -130; + break; + case 10: + _loc2_.x = -125; + _loc2_.y = -175; + break; + case 11: + _loc2_.x = -125; + _loc2_.y = -155; + break; + case 12: + _loc2_.x = -135; + _loc2_.y = -100; + break; + case 14: + _loc2_.x = -165; + _loc2_.y = -175; + break; + case 32: + _loc2_.x = -150; + _loc2_.y = -135; + break; + case 33: + _loc2_.x = -120; + _loc2_.y = -115; + break; + case 34: + _loc2_.x = -145; + _loc2_.y = -190; + break; + case 36: + _loc2_.x = -160; + _loc2_.y = -178; + break; + case 37: + _loc2_.x = -152; + _loc2_.y = -130; + break; + case 38: + _loc2_.x = -145; + _loc2_.y = -150; + break; + case 39: + _loc2_.x = -150; + _loc2_.y = -75; + break; + case 40: + _loc2_.x = -125; + _loc2_.y = -150; + break; + case 41: + _loc2_.x = -147; + _loc2_.y = -115; + break; + case 42: + _loc2_.x = -135; + _loc2_.y = -135; + break; + case 43: + _loc2_.x = -135; + _loc2_.y = -170; + break; + case 44: + _loc2_.x = -105; + _loc2_.y = -115; + break; + case 45: + _loc2_.x = -135; + _loc2_.y = -80; + break; + case 46: + _loc2_.x = -140; + _loc2_.y = -60; + break; + case 47: + _loc2_.x = -140; + _loc2_.y = -75; + break; + case 49: + _loc2_.x = -105; + _loc2_.y = -65; + break; + case 48: + _loc2_.x = -175; + _loc2_.y = -95; + break; + case 50: + _loc2_.x = -135; + _loc2_.y = -145; + break; + case 51: + _loc2_.x = -120; + _loc2_.y = -143; + break; + case 52: + _loc2_.x = -145; + _loc2_.y = -159; + break; + case 53: + _loc2_.x = -90; + _loc2_.y = -183; + break; + default: + _loc2_.x = -160; + _loc2_.y = -190; + } + return _loc2_; + } + + public static function getAvatarMinigameLobbyOffset(param1:int) : Point + { + var _loc2_:Point = new Point(0,0); + switch(param1) + { + case 1: + case 4: + _loc2_.x = 160; + _loc2_.y = 152; + break; + case 2: + _loc2_.x = 150; + _loc2_.y = 220; + break; + case 35: + _loc2_.x = 150; + _loc2_.y = 215; + break; + case 5: + case 6: + _loc2_.x = 158; + _loc2_.y = 152; + break; + case 7: + _loc2_.x = 157; + _loc2_.y = 148; + break; + case 8: + _loc2_.x = 162; + _loc2_.y = 149; + break; + case 13: + case 16: + case 15: + _loc2_.x = 160; + _loc2_.y = 152; + break; + case 22: + _loc2_.x = 155; + _loc2_.y = 165; + break; + case 18: + _loc2_.x = 153; + _loc2_.y = 150; + break; + case 19: + _loc2_.x = 148; + _loc2_.y = 173; + break; + case 20: + _loc2_.x = 153; + _loc2_.y = 170; + break; + case 17: + case 23: + _loc2_.x = 162; + _loc2_.y = 152; + break; + case 24: + _loc2_.x = 155; + _loc2_.y = 152; + break; + case 26: + _loc2_.x = 155; + _loc2_.y = 150; + break; + case 25: + _loc2_.x = 153; + _loc2_.y = 152; + break; + case 28: + _loc2_.x = 155; + _loc2_.y = 152; + break; + case 29: + _loc2_.x = 155; + _loc2_.y = 155; + break; + case 30: + _loc2_.x = 152; + _loc2_.y = 155; + break; + case 31: + _loc2_.x = 154; + _loc2_.y = 148; + break; + case 27: + _loc2_.x = 152; + _loc2_.y = 155; + break; + case 3: + case 9: + _loc2_.x = 158; + _loc2_.y = 155; + break; + case 21: + _loc2_.x = 153; + _loc2_.y = 172; + break; + case 10: + _loc2_.x = 159; + _loc2_.y = 150; + break; + case 11: + _loc2_.x = 152; + _loc2_.y = 152; + break; + case 12: + _loc2_.x = 156; + _loc2_.y = 156; + break; + case 14: + _loc2_.x = 153; + _loc2_.y = 153; + break; + case 32: + case 33: + _loc2_.x = 158; + _loc2_.y = 152; + break; + case 34: + _loc2_.x = 158; + _loc2_.y = 147; + break; + case 36: + _loc2_.x = 156; + _loc2_.y = 155; + break; + case 37: + _loc2_.x = 153; + _loc2_.y = 148; + break; + case 38: + _loc2_.x = 154; + _loc2_.y = 165; + break; + case 39: + _loc2_.x = 170; + _loc2_.y = 235; + break; + case 40: + _loc2_.x = 165; + _loc2_.y = 147; + break; + case 41: + case 42: + _loc2_.x = 154; + _loc2_.y = 151; + break; + case 43: + _loc2_.x = 167; + _loc2_.y = 149; + break; + case 44: + _loc2_.x = 152; + _loc2_.y = 147; + break; + case 45: + _loc2_.x = 157; + _loc2_.y = 215; + break; + case 46: + _loc2_.x = 157; + _loc2_.y = 210; + break; + case 47: + _loc2_.x = 159; + _loc2_.y = 210; + break; + case 49: + _loc2_.x = 157; + _loc2_.y = 245; + break; + case 48: + _loc2_.x = 162; + _loc2_.y = 148; + break; + case 50: + _loc2_.x = 158; + _loc2_.y = 148; + break; + case 51: + _loc2_.x = 158; + _loc2_.y = 150; + break; + case 52: + _loc2_.x = 159; + _loc2_.y = 151; + break; + case 53: + _loc2_.x = 163; + _loc2_.y = 148; + break; + default: + _loc2_.x = 160; + _loc2_.y = 152; + } + return _loc2_; + } + + public static function getAvOffsetByDefId(param1:int) : Point + { + switch(param1) + { + case 1: + return new Point(120,35); + case 2: + return new Point(92,140); + case 35: + return new Point(105,130); + case 4: + return new Point(134,54); + case 5: + return new Point(125,58); + case 6: + return new Point(125,55); + case 7: + return new Point(138,50); + case 8: + return new Point(130,72); + case 13: + return new Point(120,88); + case 15: + return new Point(134,90); + case 16: + return new Point(125,53); + case 18: + return new Point(128,41); + case 19: + return new Point(125,80); + case 20: + return new Point(128,85); + case 17: + return new Point(138,60); + case 23: + return new Point(132,80); + case 22: + return new Point(122,70); + case 24: + return new Point(125,60); + case 26: + return new Point(125,79); + case 21: + return new Point(122,65); + case 25: + return new Point(126,75); + case 28: + return new Point(126,92); + case 29: + return new Point(130,110); + case 30: + return new Point(110,105); + case 31: + return new Point(121,70); + case 27: + case 34: + break; + case 3: + return new Point(135,75); + case 9: + return new Point(145,75); + case 10: + return new Point(130,72); + case 11: + return new Point(125,72); + case 12: + return new Point(132,75); + case 14: + return new Point(125,72); + case 32: + case 33: + return new Point(125,87); + case 36: + return new Point(122,55); + case 37: + return new Point(122,55); + case 38: + return new Point(130,95); + case 39: + return new Point(130,175); + case 40: + return new Point(140,60); + case 41: + return new Point(115,60); + case 42: + return new Point(130,60); + case 43: + return new Point(145,85); + case 44: + return new Point(140,75); + case 45: + return new Point(135,150); + case 46: + return new Point(130,145); + case 47: + return new Point(140,165); + case 49: + return new Point(125,195); + case 48: + return new Point(145,100); + case 50: + return new Point(115,80); + case 51: + return new Point(140,80); + case 52: + return new Point(145,80); + case 53: + return new Point(155,85); + default: + return new Point(115,110); + } + return new Point(125,65); + } + + public static function isAvatarActive(param1:int) : Boolean + { + if(param1 > 0) + { + return true; + } + return false; + } + + public static function isEndangered(param1:int) : Boolean + { + if(param1 == 2) + { + return true; + } + return false; + } + + public static function isExtinct(param1:int) : Boolean + { + if(param1 == 3) + { + return true; + } + return false; + } + } +} + diff --git a/swf-src/AvatarView.as b/swf-src/AvatarView.as new file mode 100644 index 0000000..1ad0599 --- /dev/null +++ b/swf-src/AvatarView.as @@ -0,0 +1,380 @@ +package avatar +{ + import collection.AccItemCollection; + import com.sbi.graphics.LayerAnim; + import flash.display.Sprite; + import flash.filters.ColorMatrixFilter; + import item.Item; + + public class AvatarView extends Sprite + { + + protected var _layerAnim:LayerAnim; + + protected var _avatar:Avatar; + + protected var _skipAnimEnviroCheck:Boolean; + + public var avTypeChangedCallback:Function; + + public var onAvatarChangedCallback:Function; + + private var _isOffScreen:Boolean; + + private var _holdAnimId:int; + + private var _lastAnimToHappen:int; + + public function AvatarView() + { + super(); + } + + public function set lastAnimToHappen(param1:int) : void + { + _lastAnimToHappen = param1; + } + + public function get lastAnimToHappen() : int + { + return _lastAnimToHappen; + } + + public function set holdAnimId(param1:int) : void + { + _holdAnimId = param1; + } + + public function init(param1:Avatar, param2:Function = null, param3:Function = null, param4:Boolean = false, param5:Boolean = false) : void + { + _holdAnimId = 0; + _avatar = param1; + _avatar.addEventListener("OnAvatarChanged",avatarChanged,false,0,true); + avTypeChangedCallback = param2; + onAvatarChangedCallback = param3; + _skipAnimEnviroCheck = param5; + _layerAnim = LayerAnim.getNew(param4); + _layerAnim.avDefId = _avatar.avTypeId; + if(_avatar.colors) + { + _layerAnim.layers = setLayerHelper(); + } + this.addChild(_layerAnim.bitmap); + } + + public function destroy(param1:Boolean = false) : void + { + if(param1 && _avatar) + { + _avatar.removeEventListener("OnAvatarChanged",avatarChanged); + _avatar.destroy(); + _avatar = null; + } + avTypeChangedCallback = null; + onAvatarChangedCallback = null; + LayerAnim.destroy(_layerAnim); + _layerAnim = null; + } + + public function resetAvatar(param1:Avatar) : void + { + if(_avatar && _avatar.hasEventListener("OnAvatarChanged")) + { + _avatar.removeEventListener("OnAvatarChanged",avatarChanged); + } + _avatar = param1; + _avatar.addEventListener("OnAvatarChanged",avatarChanged,false,0,true); + if(_layerAnim) + { + _layerAnim.avDefId = _avatar.avTypeId; + if(_avatar.colors) + { + _layerAnim.layers = setLayerHelper(); + } + } + } + + public function isValid() : Boolean + { + return _layerAnim != null; + } + + public function hideAvatar() : void + { + if(_layerAnim != null) + { + _layerAnim.visible = false; + } + } + + public function showAvatar() : void + { + if(_layerAnim != null) + { + _layerAnim.visible = true; + } + } + + public function set isOffScreen(param1:Boolean) : void + { + _isOffScreen = param1; + } + + public function get isOffScreen() : Boolean + { + return _isOffScreen; + } + + public function pauseAnim(param1:Boolean) : void + { + _layerAnim.pause = param1; + } + + public function advanceFrame() : void + { + _layerAnim.frame++; + } + + public function get frame() : int + { + return _layerAnim.frame; + } + + public function set frame(param1:int) : void + { + _layerAnim.frame = param1; + } + + public function get flip() : Boolean + { + return _layerAnim.hFlip; + } + + public function get animId() : int + { + return _layerAnim.animId; + } + + protected function avatarChanged(param1:AvatarEvent) : void + { + if(_layerAnim) + { + if(_layerAnim.avDefId != _avatar.avTypeId) + { + _layerAnim.avDefId = _avatar.avTypeId; + if(avTypeChangedCallback != null) + { + avTypeChangedCallback(this); + } + } + _layerAnim.layers = setLayerHelper(); + if(onAvatarChangedCallback != null) + { + onAvatarChangedCallback(this); + } + } + } + + protected function setLayerHelper() : Array + { + var _loc1_:AvatarInfo = null; + var _loc2_:AccItemCollection = null; + var _loc3_:* = null; + if(_avatar.inventoryBodyMod && _avatar.inventoryBodyMod.itemCollection && _avatar.inventoryBodyMod.itemCollection.length >= 1) + { + _loc3_ = new AccItemCollection(_avatar.inventoryBodyMod.itemCollection.concatCollection(_avatar.inventoryClothing.itemCollection)); + } + else + { + _loc1_ = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_avatar.userName,_avatar.perUserAvId); + if(_loc1_) + { + _loc2_ = _skipAnimEnviroCheck ? _loc1_.getFullItems(true) : _loc1_.getItems(true); + if(_loc2_) + { + _loc3_ = _loc2_; + } + } + } + return AvatarUtility.layerArrayForItemsAndColors(_loc3_,_avatar.colors,_avatar.avInvId,_avatar.roomType,_skipAnimEnviroCheck); + } + + public function playAnim(param1:int, param2:Boolean = false, param3:int = 0, param4:Function = null, param5:Boolean = false) : void + { + var _loc14_:Boolean = false; + var _loc13_:AccItemCollection = null; + var _loc6_:int = 0; + var _loc15_:int = 0; + var _loc11_:Array = null; + var _loc8_:* = null; + var _loc10_:Object = null; + var _loc9_:Array = null; + var _loc7_:* = 0; + if(_layerAnim && _layerAnim.visible && (_holdAnimId == 0 || param1 == _holdAnimId)) + { + if(!_isOffScreen) + { + _loc14_ = false; + _loc13_ = _avatar.accShownItems; + if(!_layerAnim.layers) + { + _loc14_ = true; + } + else if(_layerAnim.layers.length != _loc13_.length) + { + _loc14_ = true; + } + else + { + _loc6_ = int(_loc13_.length); + _loc15_ = 0; + while(_loc15_ < _loc6_) + { + if(_layerAnim.layers.indexOf(_loc13_.getAccItem(_loc15_).accId) == -1) + { + _loc14_ = true; + break; + } + _loc15_++; + } + } + if(_loc14_) + { + _loc11_ = []; + _loc8_ = _loc13_; + _loc9_ = _avatar.colors; + for each(var _loc12_ in _loc8_.getCoreArray()) + { + if((_loc12_.layerId <= 3 || (_skipAnimEnviroCheck || _loc12_.enviroType == _avatar.roomType || _loc12_.isLandAndOcean)) && _loc12_.getInUse(_avatar.avInvId)) + { + if(_loc12_.layerId == 1) + { + _loc7_ = uint(_loc9_[0]); + } + else if(_loc12_.layerId == 2) + { + _loc7_ = uint(_loc9_[1]); + } + else if(_loc12_.layerId == 3) + { + _loc7_ = uint(_loc9_[2]); + } + else + { + if(param5) + { + continue; + } + _loc7_ = _loc12_.color; + } + // "d": the item, as AvatarUtility.layerArrayForItemsAndColors + // gives it: a custom one's own picture goes by it + // (LayerAnim, LayerBitmap). without it every new + // animation (walking) was painted as the item's base. + _loc10_ = { + "l":_loc12_.accId, + "c":_loc7_, + "d":_loc12_.defId + }; + _loc11_.push(_loc10_); + } + } + _layerAnim.layers = _loc11_; + } + _layerAnim.hFlip = param2; + _layerAnim.playAnim(param1,param3,param4); + } + else + { + _lastAnimToHappen = param1; + } + } + } + + public function reloadItemsFromCache() : void + { + var _loc1_:AccItemCollection = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(_avatar.userName,_avatar.perUserAvId).getItems(true); + _avatar.itemResponseIntegrate(_loc1_,_skipAnimEnviroCheck); + } + + public function preloadAnims(param1:Array, param2:Function = null) : void + { + _layerAnim.preload(param1,param2); + } + + public function blackOut() : void + { + var _loc1_:Array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]; + _layerAnim.bitmap.filters = [new ColorMatrixFilter(_loc1_)]; + } + + public function get avatarData() : Avatar + { + return _avatar; + } + + public function get userName() : String + { + if(_avatar != null) + { + return _avatar.userName; + } + return null; + } + + public function get userId() : int + { + if(_avatar == null) + { + return -1; + } + return _avatar.sfsUserId; + } + + public function get avTypeId() : int + { + return _avatar.avTypeId; + } + + public function get customAvId() : int + { + return _avatar.customAvId; + } + + public function get perUserAvId() : int + { + return _avatar.perUserAvId; + } + + public function get avInvId() : int + { + return _avatar.avInvId; + } + + public function get inventoryBodyModItems() : AccItemCollection + { + return _avatar.inventoryBodyMod.itemCollection; + } + + public function get inventoryClothingItems() : AccItemCollection + { + return _avatar.inventoryClothing.itemCollection; + } + + public function setAvtColors(param1:Array) : void + { + _avatar.colors = param1; + } + + public function get avName() : String + { + return _avatar.avName; + } + + public function get accShownItems() : AccItemCollection + { + return _avatar.accShownItems; + } + } +} + diff --git a/swf-src/AvatarWorldView.as b/swf-src/AvatarWorldView.as index 279f2d6..70b47e3 100644 --- a/swf-src/AvatarWorldView.as +++ b/swf-src/AvatarWorldView.as @@ -191,6 +191,20 @@ package avatar "water":40, "set":"land", "flip":false + },{ + // sitting facing straight forward, and straight away (the "Front" + // and "Back" between the arrows): animations 5 and 1, the ends of + // the sitting turn 1-5 (2 the back corners, 4 the front ones; the + // slide's spin plays them in turn). the game's own buttons never did. + "name":":sitS:", + "land":5, + "water":40, + "flip":false + },{ + "name":":sitN:", + "land":1, + "water":40, + "flip":false }]; // the landing puff, artwork compiled into the client. its class has a @@ -209,6 +223,21 @@ package avatar private var _platformingCurVel:Number = 0; private var _chatBalloon:ChatBalloon; + + // "..." where the chat bubble goes, while the player is typing + // (AJClient.onTyping). gone when a line arrives, when they stop, or + // TYPING_SHOWN ms after they last said they were, if a "stopped" is lost. + private static const TYPING_SHOWN:int = 8000; + + private var _typing:Sprite; + + private var _typingDots:Array; + + private var _typingTimer:Timer; + + private var _typingStep:int; + + private var _typingUntil:int; private var _namebar:NameBar; @@ -628,6 +657,14 @@ package avatar { _chatLayer.removeChild(_chatBalloon); } + hideTyping(); + if(_typingTimer) + { + _typingTimer.removeEventListener("timer",onTypingTimer); + _typingTimer = null; + } + _typing = null; + _typingDots = null; removeChild(_namebar); if(_secondaryEmot && _chatLayer.contains(_secondaryEmot)) { @@ -1023,9 +1060,108 @@ package avatar return false; } + public function setTyping(param1:Boolean) : void + { + var _loc2_:Sprite = null; + var _loc3_:int = 0; + if(!param1 || _chatLayer == null) + { + hideTyping(); + return; + } + if(_typing == null) + { + _typing = new Sprite(); + _typing.mouseEnabled = false; + _typing.mouseChildren = false; + _typing.graphics.lineStyle(2,0x8C6A3C); + _typing.graphics.beginFill(0xFFFFFF); + _typing.graphics.drawRoundRect(-22,-26,44,22,20,20); + _typing.graphics.endFill(); + _typing.graphics.lineStyle(); + _typing.graphics.beginFill(0xFFFFFF); + _typing.graphics.moveTo(-5,-5); + _typing.graphics.lineTo(0,2); + _typing.graphics.lineTo(5,-5); + _typing.graphics.endFill(); + _typingDots = []; + _loc3_ = 0; + while(_loc3_ < 3) + { + _loc2_ = new Sprite(); + _loc2_.graphics.beginFill(0x6B5034); + _loc2_.graphics.drawCircle(0,0,3); + _loc2_.graphics.endFill(); + _loc2_.x = -10 + _loc3_ * 10; + _loc2_.y = -15; + _typing.addChild(_loc2_); + _typingDots.push(_loc2_); + _loc3_++; + } + _typingTimer = new Timer(300); + _typingTimer.addEventListener("timer",onTypingTimer,false,0,true); + } + _typingUntil = getTimer() + TYPING_SHOWN; + if(_typing.parent != _chatLayer) + { + _chatLayer.addChild(_typing); + } + placeTyping(); + _typing.visible = !(_chatBalloon && _chatBalloon.visible); + if(!_typingTimer.running) + { + _typingTimer.start(); + } + } + + private function hideTyping() : void + { + if(_typingTimer) + { + _typingTimer.stop(); + } + if(_typing && _typing.parent) + { + _typing.parent.removeChild(_typing); + } + } + + private function placeTyping() : void + { + if(_typing && _chatBalloon) + { + _typing.x = _chatBalloon.x; + _typing.y = _chatBalloon.y; + } + } + + private function onTypingTimer(param1:TimerEvent) : void + { + var _loc2_:int = 0; + if(_typing == null || getTimer() > _typingUntil) + { + hideTyping(); + return; + } + placeTyping(); + _typing.visible = !(_chatBalloon && _chatBalloon.visible); + _typingStep = (_typingStep + 1) % 3; + _loc2_ = 0; + while(_loc2_ < _typingDots.length) + { + _typingDots[_loc2_].alpha = _loc2_ == _typingStep ? 1 : 0.35; + _typingDots[_loc2_].y = _loc2_ == _typingStep ? -17 : -15; + _loc2_++; + } + } + public function setMessage(param1:String, param2:int) : void { var _loc3_:Boolean = false; + if(param1 != "...") + { + hideTyping(); + } if(param2 > 1) { if(param2 == 2) @@ -1220,6 +1356,18 @@ package avatar _pet.setActionByName(_loc2_.replace(/(Land|Swim):$/,":")); } } + + // The base action definitions supply their normal orientation. A local + // Mirror selection is applied after that, so it works for every action + // without changing the original sit/dance/etc. mappings. + public function setActionMirrored(param1:Boolean) : void + { + if(_lastIdleAnim > 0 && param1) + { + _lastIdleFlip = !_lastIdleFlip; + playAnim(_lastIdleAnim,_lastIdleFlip); + } + } public function circleTest(param1:int, param2:int, param3:int) : Boolean { diff --git a/swf-src/ChatBalloon.as b/swf-src/ChatBalloon.as index 0cef6b4..831ed2f 100644 --- a/swf-src/ChatBalloon.as +++ b/swf-src/ChatBalloon.as @@ -63,9 +63,12 @@ package gui private var _emoteBGOffsetFunc:Function; - // emotes drawn inside a line of chat: "\" and an emote's code - // ("\:)", "\:fever:") is shown as that emote, small, where it was - // typed. each is {at, clip}: where its gap starts in the text shown. + // emotes drawn inside a line of chat, small, where they were typed: an + // emote's code standing as a word of its own ("hi :) there", ":fever:"), + // or anywhere after a "\" ("yay\:)"). and emoji (typed with Windows' + // emoji panel, say), which the game's font has none of: each is drawn + // as a picture of it, from the server (/emoji/.png, + // Twemoji's). each is {at, clip}: where its gap starts in the text shown. private static const INLINE_GAP:String = " "; private static const LONGEST_EMOTE_CODE:int = 16; @@ -130,7 +133,7 @@ package gui this.visible = true; } clearInline(); - _msgTxt.text = param1.indexOf("\\") == -1 ? param1 : inlineEmotes(param1); + _msgTxt.text = inlineEmotes(param1); _msgTxt.height; // AJClient.whisperNext is set by the server's "xw" just ahead of a // whispered line. @@ -178,50 +181,63 @@ package gui } } - // the text with each "\" replaced by a gap, the emote for - // it kept in _inline. A code that is no emote stays as typed. + // the text with each emote code and emoji (above) replaced by a gap, the + // picture for it kept in _inline. what is neither stays as typed. private function inlineEmotes(param1:String) : String { var _loc2_:String = ""; var _loc3_:int = 0; - var _loc4_:int = 0; var _loc5_:String = null; - var _loc6_:String = null; - var _loc7_:MovieClip = null; + var _loc7_:Sprite = null; + var _loc8_:int = 0; while(_loc3_ < param1.length) { - _loc5_ = null; - if(param1.charAt(_loc3_) == "\\") + _loc8_ = emojiLength(param1,_loc3_); + if(_loc8_ > 0) { - _loc4_ = Math.min(LONGEST_EMOTE_CODE,param1.length - _loc3_ - 1); - while(_loc4_ >= 2 && _loc5_ == null) - { - _loc6_ = param1.substr(_loc3_ + 1,_loc4_); - if(EmoticonUtility.doesStringMatchAnEmote(_loc6_)) - { - _loc5_ = _loc6_; - } - _loc4_--; - } + _inline.push({ + "at":_loc2_.length, + "clip":emojiClip(param1.substr(_loc3_,_loc8_)) + }); + _loc2_ += INLINE_GAP; + _loc3_ += _loc8_; + continue; } - if(_loc5_ != null) + _loc5_ = null; + // an emoji as it is sent: "\{1f600}" (AJClient.emojiToTokens) + if(param1.substr(_loc3_,2) == "\\{") { - _loc7_ = EmoticonUtility.getSmallSmileyMCForEmoteString(_loc5_); - if(_loc7_ != null) + var _loc9_:Array = /^\\\{([0-9a-f]{2,6}(?:-[0-9a-f]{2,6}){0,9})\}/.exec(param1.substr(_loc3_,90)); + if(_loc9_ != null) { - _loc7_.mouseEnabled = false; - _loc7_.mouseChildren = false; _inline.push({ "at":_loc2_.length, - "clip":_loc7_ + "clip":emojiClipNamed(_loc9_[1]) }); _loc2_ += INLINE_GAP; + _loc3_ += String(_loc9_[0]).length; + continue; } - else - { - _loc2_ += _loc5_; - } - _loc3_ += 1 + _loc5_.length; + } + if(param1.charAt(_loc3_) == "\\") + { + _loc5_ = emoteCodeAt(param1,_loc3_ + 1,false); + } + else if(_loc3_ == 0 || param1.charAt(_loc3_ - 1) == " ") + { + _loc5_ = emoteCodeAt(param1,_loc3_,true); + } + _loc7_ = _loc5_ == null ? null : EmoticonUtility.getSmallSmileyMCForEmoteString(_loc5_); + if(_loc7_ != null) + { + _loc7_.mouseEnabled = false; + _loc7_.mouseChildren = false; + _inline.push({ + "at":_loc2_.length, + "clip":_loc7_ + }); + _loc2_ += INLINE_GAP; + _loc3_ += (param1.charAt(_loc3_) == "\\" ? 1 : 0) + _loc5_.length; } else { @@ -231,7 +247,149 @@ package gui } return _loc2_; } - + + // the longest emote code at `param2`, or null. `param3`: as a word of its + // own, so it must end the text or come before a space or a stop. + private static function emoteCodeAt(param1:String, param2:int, param3:Boolean) : String + { + var _loc4_:int = Math.min(LONGEST_EMOTE_CODE,param1.length - param2); + var _loc5_:String = null; + var _loc6_:String = null; + while(_loc4_ >= 2) + { + _loc5_ = param1.substr(param2,_loc4_); + _loc6_ = param1.charAt(param2 + _loc4_); + if((!param3 || _loc6_ == "" || " .,!?".indexOf(_loc6_) != -1) && EmoticonUtility.doesStringMatchAnEmote(_loc5_)) + { + return _loc5_; + } + _loc4_--; + } + return null; + } + + // how many UTF-16 units the emoji at `param2` takes (with its skin tone, + // its variation selector, a keycap, a second flag letter, and whatever + // it is joined to with a zero-width joiner), or 0 when there is none. + public static function emojiLength(param1:String, param2:int) : int + { + var _loc3_:int = param1.charCodeAt(param2); + var _loc4_:int = 0; + var _loc5_:int = 0; + var _loc6_:int = 0; + var _loc7_:Boolean = false; + if(_loc3_ >= 0xD800 && _loc3_ <= 0xDBFF) + { + _loc5_ = codePointAt(param1,param2); + if(_loc5_ < 0x1F000 || _loc5_ > 0x1FAFF) + { + return 0; + } + _loc4_ = 2; + _loc7_ = _loc5_ >= 0x1F1E6 && _loc5_ <= 0x1F1FF; + // a flag is two letters + if(_loc7_) + { + _loc6_ = codePointAt(param1,param2 + 2); + if(_loc6_ >= 0x1F1E6 && _loc6_ <= 0x1F1FF) + { + _loc4_ = 4; + } + } + } + else if(_loc3_ >= 0x2600 && _loc3_ <= 0x27BF || _loc3_ >= 0x2300 && _loc3_ <= 0x23FF || _loc3_ >= 0x2B00 && _loc3_ <= 0x2BFF + || _loc3_ >= 0x2194 && _loc3_ <= 0x21AA || _loc3_ >= 0x25AA && _loc3_ <= 0x25FE + || [0x203C,0x2049,0x2122,0x2139,0x24C2,0x2934,0x2935,0x3030,0x303D,0x3297,0x3299,0xA9,0xAE].indexOf(_loc3_) != -1 && param1.charCodeAt(param2 + 1) == 0xFE0F) + { + _loc4_ = 1; + } + else if("0123456789#*".indexOf(param1.charAt(param2)) != -1 && param1.charCodeAt(param2 + 1) == 0xFE0F && param1.charCodeAt(param2 + 2) == 0x20E3) + { + return 3; + } + else + { + return 0; + } + while(param2 + _loc4_ < param1.length) + { + _loc3_ = param1.charCodeAt(param2 + _loc4_); + if(_loc3_ == 0xFE0F || _loc3_ == 0x20E3) + { + _loc4_++; + } + else if(_loc3_ == 0xD83C && param1.charCodeAt(param2 + _loc4_ + 1) >= 0xDFFB && param1.charCodeAt(param2 + _loc4_ + 1) <= 0xDFFF) + { + _loc4_ += 2; + } + else if(_loc3_ == 0x200D && param2 + _loc4_ + 1 < param1.length) + { + _loc5_ = emojiLength(param1,param2 + _loc4_ + 1); + if(_loc5_ == 0) + { + break; + } + _loc4_ += 1 + _loc5_; + break; + } + else + { + break; + } + } + return _loc4_; + } + + private static function codePointAt(param1:String, param2:int) : int + { + var _loc3_:int = param1.charCodeAt(param2); + var _loc4_:int = param1.charCodeAt(param2 + 1); + if(_loc3_ >= 0xD800 && _loc3_ <= 0xDBFF && _loc4_ >= 0xDC00 && _loc4_ <= 0xDFFF) + { + return (_loc3_ - 0xD800) * 0x400 + (_loc4_ - 0xDC00) + 0x10000; + } + return _loc3_; + } + + // its picture's name, as Twemoji names its files: the code points in + // hex, "-" between, without U+FE0F unless it is joined (U+200D). + public static function emojiName(param1:String) : String + { + var _loc2_:Array = []; + var _loc3_:int = 0; + var _loc4_:int = 0; + var _loc5_:Boolean = param1.indexOf(String.fromCharCode(0x200D)) != -1; + while(_loc3_ < param1.length) + { + _loc4_ = codePointAt(param1,_loc3_); + _loc3_ += _loc4_ > 0xFFFF ? 2 : 1; + if(_loc4_ != 0xFE0F || _loc5_) + { + _loc2_.push(_loc4_.toString(16)); + } + } + return _loc2_.join("-"); + } + + // the picture of an emoji: a 72-square, its middle on the origin (as + // the game's small emotes are), filled when the picture has loaded. + private static function emojiClip(param1:String) : Sprite + { + return emojiClipNamed(emojiName(param1)); + } + + private static function emojiClipNamed(param1:String) : Sprite + { + var _loc2_:Sprite = new Sprite(); + _loc2_.graphics.beginFill(0,0); + _loc2_.graphics.drawRect(-36,-36,72,72); + _loc2_.graphics.endFill(); + _loc2_.mouseEnabled = false; + _loc2_.mouseChildren = false; + AJClient.loadArt(gMainFrame.clientInfo.websiteURL + "emoji/" + param1 + ".png",_loc2_,72,false); + return _loc2_; + } + // puts each inline emote over its gap, as tall as the line. private function placeInline() : void { diff --git a/swf-src/ChatHistory.as b/swf-src/ChatHistory.as index 228c80a..e63793d 100644 --- a/swf-src/ChatHistory.as +++ b/swf-src/ChatHistory.as @@ -14,6 +14,7 @@ package gui import flash.events.TextEvent; import flash.text.StyleSheet; import flash.text.TextField; + import flash.text.TextFormat; import flash.ui.Mouse; import gui.itemWindows.ItemWindowTextNode; import localization.LocalizationManager; @@ -211,6 +212,8 @@ package gui public function addMessage(param1:String, param2:String, param3:String, param4:String) : void { + // emoji as their names here: this list has no pictures (AJClient.emojiAsNames) + param4 = AJClient.emojiAsNames(param4); var _loc5_:Boolean = false; var _loc6_:* = 0; var _loc7_:int = 0; @@ -479,9 +482,10 @@ package gui } else { - // 150 here, where the original stopped at 70. the server takes - // up to config.maxChatLength. - chatMsgText.maxChars = 150; + // 200 here, where the original stopped at 70. the server takes + // up to config.maxChatLength (more: an emoji goes as a tag of 8 + // or more), and makes long lines shorter (lib/chatspam.js). + chatMsgText.maxChars = 200; } } @@ -753,6 +757,51 @@ package gui { _predictiveTextManager.onTextFieldChanged(param1); } + showEmojiInInput(); + AJClient.noteTyping(chatMsgText.text); + } + + // the chat box while it holds an emoji (Windows' emoji panel, say): the + // game's font has none, so the box is drawn in the computer's own emoji + // font until there are none again. the bubble shows them as pictures + // (gui.ChatBalloon). + private var _inputShowsEmoji:Boolean = false; + + private var _inputFormat:TextFormat; + + private var _inputEmbedded:Boolean = true; + + public function showEmojiInInput() : void + { + var _loc1_:Boolean = false; + var _loc2_:int = 0; + var _loc3_:String = chatMsgText == null ? "" : chatMsgText.text; + var _loc4_:TextFormat = null; + while(_loc2_ < _loc3_.length && !_loc1_) + { + _loc1_ = ChatBalloon.emojiLength(_loc3_,_loc2_) > 0; + _loc2_++; + } + if(chatMsgText == null || _loc1_ == _inputShowsEmoji) + { + return; + } + if(_loc1_) + { + _inputFormat = chatMsgText.defaultTextFormat; + _inputEmbedded = chatMsgText.embedFonts; + _loc4_ = new TextFormat("Segoe UI Emoji",_inputFormat.size,_inputFormat.color,_inputFormat.bold); + chatMsgText.embedFonts = false; + chatMsgText.defaultTextFormat = _loc4_; + chatMsgText.setTextFormat(_loc4_); + } + else + { + chatMsgText.embedFonts = _inputEmbedded; + chatMsgText.defaultTextFormat = _inputFormat; + chatMsgText.setTextFormat(_inputFormat); + } + _inputShowsEmoji = _loc1_; } private function keyDownListener(param1:KeyboardEvent) : void diff --git a/swf-src/DenItemHelper.as b/swf-src/DenItemHelper.as new file mode 100644 index 0000000..3bcd605 --- /dev/null +++ b/swf-src/DenItemHelper.as @@ -0,0 +1,665 @@ +package loader +{ + import Enums.DenItemDef; + import avatar.AvatarManager; + import avatar.MannequinData; + import com.sbi.loader.FileServerEvent; + import den.DenItem; + import den.DenStateItem; + import den.DenXtCommManager; + import flash.display.DisplayObject; + import flash.display.Loader; + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.MouseEvent; + import pet.PetItem; + import pet.PetManager; + + public class DenItemHelper + { + + private var _denItem:DenItem; + + private var _denStateItem:DenStateItem; + + private var _defId:int; + + private var _id:uint; + + private var _callback:Function; + + private var _loader:Loader; + + private var _sprite:Sprite; + + private var _portalSprite:Sprite; + + private var _sortOffset:int; + + private var _minigameDefId:int; + + private var _nameStrId:int; + + private var _listLauncherId:int; + + private var _version:int; + + private var _version2:int; + + private var _version3:int; + + private var _petItem:PetItem; + + private var _bFlipLabel:Boolean; + + private var _isUniqueImageItem:Boolean; + + private var _uniqueImageId:String; + + private var _uniqueImageCreator:String; + + private var _uniqueImageCreatorDbId:int; + + private var _uniqueImageCreatorUUID:String; + + private var _isMannequin:Boolean; + + private var _isDenStore:Boolean; + + private var _masterpieceDefHelper:MasterpieceDefHelper; + + private var _mannequinData:MannequinData; + + private var _onMouseDownCallback:Function; + + private var _onMouseOverCallback:Function; + + private var _onMouseOutCallback:Function; + + private var _uniqueImage:Sprite; + + public function DenItemHelper() + { + super(); + } + + public function get displayObject() : Sprite + { + return _sprite; + } + + public function get content() : DisplayObject + { + return _loader.content; + } + + public function get sortOffset() : int + { + return _sortOffset; + } + + public function get id() : int + { + return _id; + } + + public function get minigameDefId() : int + { + return _minigameDefId; + } + + public function get bFlipLabel() : Boolean + { + return _bFlipLabel; + } + + public function get isUniqueImageItem() : Boolean + { + return _isUniqueImageItem; + } + + public function get listLauncherId() : int + { + return _listLauncherId; + } + + public function get nameStrId() : int + { + return _nameStrId; + } + + public function get uniqueImage() : Sprite + { + return _uniqueImage; + } + + public function get uniqueImageId() : String + { + return _uniqueImageId; + } + + public function set uniqueImageId(param1:String) : void + { + _uniqueImageId = param1; + } + + public function get uniqueImageCreator() : String + { + return _uniqueImageCreator; + } + + public function set uniqueImageCreator(param1:String) : void + { + _uniqueImageCreator = param1; + } + + public function get uniqueImageCreatorDbId() : int + { + return _uniqueImageCreatorDbId; + } + + public function get uniqueImageCreatorUUID() : String + { + return _uniqueImageCreatorUUID; + } + + public function get denStateItem() : DenStateItem + { + return _denStateItem; + } + + public function get defId() : int + { + return _defId; + } + + public function get version() : int + { + return _version; + } + + public function get mannequin() : MannequinData + { + return _mannequinData; + } + + public function get isMannequin() : Boolean + { + return _isMannequin; + } + + public function get isDenStore() : Boolean + { + return _isDenStore; + } + + public function get contentWidth() : int + { + if(_loader != null && _loader.content != null) + { + if(_loader.content.hasOwnProperty("sizeCont")) + { + return _loader.content["sizeCont"].width; + } + return _loader.content.width; + } + return 0; + } + + public function get contentHeight() : int + { + if(_loader != null && _loader.content != null) + { + if(_loader.content.hasOwnProperty("sizeCont")) + { + return _loader.content["sizeCont"].height; + } + return _loader.content.height; + } + return 0; + } + + public function get currDenItem() : DenItem + { + return _denItem; + } + + public function init(param1:DenItem, param2:Function, param3:PetItem = null, param4:int = 0, param5:int = 0, param6:MannequinData = null) : void + { + _denItem = param1; + _defId = param1.defId; + _id = uint(_defId << 16 | DenItem.getIconId(param1.sortId)); + _callback = param2; + _minigameDefId = param1.minigameDefId; + _nameStrId = param5; + _listLauncherId = param4; + _bFlipLabel = false; + _isUniqueImageItem = false; + _petItem = param3; + _version = param1.sortId == 99 ? _petItem.petBits[0] : param1.version; + _version2 = param1.sortId == 99 ? _petItem.petBits[1] : 0; + _version3 = param1.sortId == 99 ? _petItem.petBits[2] : 0; + _loader = new Loader(); + _sprite = new Sprite(); + _portalSprite = new Sprite(); + _uniqueImage = new Sprite(); + _uniqueImageId = param1.uniqueImageId; + _uniqueImageCreator = param1.uniqueImageCreator; + _uniqueImageCreatorDbId = param1.uniqueImageCreatorDbId; + _uniqueImageCreatorUUID = param1.uniqueImageCreatorUUID; + _mannequinData = param6; + if(loadCustomArt()) + { + return; + } + DenItemServer.instance.addEventListener("OnNewData",handleData,false,0,true); + DenItemServer.instance.requestFile(_id); + } + + public function initDS(param1:DenStateItem, param2:Function) : void + { + _denStateItem = param1; + _defId = param1.defId; + _id = uint(_defId << 16 | param1.catId); + _callback = param2; + _minigameDefId = param1.minigameDefId; + _nameStrId = param1.nameStrId; + _listLauncherId = param1.listLauncherId; + _bFlipLabel = false; + _isUniqueImageItem = false; + _petItem = param1.petItem; + _version = param1.sortCatId == 99 ? _petItem.petBits[0] : param1.version; + _version2 = param1.sortCatId == 99 ? _petItem.petBits[1] : 0; + _version3 = param1.sortCatId == 99 ? _petItem.petBits[2] : 0; + _loader = new Loader(); + _sprite = new Sprite(); + _portalSprite = new Sprite(); + _uniqueImage = new Sprite(); + _uniqueImageId = param1.uniqueImageId; + _uniqueImageCreator = param1.uniqueImageCreator; + _uniqueImageCreatorDbId = param1.uniqueImageCreatorDbId; + _uniqueImageCreatorUUID = param1.uniqueImageCreatorUUID; + _mannequinData = param1.mannequinData; + if(loadCustomArt()) + { + return; + } + DenItemServer.instance.addEventListener("OnNewData",handleData,false,0,true); + DenItemServer.instance.requestFile(_id); + } + + public function initGeneric(param1:DenItemDef, param2:Function, param3:int = 0, param4:int = 0, param5:int = 0, param6:String = "", param7:int = -1, param8:String = "", param9:PetItem = null, param10:MannequinData = null) : void + { + _defId = param1.id; + _id = uint(_defId << 16 | DenItem.getIconId(param1.sortCat)); + _callback = param2; + _minigameDefId = param1.gameDefId; + _nameStrId = param5; + _listLauncherId = param4; + _bFlipLabel = false; + _isUniqueImageItem = false; + _petItem = param9; + _version = param1.sortCat == 99 ? _petItem.petBits[0] : param3; + _version2 = param1.sortCat == 99 ? _petItem.petBits[1] : 0; + _version3 = param1.sortCat == 99 ? _petItem.petBits[2] : 0; + _loader = new Loader(); + _sprite = new Sprite(); + _portalSprite = new Sprite(); + _uniqueImage = new Sprite(); + _uniqueImageId = param6; + _uniqueImageCreator = ""; + _uniqueImageCreatorDbId = param7; + _uniqueImageCreatorUUID = param8; + _mannequinData = param10; + if(loadCustomArt()) + { + return; + } + DenItemServer.instance.addEventListener("OnNewData",handleData,false,0,true); + DenItemServer.instance.requestFile(_id); + } + + public function destroy() : void + { + DenItemServer.instance.removeEventListener("OnNewData",handleData); + if(_loader) + { + if(_loader.parent) + { + _loader.parent.removeChild(_loader); + } + _loader.unloadAndStop(true); + } + _callback = null; + _sprite = null; + } + + public function loadUniqueImage() : void + { + if(_loader && _loader.content.hasOwnProperty("setUniqueImage")) + { + _isUniqueImageItem = true; + if(_uniqueImageId != "") + { + _masterpieceDefHelper = new MasterpieceDefHelper(); + _masterpieceDefHelper.init(_uniqueImageId,onUniqueImageIdLoaded); + } + } + } + + public function setupItemWithEmotes(param1:DenStateItem) : void + { + _denStateItem = param1; + } + + public function addPortalListeners(param1:DenStateItem, param2:Function, param3:Function = null, param4:Function = null) : void + { + _denStateItem = param1; + _onMouseDownCallback = param2; + _portalSprite.addEventListener("mouseDown",onMouseDown,false,0,true); + if(param3 != null) + { + _onMouseOverCallback = param3; + _portalSprite.addEventListener("mouseOver",onMouseOver,false,0,true); + } + if(param4 != null) + { + _onMouseOutCallback = param4; + _portalSprite.addEventListener("mouseOut",onMouseOut,false,0,true); + } + } + + public function addMouseListeners(param1:DenStateItem, param2:Function, param3:Function = null, param4:Function = null) : void + { + _denStateItem = param1; + _onMouseDownCallback = param2; + _sprite.addEventListener("mouseDown",onMouseDown,false,0,true); + if(param3 != null) + { + _onMouseOverCallback = param3; + _sprite.addEventListener("mouseOver",onMouseOver,false,0,true); + } + if(param4 != null) + { + _onMouseOutCallback = param4; + _sprite.addEventListener("mouseOut",onMouseOut,false,0,true); + } + } + + public function removeMouseListeners() : void + { + _denStateItem = null; + _onMouseDownCallback = null; + _sprite.removeEventListener("mouseDown",onMouseDown); + if(_onMouseOverCallback != null) + { + _onMouseOverCallback = null; + _sprite.removeEventListener("mouseOver",onMouseOver); + } + if(_onMouseOutCallback != null) + { + _onMouseOutCallback = null; + _sprite.removeEventListener("mouseOut",onMouseOut); + } + } + + public function removePortalListeners() : void + { + _denStateItem = null; + _onMouseDownCallback = null; + _portalSprite.removeEventListener("mouseDown",onMouseDown); + if(_onMouseOverCallback != null) + { + _onMouseOverCallback = null; + _portalSprite.removeEventListener("mouseOver",onMouseOver); + } + if(_onMouseOutCallback != null) + { + _onMouseOutCallback = null; + _portalSprite.removeEventListener("mouseOut",onMouseOut); + } + } + + public function getVersions() : Array + { + if(_loader && _loader.content && _loader.content.hasOwnProperty("getVersions")) + { + return _loader.content["getVersions"](); + } + return null; + } + + public function setVersion(param1:int, param2:int = 0, param3:int = 0) : void + { + var _loc5_:MovieClip = null; + var _loc4_:int = 0; + _version = param1; + if(param2 > 0) + { + _version2 = param2; + } + if(param3 > 0) + { + _version3 = param3; + } + if(_loader && _loader.content) + { + if(_loader.content.hasOwnProperty("setVersion")) + { + if(_version == -1) + { + _version = getVersions()[0]; + } + _loader.content["setVersion"](param1); + } + else if(_loader.content.hasOwnProperty("pet")) + { + _loc5_ = MovieClip(_loader.content); + PetManager.setPetState(_loc5_,_version,_version2,_version3); + if(_petItem && _petItem.isEgg) + { + if(_loc5_.pet.hasOwnProperty("setEggDayInt")) + { + _loc4_ = _petItem.createdTs > 0 ? Math.floor((Utility.getInitialEpochTime() - _petItem.createdTs) / 86400) : 0; + _loc5_.pet.setEggDayInt(_loc4_); + } + } + } + } + } + + public function rebuildMannequinView() : void + { + var _loc1_:DenItemDef = DenXtCommManager.getDenItemDef(_defId); + if(_loc1_ != null && _loc1_.mannequinAvatarDefId > 0) + { + _isMannequin = true; + _mannequinData.setupMannequinAvatarView(_loc1_,MovieClip(_loader.content)); + } + } + + // a custom den item's own picture (AJClient.customArtUrl): in place of + // the game's art, as its icon and in a den, standing on its spot. + private function loadCustomArt() : Boolean + { + var _loc1_:String = AJClient.customArtUrl("den",_defId); + if(_loc1_ == null) + { + return false; + } + var _loc2_:DenItemHelper = this; + _sortOffset = 0; + AJClient.loadArt(_loc1_,_sprite,160,true,function():void + { + _sprite.addChild(_portalSprite); + if(_callback != null) + { + _callback(_loc2_); + _callback = null; + } + }); + return true; + } + + private function handleData(param1:FileServerEvent) : void + { + var _loc2_:Object = null; + if(param1.id == _id && param1.success) + { + DenItemServer.instance.removeEventListener("OnNewData",handleData); + _loader.contentLoaderInfo.addEventListener("complete",onBytesLoaded); + param1.data.position = 0; + _loc2_ = param1.data.readObject(); + _sortOffset = _loc2_.so; + _loader.loadBytes(_loc2_.ba); + } + } + + private function onBytesLoaded(param1:Event) : void + { + var _loc3_:MovieClip = null; + var _loc2_:int = 0; + var _loc4_:DenItemDef = null; + _loader.contentLoaderInfo.removeEventListener("complete",onBytesLoaded); + var _loc5_:Array = _loader.content["currentLabels"]; + if(_loc5_.length >= 0) + { + for each(var _loc6_:Object in _loc5_) + { + if(_loc6_.name == "flip") + { + _bFlipLabel = true; + break; + } + } + if(!Utility.doesItAnimate(_loader.content)) + { + _loader.cacheAsBitmap = true; + } + } + if(_version == -1) + { + if(_loader.content.hasOwnProperty("getVersions")) + { + _version = getVersions()[0]; + } + else + { + _version = 0; + } + } + if(_loader.content.hasOwnProperty("setVersion") && _version >= 0) + { + MovieClip(_loader.content).setVersion(_version); + } + else if(_loader.content.hasOwnProperty("pet")) + { + _loc3_ = MovieClip(_loader.content); + PetManager.setPetState(_loc3_,_version,_version2,_version3); + if(_petItem && _petItem.isEgg) + { + if(_loc3_.pet.hasOwnProperty("setEggDayInt")) + { + _loc2_ = _petItem.createdTs > 0 ? Math.floor((Utility.getInitialEpochTime() - _petItem.createdTs) / 86400) : 0; + _loc3_.pet.setEggDayInt(_loc2_); + } + } + } + if(MovieClip(_loader.content).isMoveToDisabled) + { + _loader.name = "moveToDisabled"; + } + if(_mannequinData != null) + { + _loc4_ = DenXtCommManager.getDenItemDef(_defId); + if(_loc4_ != null && _loc4_.mannequinAvatarDefId > 0) + { + _isMannequin = true; + _mannequinData.setupMannequinAvatarView(_loc4_,MovieClip(_loader.content)); + } + } + if(_denStateItem != null) + { + if(_denStateItem.specialType == 1) + { + _portalSprite.addChild(MovieClip(_loader.content).clickObject); + } + else if(_denStateItem.specialType == 2 && _loader.content.hasOwnProperty("setEmoteCallback")) + { + MovieClip(_loader.content).setEmoteCallback(onEmoteItemClicked); + } + else if(_denStateItem.specialType == 5) + { + _isDenStore = true; + } + } + if(_loader.content.hasOwnProperty("setUniqueImage")) + { + _isUniqueImageItem = true; + if(_uniqueImageId != "") + { + _masterpieceDefHelper = new MasterpieceDefHelper(); + _masterpieceDefHelper.init(_uniqueImageId,onUniqueImageIdLoaded); + } + } + _sprite.addChild(_loader); + _sprite.addChild(_portalSprite); + if(_callback != null) + { + _callback(this); + _callback = null; + } + } + + private function onUniqueImageIdLoaded(param1:Sprite) : void + { + if(_masterpieceDefHelper) + { + _masterpieceDefHelper.destroy(); + _masterpieceDefHelper = null; + } + if(_uniqueImage) + { + _uniqueImage.addChild(param1); + if(_loader && _loader.content && "setUniqueImage" in _loader.content) + { + MovieClip(_loader.content).setUniqueImage(_uniqueImage); + } + } + } + + private function onEmoteItemClicked(param1:int) : void + { + if(AvatarManager.playerAvatarWorldView && !AvatarManager.playerAvatarWorldView.isThisAttachmentOn(param1)) + { + AvatarManager.setPlayerAttachmentEmot(param1); + } + } + + private function onMouseDown(param1:MouseEvent) : void + { + if(_onMouseDownCallback != null) + { + _onMouseDownCallback(param1,this); + } + } + + private function onMouseOver(param1:MouseEvent) : void + { + if(_onMouseOverCallback != null) + { + _onMouseOverCallback(param1,this); + } + } + + private function onMouseOut(param1:MouseEvent) : void + { + if(_onMouseOutCallback != null) + { + _onMouseOutCallback(param1); + } + } + } +} + diff --git a/swf-src/ECardInbox.as b/swf-src/ECardInbox.as index 9625322..b09d4eb 100644 --- a/swf-src/ECardInbox.as +++ b/swf-src/ECardInbox.as @@ -33,6 +33,7 @@ package gui import flash.net.navigateToURL; import giftPopup.GiftPopup; import gui.itemWindows.ItemWindowECard; + import item.ItemXtCommManager; import item.SimpleIcon; import loader.DenItemHelper; import loader.MediaHelper; @@ -698,6 +699,16 @@ package gui switch(_loc6_.type) { case 1: + // a custom item's own picture, when it has one (AJClient.customArtUrl) + if(AJClient.customArtUrl("clothing",giftItemDefId(_loc6_)) != null) + { + var _loc8_:Sprite = new Sprite(); + AJClient.loadArt(AJClient.customArtUrl("clothing",giftItemDefId(_loc6_)),_loc8_,100,false,function():void + { + setupGiftPopup(_loc8_); + }); + break; + } _clothingIconHelper = new SimpleIcon(); _clothingIconHelper.init(_loc6_.giftColor,_loc6_.giftId,1,true,false,clothingIconReceived); break; @@ -802,10 +813,45 @@ package gui setupGiftPopup(_guiPet); } + // a clothing gift's item id, which the server sends as "item|" in + // the card's additional gift data (its gift id is the art's), or 0 + private static function giftItemDefId(param1:ECard) : int + { + var _loc2_:String = param1.additionalGiftData == null ? "" : param1.additionalGiftData; + return _loc2_.indexOf("item|") == 0 ? int(_loc2_.substr(5)) : 0; + } + + // a custom item's name as it is now (the server sends it with the + // item, "xdi"): the game's strings have none for one made since this + // game started, nor a name it was given since. + private static function giftItemName(param1:ECard) : String + { + var _loc2_:Object = null; + var _loc3_:int = param1.type == 1 ? giftItemDefId(param1) : param1.giftId; + if(_loc3_ < 50000) + { + return null; + } + if(param1.type == 1) + { + _loc2_ = ItemXtCommManager.getItemDef(_loc3_); + } + else if(param1.type == 3 || param1.type == 99) + { + _loc2_ = DenXtCommManager.getDenItemDef(_loc3_); + } + return _loc2_ != null && _loc2_.name ? String(_loc2_.name) : null; + } + private function setupGiftPopup(param1:Sprite) : void { DarkenManager.showLoadingSpiral(false); var _loc2_:ECard = _inbox[_currCardIdx]; + var _loc4_:String = giftItemName(_loc2_); + if(_loc4_ != null) + { + _loc2_.giftName = _loc4_; + } var _loc3_:Boolean = _loc2_.isFromVoice && _loc2_.additionalGiftData.length > 0 && _loc2_.additionalGiftData.indexOf("|") == -1; _giftPopup = new GiftPopup(); _giftPopup.init(_guiLayer,param1,_loc2_.giftName,_loc2_.giftId,_loc2_.isFromVoice ? 6 : 0,GiftPopup.giftTypeForECardType(_loc2_.type),keepGiftCallback,rejectGiftCallback,destroyGiftPopup,!_loc2_.isFromVoice,GiftPopup.buttonsTypeForECardType(_loc2_.type),_loc2_.secondaryType,null,_loc3_ ? _loc2_.modifiedMsg : null,_petBits); diff --git a/swf-src/EmoticonUtility.cinit.pcode b/swf-src/EmoticonUtility.cinit.pcode index ffd632e..65414fe 100644 --- a/swf-src/EmoticonUtility.cinit.pcode +++ b/swf-src/EmoticonUtility.cinit.pcode @@ -3,7 +3,7 @@ returns null body - maxstack 43 + maxstack 45 localcount 1 initscopedepth 0 maxscopedepth 1 @@ -54,7 +54,9 @@ pushstring "emo_star2_sml" pushstring "emo_star3_sml" pushstring "emo_temp_sml" - newarray 43 + pushstring "emo_skull_sml" + pushstring "emo_sob_sml" + newarray 45 findproperty QName(PrivateNamespace("gui:EmoticonUtility"),"displaySprites") swap setproperty QName(PrivateNamespace("gui:EmoticonUtility"),"displaySprites") @@ -126,7 +128,9 @@ pushstring "emo_star2" pushstring "emo_star3" pushstring "emo_temp" - newarray 43 + pushstring "emo_skull" + pushstring "emo_sob" + newarray 45 findproperty QName(PrivateNamespace("gui:EmoticonUtility"),"emoteSprites") swap setproperty QName(PrivateNamespace("gui:EmoticonUtility"),"emoteSprites") @@ -565,6 +569,26 @@ pushstring ":fever:" newarray 1 setproperty MultinameL([PrivateNamespace("gui:EmoticonUtility"),StaticProtectedNs("gui:EmoticonUtility"),StaticProtectedNs("Object"),PackageNamespace("gui"),PackageInternalNs("gui"),PrivateNamespace("FilePrivateNS:EmoticonUtility"),PackageNamespace(""),Namespace("http://adobe.com/AS3/2006/builtin")]) + getlex QName(PrivateNamespace("gui:EmoticonUtility"),"_emoteStrings") + pushstring "emo_skull" + pushstring ":skull:" + newarray 1 + setproperty MultinameL([PrivateNamespace("gui:EmoticonUtility"),StaticProtectedNs("gui:EmoticonUtility"),StaticProtectedNs("Object"),PackageNamespace("gui"),PackageInternalNs("gui"),PrivateNamespace("FilePrivateNS:EmoticonUtility"),PackageNamespace(""),Namespace("http://adobe.com/AS3/2006/builtin")]) + getlex QName(PrivateNamespace("gui:EmoticonUtility"),"_emoteChatStrings") + pushstring "emo_skull" + pushstring ":skull:" + newarray 1 + setproperty MultinameL([PrivateNamespace("gui:EmoticonUtility"),StaticProtectedNs("gui:EmoticonUtility"),StaticProtectedNs("Object"),PackageNamespace("gui"),PackageInternalNs("gui"),PrivateNamespace("FilePrivateNS:EmoticonUtility"),PackageNamespace(""),Namespace("http://adobe.com/AS3/2006/builtin")]) + getlex QName(PrivateNamespace("gui:EmoticonUtility"),"_emoteStrings") + pushstring "emo_sob" + pushstring ":sob:" + newarray 1 + setproperty MultinameL([PrivateNamespace("gui:EmoticonUtility"),StaticProtectedNs("gui:EmoticonUtility"),StaticProtectedNs("Object"),PackageNamespace("gui"),PackageInternalNs("gui"),PrivateNamespace("FilePrivateNS:EmoticonUtility"),PackageNamespace(""),Namespace("http://adobe.com/AS3/2006/builtin")]) + getlex QName(PrivateNamespace("gui:EmoticonUtility"),"_emoteChatStrings") + pushstring "emo_sob" + pushstring ":sob:" + newarray 1 + setproperty MultinameL([PrivateNamespace("gui:EmoticonUtility"),StaticProtectedNs("gui:EmoticonUtility"),StaticProtectedNs("Object"),PackageNamespace("gui"),PackageInternalNs("gui"),PrivateNamespace("FilePrivateNS:EmoticonUtility"),PackageNamespace(""),Namespace("http://adobe.com/AS3/2006/builtin")]) returnvoid end ; code end ; body diff --git a/swf-src/GuiManager.as b/swf-src/GuiManager.as index a8b6126..50f2001 100644 --- a/swf-src/GuiManager.as +++ b/swf-src/GuiManager.as @@ -2769,8 +2769,20 @@ package gui gMainFrame.stage.removeEventListener("mouseUp",clickedOutsideChatCui); } + // an emote from the emote window: sent on its own, as the game has it; + // but with words already typed in the chat box, its code goes there, + // after them, and the line shows it among the words (gui.ChatBalloon). public static function onEmoteClick(param1:Sprite) : void { + var _loc2_:String = EmoticonUtility.getEmoteString(param1); + var _loc3_:Object = chatHist != null ? chatHist.chatMsgText : null; + if(_loc2_ != null && _loc3_ != null && chatHist.enableFreeChatValue && String(_loc3_.text).replace(/\s+/g,"").length > 0) + { + _loc3_.text = String(_loc3_.text).replace(/\s+$/,"") + " " + _loc2_ + " "; + gMainFrame.stage.focus = _loc3_ as InteractiveObject; + _loc3_.setSelection(_loc3_.text.length,_loc3_.text.length); + return; + } UserCommXtCommManager.sendAvatarEmote(param1); } diff --git a/swf-src/Item.as b/swf-src/Item.as new file mode 100644 index 0000000..cb02465 --- /dev/null +++ b/swf-src/Item.as @@ -0,0 +1,803 @@ +package item +{ + import com.sbi.debug.DebugUtility; + import currency.CombinedCurrencyItem; + import diamond.DiamondItem; + import diamond.DiamondXtCommManager; + import flash.display.Sprite; + import inventory.Iitem; + import localization.LocalizationManager; + + public class Item implements Iitem + { + + public static const BODY_MOD_TYPE:int = 0; + + public static const CLOTHING_TYPE:int = 1; + + public static const BASE_LAYER:int = 1; + + public static const PATTERN_LAYER:int = 2; + + public static const EYE_LAYER:int = 3; + + public static const TAIL_LAYER:int = 4; + + public static const LEG_LAYER:int = 5; + + public static const BACK_LAYER:int = 6; + + public static const NECK_LAYER:int = 7; + + public static const HEAD_LAYER_1:int = 8; + + public static const HEAD_LAYER_2:int = 9; + + public static const HEAD_LAYER_3:int = 10; + + public static const OCEAN_LEG_LAYER:int = 8; + + public static const OCEAN_BACK_LAYER:int = 6; + + public static const OCEAN_HEAD_LAYER:int = 7; + + public static const OCEAN_NECK_LAYER:int = 5; + + public static const NUM_DETAILS_PER_ITEM:int = 11; + + public static const COMBAT_TYPE_MELEE:int = 0; + + public static const COMBAT_TYPE_RANGED:int = 1; + + public static const MODIFIER_TYPE_NONE:int = 0; + + public static const MODIFIER_TYPE_RANGED:int = 1; + + public static const MODIFIER_TYPE_MELEE:int = 2; + + public static const MODIFIER_TYPE_DEFENSE:int = 3; + + public static const MODIFIER_TYPE_RESTORE:int = 4; + + private var _currDef:Object; + + private var _layerId:int; + + private var _invIdx:int; + + private var _accId:int; + + private var _color:uint; + + private var _name:String; + + private var _isGiftable:Boolean; + + private var _isMemberOnly:Boolean; + + private var _itemStatus:int; + + private var _type:int; + + private var _enviroType:int; + + private var _recycleValue:int; + + private var _currencyType:int; + + private var _avatarUseFlag:Object; + + private var _endTime:uint; + + private var _colors:Array; + + private var _equippedAvatars:EquippedAvatars; + + private var _value:int; + + private var _defId:int; + + private var _icon:Sprite; + + private var _iconHelper:SimpleIcon; + + private var _denStoreInvId:int; + + private var _largeIcon:Sprite; + + private var _largeIconHelper:SimpleIcon; + + private var _isShopItem:Boolean; + + private var _isIconLoaded:Boolean; + + private var _imageLoadedCallback:Function; + + private var _iconLayerID:int = -1; + + private var _iconColorID:int = 0; + + private var _attackMediaRefId:int = 0; + + private var _defense:int = 0; + + private var _attack:int = 0; + + private var _combatType:int = 0; + + private var _fierce:int = 0; + + private var _modifierType:int = 0; + + private var _modifierValue:int = 0; + + private var _combinedCurrencyItem:CombinedCurrencyItem; + + private var _specialScale:Number; + + private var _diamondItem:DiamondItem; + + private var _asShopItemSized:Boolean; + + public function Item() + { + super(); + } + + public function init(param1:int, param2:int = 0, param3:uint = 0, param4:EquippedAvatars = null, param5:Boolean = false, param6:Number = -1, param7:int = 0) : void + { + _defId = param1; + _invIdx = param2; + _color = param3; + _equippedAvatars = param4 != null ? param4 : new EquippedAvatars(); + _isShopItem = param5; + _specialScale = param6; + _denStoreInvId = param7; + _currDef = ItemXtCommManager.getItemDef(param1); + if(_currDef == null) + { + DebugUtility.debugTrace("Item.init got invalid defId? defId:" + param1); + return; + } + _layerId = _currDef.layerId; + _accId = _currDef.accId; + _name = _currDef.name; + _isGiftable = _currDef.isGiftable; + _diamondItem = DiamondXtCommManager.getDiamondItem(DiamondXtCommManager.getDiamondDefIdByRefId(_currDef.defId,0)); + if(_diamondItem) + { + _itemStatus = _diamondItem.status; + _value = _diamondItem.value; + _currencyType = 3; + _endTime = _diamondItem.availabilityEndTime; + } + else + { + _itemStatus = _currDef.itemStatus; + _value = isOnSale ? Math.ceil(_currDef.cost * 0.5) : _currDef.cost; + _currencyType = _currDef.currencyType; + _endTime = _currDef.availabilityEndTime; + } + _type = _currDef.type; + _isMemberOnly = _currDef.isMembersOnly; + _enviroType = _currDef.enviroType; + _recycleValue = _currDef.recycleValue == 0 ? _currDef.cost * gMainFrame.clientInfo.recyclePercentage : _currDef.recycleValue; + _avatarUseFlag = _currDef.avatarUseFlag; + _colors = _currDef.colors; + _attackMediaRefId = _currDef.attackMediaRefId; + _defense = _currDef.defense; + _attack = _currDef.attack; + _combatType = _currDef.combatType; + _fierce = _currDef.criticalHit; + _modifierType = _currDef.modifierType; + _modifierValue = _currDef.modifierValue; + _largeIcon = null; + _icon = null; + if(_currencyType == 100) + { + _combinedCurrencyItem = new CombinedCurrencyItem(_currDef.combinedCurrencyString); + } + _isIconLoaded = false; + } + + public function destroy() : void + { + if(_iconHelper) + { + _iconHelper.destroy(); + _iconHelper = null; + } + if(_largeIconHelper) + { + _largeIconHelper.destroy(); + _largeIconHelper = null; + } + if(_icon) + { + _icon = null; + } + } + + public function ifItemDiffers(param1:Iitem) : Boolean + { + var _loc2_:Item = param1 as Item; + if(_loc2_) + { + if(_defId == param1.defId) + { + if(!_equippedAvatars.equals(_loc2_._equippedAvatars) || value != _loc2_.value || _color != _loc2_._color || _name != _loc2_._name || _isGiftable != _loc2_._isGiftable || _type != _loc2_._type || _layerId != _loc2_._layerId || _accId != _loc2_._accId || _isMemberOnly != _loc2_._isMemberOnly || isNew != _loc2_.isNew || isOnSale != _loc2_.isOnSale || _recycleValue != _loc2_._recycleValue || _currencyType != _loc2_._currencyType || _endTime != _loc2_._endTime || _specialScale != _loc2_.specialScale || isInDenShop != _loc2_.isInDenShop) + { + return true; + } + } + } + return false; + } + + public function clone() : Iitem + { + var _loc1_:Item = new Item(); + _loc1_.init(_defId,_invIdx,_color,_equippedAvatars.clone(),_isShopItem,_specialScale,_denStoreInvId); + _loc1_.updateValueWithNewStatus(_itemStatus); + _loc1_.imageLoadedCallback = imageLoadedCallback; + return _loc1_; + } + + public function makeSmallIcon() : void + { + if(_accId == 3) + { + return; + } + _isIconLoaded = false; + _icon = new Sprite(); + // a custom item's own picture (AJClient.customArtUrl), in a box the + // size of the game's icons + var _loc1_:String = AJClient.customArtUrl("clothing",_defId); + if(_loc1_ != null) + { + var _loc2_:Sprite = new Sprite(); + AJClient.loadArt(_loc1_,_loc2_,100,false,function():void + { + _loc2_.x = 50; + _loc2_.y = 50; + _icon.addChild(_loc2_); + resizeAndPositionIcon(false); + _isIconLoaded = true; + }); + return; + } + _iconHelper = new SimpleIcon(); + _iconHelper.init(_color,_accId,1,_isShopItem,false,smallIconReceived); + } + + public function makeLargeIcon() : void + { + if(_accId == 3) + { + return; + } + _isIconLoaded = false; + _largeIcon = new Sprite(); + var _loc1_:String = AJClient.customArtUrl("clothing",_defId); + if(_loc1_ != null) + { + var _loc2_:Sprite = new Sprite(); + AJClient.loadArt(_loc1_,_loc2_,100,false,function():void + { + _loc2_.x = 50; + _loc2_.y = 50; + _largeIcon.addChild(_loc2_); + resizeAndPositionIcon(true); + _isIconLoaded = true; + }); + return; + } + _largeIconHelper = new SimpleIcon(); + _largeIconHelper.init(_color,_accId,1,_isShopItem,false,largeIconReceived); + } + + private function smallIconReceived() : void + { + _icon.addChild(_iconHelper.iconBitmap); + resizeAndPositionIcon(false); + _isIconLoaded = true; + if(_iconLayerID >= 0) + { + if(_icon && _iconHelper) + { + _iconHelper.updateLayerColor(_iconLayerID,_iconColorID); + } + _iconLayerID = -1; + } + } + + private function largeIconReceived() : void + { + _largeIcon.addChild(_largeIconHelper.iconBitmap); + resizeAndPositionIcon(true); + _isIconLoaded = true; + } + + public function setIconColor(param1:int, param2:uint) : void + { + _iconLayerID = param1; + _iconColorID = param2; + if(_icon && _iconHelper) + { + _iconHelper.updateLayerColor(_iconLayerID,_iconColorID); + } + } + + private function updateLargeIconColor() : void + { + if(_largeIcon && _largeIconHelper) + { + _largeIconHelper.updateLayerColor(_layerId,_color); + } + } + + private function updateIconColor() : void + { + if(_icon && _iconHelper) + { + _iconHelper.updateLayerColor(_layerId,_color); + } + } + + public function resizeAndPositionIcon(param1:Boolean) : void + { + var _loc2_:Number = NaN; + if(_isShopItem || param1 || _asShopItemSized) + { + if(param1) + { + _loc2_ = 1; + _largeIcon.width *= _loc2_; + _largeIcon.height *= _loc2_; + _largeIcon.x = -(_largeIcon.width * 0.5); + _largeIcon.y = -(_largeIcon.height * 0.5); + } + else + { + if(_specialScale > 0) + { + _loc2_ = _specialScale; + } + else + { + _loc2_ = 0.6; + } + _icon.width *= _loc2_; + _icon.height *= _loc2_; + _icon.x = -(_icon.width * 0.5); + _icon.y = -(_icon.height * 0.5); + } + } + else + { + _loc2_ = 0.75; + _icon.width *= _loc2_; + _icon.height *= _loc2_; + _icon.x = -(_icon.width * 0.5); + _icon.y = -(_icon.height * 0.5); + } + if(_imageLoadedCallback != null) + { + _imageLoadedCallback(); + } + } + + public function set asShopItemSized(param1:Boolean) : void + { + _asShopItemSized = param1; + } + + public function set diamondItem(param1:DiamondItem) : void + { + _diamondItem = param1; + } + + public function get diamondItem() : DiamondItem + { + return _diamondItem; + } + + public function get defId() : int + { + return _defId; + } + + public function set defId(param1:int) : void + { + _defId = param1; + } + + public function get icon() : Sprite + { + if(!_icon) + { + makeSmallIcon(); + } + else + { + updateIconColor(); + } + return _icon; + } + + public function get largeIcon() : Sprite + { + if(!_largeIcon) + { + makeLargeIcon(); + } + else + { + updateLargeIconColor(); + } + return _largeIcon; + } + + public function get isOnSale() : Boolean + { + return _itemStatus == 2; + } + + public function get isOnClearance() : Boolean + { + return _itemStatus == 3; + } + + public function get isRare() : Boolean + { + return _itemStatus == 4; + } + + public function get isNew() : Boolean + { + return _itemStatus == 1; + } + + public function get startTime() : uint + { + if(_diamondItem) + { + return _diamondItem.startTime; + } + if(_currDef) + { + return _currDef.availabilityStartTime; + } + return 0; + } + + public function get isOcean() : Boolean + { + return _enviroType == 1; + } + + public function get isLand() : Boolean + { + return _enviroType == 0; + } + + public function get isLandAndOcean() : Boolean + { + return _enviroType == 3; + } + + public function get isDiamond() : Boolean + { + return _diamondItem != null; + } + + public function get isRareDiamond() : Boolean + { + return isRare && isDiamond; + } + + public function get attackMediaRefId() : int + { + return _attackMediaRefId; + } + + public function get defense() : int + { + return _defense; + } + + public function get attack() : int + { + return _attack; + } + + public function get combatType() : int + { + return _combatType; + } + + public function get modifierType() : int + { + return _modifierType; + } + + public function get modifierValue() : int + { + return _modifierValue; + } + + public function get fierceAttack() : int + { + return _fierce; + } + + public function get extraTooltipInfo() : String + { + return ""; + } + + public function cloneEquippedAvatars(param1:Boolean = false) : EquippedAvatars + { + if(param1 && _equippedAvatars.isEquippedOnAnyAvatars()) + { + return EquippedAvatars.forced(); + } + return _equippedAvatars.clone(); + } + + public function getInUse(param1:int = -1) : Boolean + { + return _equippedAvatars.isEquipped(param1); + } + + public function setInUse(param1:int, param2:Boolean) : void + { + _equippedAvatars.setEquipped(param1,param2); + } + + public function forceInUse(param1:Boolean) : void + { + _equippedAvatars.setForceInUse(param1); + } + + public function updateValueWithNewStatus(param1:int) : void + { + if(_currencyType != 100 && !isRare && _currDef != null) + { + _itemStatus = param1; + if(isOnSale) + { + if(_diamondItem) + { + if(_diamondItem.isOnSale) + { + _value = _diamondItem.value; + } + else + { + _value = Math.ceil(_diamondItem.value * 0.5); + } + } + else + { + _value = Math.ceil(_currDef.cost * 0.5); + } + } + else + { + _value = _diamondItem ? _diamondItem.value : _currDef.cost; + } + _recycleValue = _currDef.recycleValue == 0 ? _currDef.cost * gMainFrame.clientInfo.recyclePercentage : _currDef.recycleValue; + } + } + + public function get combinedCurrencyItem() : CombinedCurrencyItem + { + return _combinedCurrencyItem; + } + + public function get sincleCurrencyCost() : int + { + return _value; + } + + public function get value() : * + { + if(_currencyType == 100) + { + return _combinedCurrencyItem; + } + return _value; + } + + public function get sortIdString() : String + { + switch(_layerId - 4) + { + case 0: + return LocalizationManager.translateIdOnly(11209).toLowerCase(); + case 1: + return LocalizationManager.translateIdOnly(11208).toLowerCase(); + case 2: + return LocalizationManager.translateIdOnly(11207).toLowerCase(); + case 3: + return LocalizationManager.translateIdOnly(11206).toLowerCase(); + case 4: + case 5: + case 6: + return LocalizationManager.translateIdOnly(11205).toLowerCase(); + default: + return ""; + } + } + + public function get isMemberOnly() : Boolean + { + return _isMemberOnly; + } + + public function set isMemberOnly(param1:Boolean) : void + { + _isMemberOnly = param1; + } + + public function get layerId() : int + { + return _layerId; + } + + public function get invIdx() : int + { + return _invIdx; + } + + public function get accId() : int + { + return _accId; + } + + public function get color() : uint + { + return _color; + } + + public function set color(param1:uint) : void + { + _color = param1; + } + + public function get colors() : Array + { + return _colors; + } + + public function get name() : String + { + return _name; + } + + public function get isGiftable() : Boolean + { + return _isGiftable; + } + + public function get itemStatus() : int + { + return _itemStatus; + } + + public function get type() : int + { + return _type; + } + + public function get enviroType() : int + { + return _enviroType; + } + + public function get recycleValue() : int + { + return _recycleValue; + } + + public function get currencyType() : int + { + return _currencyType; + } + + public function get avatarUseFlag() : Object + { + return _avatarUseFlag; + } + + public function get endTime() : uint + { + return _endTime; + } + + public function set endTime(param1:uint) : void + { + _endTime = param1; + } + + public function get isIconLoaded() : Boolean + { + return _isIconLoaded; + } + + public function get imageLoadedCallback() : Function + { + return _imageLoadedCallback; + } + + public function set imageLoadedCallback(param1:Function) : void + { + _imageLoadedCallback = param1; + } + + public function get isShopItem() : Boolean + { + return _isShopItem; + } + + public function get specialScale() : Number + { + return _specialScale; + } + + public function set specialScale(param1:Number) : void + { + _specialScale = param1; + } + + public function get isApproved() : Boolean + { + return true; + } + + public function set isApproved(param1:Boolean) : void + { + } + + public function get isCustom() : Boolean + { + return false; + } + + public function get isAvailable() : Boolean + { + if(_diamondItem) + { + return _diamondItem.isAvailable; + } + if(_currDef) + { + return Utility.isAvailable(_currDef.availabilityStartTime,_currDef.availabilityEndTime); + } + return false; + } + + public function get isInDenShop() : Boolean + { + return _denStoreInvId > 0; + } + + public function get denStoreInvId() : int + { + return _denStoreInvId; + } + + public function get itemType() : int + { + return 2; + } + + public function set denStoreInvId(param1:int) : void + { + _denStoreInvId = param1; + } + } +} + diff --git a/swf-src/ItemWindowToggle.as b/swf-src/ItemWindowToggle.as index 8f46668..1257931 100644 --- a/swf-src/ItemWindowToggle.as +++ b/swf-src/ItemWindowToggle.as @@ -165,6 +165,7 @@ package gui.itemWindows _window.goNowBtn.mouse.up.txt.text = ServerSelector.getShardName(RoomManagerWorld.instance.shardId); break; case "itemFinder": + case "itemMaker": case "chatFilter": case "themeMenu": case "themePick": @@ -636,6 +637,13 @@ package gui.itemWindows } AJClient.openTool(0); break; + case "itemMaker": + if(_mySettingsCloseFunction != null) + { + _mySettingsCloseFunction(null); + } + AJClient.openTool(2); + break; case "chatFilter": if(_mySettingsCloseFunction != null) { diff --git a/swf-src/KeepAlive.as b/swf-src/KeepAlive.as new file mode 100644 index 0000000..a30b3d4 --- /dev/null +++ b/swf-src/KeepAlive.as @@ -0,0 +1,177 @@ +package com.sbi.client +{ + import com.sbi.popup.SBOkPopup; + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.events.Event; + import flash.events.MouseEvent; + import flash.events.TimerEvent; + import flash.utils.Timer; + import localization.LocalizationManager; + + public class KeepAlive + { + + // how long a player may be away before the game signs them out: an + // hour and a quarter (the game's own was 7 minutes). the server's + // socket waits longer still (config.idleTimeoutMs). + private static var KICK_INTERVAL:int = 4500000; + + private static var SEND_MSG_INTERVAL:int = 180000; + + private static var NOTIFY_USER_INTERVAL:int = 10000; + + private static var NOTIFY_USER_TIME:int = 60000; + + public static var popupLayer:DisplayObjectContainer; + + private static var _keepAliveTimer:Timer; + + private static var _timeLeftTimer:Timer; + + private static var _bInputReceived:Boolean; + + private static var _mcsToKeepAlive:Array; + + private static var _lastMsgSentToServer:Number; + + private static var _inputTimer:Timer; + + private static var _kickWarningPopupShowing:Boolean; + + private static var _isConnected:Function; + + private static var _disconnectClient:Function; + + private static var _playIdleWarningSound:Function; + + public function KeepAlive() + { + super(); + } + + public static function init(param1:DisplayObjectContainer, param2:Function, param3:Function = null, param4:Function = null) : void + { + popupLayer = param1; + _keepAliveTimer = new Timer(SEND_MSG_INTERVAL); + _keepAliveTimer.addEventListener("timer",sendKeepAliveMsg); + _timeLeftTimer = new Timer(NOTIFY_USER_INTERVAL); + _timeLeftTimer.addEventListener("timer",timeLeftTimer); + _timeLeftTimer.start(); + _lastMsgSentToServer = new Date().getTime(); + _mcsToKeepAlive = []; + _isConnected = param2; + _disconnectClient = param3; + _playIdleWarningSound = param4; + } + + public static function startKATimer(param1:DisplayObjectContainer) : void + { + param1.addEventListener("mouseDown",inputReceivedHandler,false,0,true); + param1.addEventListener("keyDown",inputReceivedHandler,false,0,true); + _mcsToKeepAlive.push(param1); + _bInputReceived = true; + sendKeepAliveMsg(null); + _keepAliveTimer.start(); + } + + public static function stopKATimer(param1:DisplayObjectContainer) : void + { + var _loc2_:int = 0; + gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone); + _keepAliveTimer.stop(); + _loc2_ = 0; + while(_loc2_ < _mcsToKeepAlive.length) + { + if(_mcsToKeepAlive[_loc2_] == param1) + { + _mcsToKeepAlive[_loc2_].removeEventListener("mouseDown",inputReceivedHandler); + _mcsToKeepAlive[_loc2_].removeEventListener("keyDown",inputReceivedHandler); + _mcsToKeepAlive.splice(_loc2_,1); + break; + } + _loc2_++; + } + } + + public static function restartTimeLeftTimer() : void + { + if(_timeLeftTimer) + { + _lastMsgSentToServer = new Date().getTime(); + _timeLeftTimer.stop(); + _timeLeftTimer.start(); + } + } + + public static function sendKeepAliveReset() : void + { + _bInputReceived = true; + sendKeepAliveMsg(null); + } + + private static function sendKeepAliveMsg(param1:TimerEvent) : void + { + if(_bInputReceived) + { + gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone); + _lastMsgSentToServer = new Date().getTime(); + _bInputReceived = false; + } + } + + private static function timeLeftTimer(param1:TimerEvent) : void + { + var _loc2_:DisplayObject = null; + var _loc3_:Number = new Date().getTime() - _lastMsgSentToServer; + if(!_kickWarningPopupShowing && _loc3_ > KICK_INTERVAL - NOTIFY_USER_TIME) + { + _loc2_ = new SBOkPopup(popupLayer,LocalizationManager.translateIdOnly(14681),true,onKickWarningPopup); + _kickWarningPopupShowing = true; + if(_playIdleWarningSound != null) + { + _playIdleWarningSound(); + } + if((gMainFrame.userInfo.isModerator || gMainFrame.clientInfo.accountType == 4) && !gMainFrame.server.isBlueboxMode()) + { + _bInputReceived = true; + sendKeepAliveMsg(null); + _kickWarningPopupShowing = false; + SBOkPopup.destroyInParentChain(_loc2_); + } + } + if(_loc3_ > KICK_INTERVAL) + { + if(_isConnected()) + { + if(_disconnectClient != null) + { + _disconnectClient(); + } + } + } + } + + private static function onKickWarningPopup(param1:MouseEvent) : void + { + _bInputReceived = true; + sendKeepAliveMsg(null); + param1.stopPropagation(); + SBOkPopup.destroyInParentChain(param1.target.parent); + _kickWarningPopupShowing = false; + } + + public static function inputReceivedHandler(param1:Event) : void + { + if(!_bInputReceived) + { + _bInputReceived = true; + } + if(new Date().getTime() - _lastMsgSentToServer > SEND_MSG_INTERVAL) + { + sendKeepAliveMsg(null); + } + } + } +} + diff --git a/swf-src/LayerAnim.as b/swf-src/LayerAnim.as index ec3819b..f6a120d 100644 --- a/swf-src/LayerAnim.as +++ b/swf-src/LayerAnim.as @@ -440,7 +440,8 @@ package com.sbi.graphics _loc2_ = false; for(var _loc4_ in param1) { - if(!_layers[_loc4_] || _layers[_loc4_].l != param1[_loc4_].l) + // (a custom item has its base's art: its own picture makes it another, AJClient.customArtKey) + if(!_layers[_loc4_] || _layers[_loc4_].l != param1[_loc4_].l || AJClient.customArtKey("clothing",int(_layers[_loc4_].d)) != AJClient.customArtKey("clothing",int(param1[_loc4_].d))) { _loc2_ = true; break; @@ -702,6 +703,19 @@ package com.sbi.graphics buildRequestArray(param1,_loc2_,_loc4_); _loc2_.sort(); var _loc3_:String = _loc2_.join(); + // custom items with pictures of their own are painted otherwise than + // their bases: their frames are kept apart + for each(var _loc5_:Object in _layers) + { + if(_loc5_.d) + { + var _loc6_:String = AJClient.customArtKey("clothing",int(_loc5_.d)); + if(_loc6_ != "") + { + _loc3_ += "|" + _loc6_; + } + } + } _colors = _loc4_; _requestedCacheKey = _loc3_; _receivedData = []; @@ -792,7 +806,8 @@ package com.sbi.graphics { var _loc7_:int = int(_loc6_[_loc4_.l]); _loc6_[_loc4_.l] = _loc7_ + 1; - _bitmap.setLayer(LayerBitmap.slotFor(_loc4_.l,_loc7_),_loc4_.d,_loc4_.c,_requestedCacheKey); + _bitmap.setLayer(LayerBitmap.slotFor(_loc4_.l,_loc7_),_loc4_.d,_loc4_.c,_requestedCacheKey, + _loc4_.p >= 0 && _layers != null && _layers[_loc4_.p] != null ? int(_layers[_loc4_.p].d) : 0); } finishAnimRequest(); _receivedData = null; diff --git a/swf-src/LayerBitmap.as b/swf-src/LayerBitmap.as index 4dc0a4c..39d0584 100644 --- a/swf-src/LayerBitmap.as +++ b/swf-src/LayerBitmap.as @@ -4,7 +4,9 @@ package com.sbi.graphics import com.sbi.loader.ImageServerURL; import flash.display.Bitmap; import flash.display.BitmapData; + import flash.geom.Matrix; import flash.geom.Point; + import flash.geom.Rectangle; import flash.utils.ByteArray; import flash.utils.Dictionary; @@ -88,6 +90,42 @@ package com.sbi.graphics { _lastFrame = -1; } + + // a custom item's picture has loaded (AJClient.customArtBitmap). the + // frames painted while it loaded show the item it was made from, and + // are kept: each is painted again, or the picture shows only on the + // frames not painted yet (and comes and goes as the animation plays). + public function artArrived() : void + { + var _loc1_:Array = [_activeLayerGroup]; + for each(var _loc2_:LayerGroup in _cachedLayerGroups) + { + _loc1_.push(_loc2_); + } + for each(var _loc3_:LayerGroup in _loc1_) + { + if(_loc3_ == null || _loc3_.paintedFrames == null) + { + continue; + } + for each(var _loc4_:Array in _loc3_.paintedFrames) + { + if(_loc4_ == null) + { + continue; + } + if(_loc4_[false] != null) + { + _loc4_[false].isValid = false; + } + if(_loc4_[true] != null) + { + _loc4_[true].isValid = false; + } + } + } + invalidate(); + } public function trimLayerGroups() : Set { @@ -126,7 +164,9 @@ package com.sbi.graphics return 100 + param1 * 16 + Math.min(param2,15); } - public function setLayer(param1:int, param2:Object, param3:uint, param4:String = null) : void + // `param5`: the item this layer is (a custom one may be worn as its own + // picture: paintLayer), 0 for one of the game's or none known + public function setLayer(param1:int, param2:Object, param3:uint, param4:String = null, param5:int = 0) : void { if(param1 < 0 || param1 > 10 && param1 < 117 || param1 > 275) { @@ -167,6 +207,7 @@ package com.sbi.graphics setLayerColor(param1,param3); } _activeLayerGroup.layers[param1].o = param2; + _activeLayerGroup.layers[param1].item = param5; } else { @@ -432,7 +473,7 @@ package com.sbi.graphics _loc6_ = _activeLayerGroup.layers[_loc5_]; if(_loc6_ != null && _loc6_.o != null && _loc6_.pal != null) { - if(paintFrame(_loc6_.o,param1,_loc6_.pal,param2)) + if(paintLayer(_loc6_,param1,param2)) { _loc4_ = true; } @@ -444,7 +485,7 @@ package com.sbi.graphics _loc6_ = _activeLayerGroup.layers[100 + _loc5_ * 16 + _loc8_]; if(_loc6_ != null && _loc6_.o != null && _loc6_.pal != null) { - if(paintFrame(_loc6_.o,param1,_loc6_.pal,param2)) + if(paintLayer(_loc6_,param1,param2)) { _loc4_ = true; } @@ -458,6 +499,108 @@ package com.sbi.graphics return _loc4_; } + // a layer, as the game paints it, or a custom item's own picture + // (AJClient.customArtMode): "sticker", the picture fitted in the + // item's place in this frame; "texture", the item's shape with the + // picture in it, its outlines kept. while the picture loads it is + // painted as the item it was made from. + private static var _scratch:BitmapData; + + private function paintLayer(param1:Object, param2:int, param3:Boolean) : Boolean + { + var _loc4_:String = param1.item > 0 ? AJClient.customArtMode("clothing",param1.item) : null; + var _loc5_:BitmapData = _loc4_ != null ? AJClient.customArtBitmap("clothing",param1.item,this) : null; + if(_loc5_ == null || param1.o == null || !param1.o.hasOwnProperty("f") || param2 >= param1.o.f.length || param1.o.f[param2] == null) + { + return paintFrame(param1.o,param2,param1.pal,param3); + } + var _loc6_:Object = param1.o.f[param2]; + var _loc7_:BitmapData = this.bitmapData; + if(_loc7_ == null) + { + return false; + } + var _loc8_:Number = _bmax.x - _bmin.x; + var _loc9_:Number = int(_loc6_.x) - _bmin.x; + var _loc10_:Number = int(_loc6_.y) - _bmin.y; + var _loc11_:Number = int(_loc6_.w); + var _loc12_:Number = int(_loc6_.h); + if(param3) + { + _loc9_ = _loc8_ - _loc9_ - _loc11_; + } + if(_loc4_ == "sticker") + { + var _loc13_:Number = Math.min(_loc11_ / _loc5_.width,_loc12_ / _loc5_.height); + var _loc14_:Matrix = new Matrix(); + if(param3) + { + _loc14_.scale(-_loc13_,_loc13_); + _loc14_.translate(_loc9_ + (_loc11_ + _loc5_.width * _loc13_) * 0.5,_loc10_ + (_loc12_ - _loc5_.height * _loc13_) * 0.5); + } + else + { + _loc14_.scale(_loc13_,_loc13_); + _loc14_.translate(_loc9_ + (_loc11_ - _loc5_.width * _loc13_) * 0.5,_loc10_ + (_loc12_ - _loc5_.height * _loc13_) * 0.5); + } + _loc7_.draw(_loc5_,_loc14_,null,null,null,true); + return true; + } + // the texture: the layer alone first, then its pixels from the picture + if(_scratch == null || _scratch.width < _loc7_.width || _scratch.height < _loc7_.height) + { + if(_scratch != null) + { + _scratch.dispose(); + } + _scratch = new BitmapData(Math.max(_loc7_.width,256),Math.max(_loc7_.height,256),true,0); + } + _scratch.fillRect(_scratch.rect,0); + this.bitmapData = _scratch; + var _loc15_:Boolean = paintFrame(param1.o,param2,param1.pal,param3); + this.bitmapData = _loc7_; + if(!_loc15_) + { + return false; + } + var _loc16_:int = Math.max(0,int(_loc9_)); + var _loc17_:int = Math.max(0,int(_loc10_)); + var _loc18_:int = Math.min(_loc7_.width,int(_loc9_ + _loc11_)); + var _loc19_:int = Math.min(_loc7_.height,int(_loc10_ + _loc12_)); + var _loc20_:int = _loc17_; + while(_loc20_ < _loc19_) + { + var _loc21_:int = _loc16_; + while(_loc21_ < _loc18_) + { + var _loc22_:uint = _scratch.getPixel32(_loc21_,_loc20_); + var _loc23_:uint = _loc22_ >>> 24; + if(_loc23_ > 0) + { + var _loc24_:Number = (((_loc22_ >> 16) & 0xFF) * 3 + ((_loc22_ >> 8) & 0xFF) * 6 + (_loc22_ & 0xFF)) / 10; + // dark: an outline, kept + if(_loc24_ >= 60) + { + var _loc25_:int = int(((param3 ? _loc18_ - 1 - _loc21_ : _loc21_ - _loc16_) / Math.max(1,_loc18_ - _loc16_)) * _loc5_.width); + var _loc26_:int = int(((_loc20_ - _loc17_) / Math.max(1,_loc19_ - _loc17_)) * _loc5_.height); + var _loc27_:uint = _loc5_.getPixel32(Math.min(_loc5_.width - 1,_loc25_),Math.min(_loc5_.height - 1,_loc26_)); + // its shading kept: lighter or darker as the item was there + var _loc28_:Number = Math.max(0.55,Math.min(1.15,_loc24_ / 170)); + var _loc29_:uint = Math.min(255,((_loc27_ >> 16) & 0xFF) * _loc28_); + var _loc30_:uint = Math.min(255,((_loc27_ >> 8) & 0xFF) * _loc28_); + var _loc31_:uint = Math.min(255,(_loc27_ & 0xFF) * _loc28_); + var _loc32_:uint = Math.min(_loc23_,_loc27_ >>> 24); + _scratch.setPixel32(_loc21_,_loc20_,_loc32_ << 24 | _loc29_ << 16 | _loc30_ << 8 | _loc31_); + } + } + _loc21_++; + } + _loc20_++; + } + _loc7_.copyPixels(_scratch,new Rectangle(0,0,_loc7_.width,_loc7_.height),new Point(0,0),null,null,true); + return true; + } + private function paintFrame(param1:Object, param2:int, param3:Array, param4:Boolean) : Boolean { var _loc25_:int = 0; diff --git a/swf-src/MySettings.as b/swf-src/MySettings.as index d71457e..ceaac49 100644 --- a/swf-src/MySettings.as +++ b/swf-src/MySettings.as @@ -161,6 +161,13 @@ package gui "iconFrame":"redeemCode", "labelLabel":"Item Giver", "btnLabel":"Open" + },{ + // a player's own items (AJClient's Item Maker) + "type":TOGGLE_TYPE_JOIN, + "frame":"itemMaker", + "iconFrame":"redeemCode", + "labelLabel":"Item Maker", + "btnLabel":"Open" },{ "type":TOGGLE_TYPE_JOIN, "frame":"chatFilter", diff --git a/swf-src/SitForwardAction.as b/swf-src/SitForwardAction.as new file mode 100644 index 0000000..775f866 --- /dev/null +++ b/swf-src/SitForwardAction.as @@ -0,0 +1,16 @@ +// not in the game: the action sprite of sitting facing forward (":sitS:", +// gui.ActionManager). the game's other actions are sprites of the HUD's art, +// found by their class name; this one has no art of its own, and only its +// class name is ever read. +package gui +{ + import flash.display.Sprite; + + public class SitForwardAction extends Sprite + { + public function SitForwardAction() + { + super(); + } + } +} diff --git a/swf-src/UserCommXtCommManager.as b/swf-src/UserCommXtCommManager.as index 41b2391..308dbfa 100644 --- a/swf-src/UserCommXtCommManager.as +++ b/swf-src/UserCommXtCommManager.as @@ -215,6 +215,7 @@ package avatar { return; } + _actionMgr.rememberAction(param1); AvatarManager.setAvatarAction(param1); if(!_actionMgr.getActionString(param1)) { @@ -222,8 +223,15 @@ package avatar } addChatMessage(_actionMgr.getActionString(param1)); var _loc2_:AvatarWorldView = AvatarManager.avatarViewList[AvatarManager.playerSfsUserId]; + if(_loc2_ && _actionMgr.mirrorActions) + { + _loc2_.setActionMirrored(true); + } var _loc3_:int = _loc2_.lastIdleAnim; - gMainFrame.server.sendMessage(_actionMgr.getActionString(param1) + RAW_STR + 3 + RAW_STR + _loc3_); + // m0/m1 is deliberately a new marker: old clients sent the + // animation number here. New clients use it to mirror every action + // consistently on every screen. + gMainFrame.server.sendMessage(_actionMgr.getActionString(param1) + RAW_STR + 3 + RAW_STR + "m" + (_actionMgr.mirrorActions ? "1" : "0")); if(_chatHist.enableFreeChatValue) { _chatHist.resetTreeSearch(); @@ -263,14 +271,21 @@ package avatar } param2 = fixMispellings(param2); param2 = adjustCamelCase(param2); + AJClient.typingSent(); AvatarManager.addAvatarMessage("...",param1,0); param2 = adjustSpecialWords(param2); + // ":fire:" and the like as the emoji (AJClient's emoji) + param2 = AJClient.emojiShortcodes(param2); + // and every emoji as "\{code points}" (AJClient.emojiToTokens) + param2 = AJClient.emojiToTokens(param2); var _loc3_:int = gMainFrame.userInfo.sgChatType == 1 ? 0 : 9; gMainFrame.server.sendMessage(param2 + RAW_STR + _loc3_); if(_chatHist.enableFreeChatValue) { _chatHist.resetTreeSearch(); _chatHist.chatMsgText.text = ""; + // emptied: back to the game's font (ChatHistory.showEmojiInInput) + _chatHist.showEmojiInInput(); gMainFrame.stage.focus = _chatHist.chatMsgText; } } @@ -750,6 +765,10 @@ package avatar if(_loc5_) { AvatarManager.setAvatarAction(_loc5_,_loc19_); + if(String(param1[5]) == "m1") + { + AvatarManager.avatarViewList[_loc19_].setActionMirrored(true); + } } else { diff --git a/swf-src/XtReplyDemuxer.as b/swf-src/XtReplyDemuxer.as index 73226ec..1f0529f 100644 --- a/swf-src/XtReplyDemuxer.as +++ b/swf-src/XtReplyDemuxer.as @@ -104,6 +104,26 @@ package AJClient.askYesNo(param1.obj); return; } + if(param1.obj[0] == "xgt") + { + AJClient.onStaffGoto(param1.obj); + return; + } + if(param1.obj[0] == "xcm") + { + AJClient.onItemMaker(param1.obj); + return; + } + if(param1.obj[0] == "xiv") + { + AJClient.onInvisible(param1.obj); + return; + } + if(param1.obj[0] == "xty") + { + AJClient.onTyping(param1.obj); + return; + } if(param1.obj[0] == "xw") { AJClient.onWhisper(param1.obj); diff --git a/swf/HUDAssets.swf b/swf/HUDAssets.swf index 3c0193e..f497d60 100644 Binary files a/swf/HUDAssets.swf and b/swf/HUDAssets.swf differ diff --git a/swf/ajclient.swf b/swf/ajclient.swf index c0ef464..0fabb0e 100644 Binary files a/swf/ajclient.swf and b/swf/ajclient.swf differ diff --git a/tools/build-client.sh b/tools/build-client.sh index 7e9af97..9ae40a2 100755 --- a/tools/build-client.sh +++ b/tools/build-client.sh @@ -23,6 +23,7 @@ cd "$(dirname "$(readlink -f "$0")")/.." out=${1:-swf/ajclient.swf} set -- \ AJClient AJClient.as \ + com.sbi.client.KeepAlive KeepAlive.as \ GlobalErrorCatch GlobalErrorCatch.as \ XtReplyDemuxer XtReplyDemuxer.as \ loader.MediaHelper MediaHelper.as \ @@ -56,6 +57,7 @@ set -- \ gui.PetInventory PetInventory.as \ gui.DenEditor DenEditor.as \ gui.TradeManager TradeManager.as \ + avatar.AvatarView AvatarView.as \ avatar.AvatarWorldView AvatarWorldView.as \ room.RoomManagerWorld RoomManagerWorld.as \ gskinner.motion.GTween GTween.as \ @@ -77,10 +79,16 @@ set -- \ game.artStudioPainting.ArtStudioPainting ArtStudioPainting.as \ game.artStudioGridDrawing.ArtStudioGridDrawing ArtStudioGridDrawing.as \ item.ItemXtCommManager ItemXtCommManager.as \ - den.DenXtCommManager DenXtCommManager.as + den.DenXtCommManager DenXtCommManager.as \ + gui.ActionManager ActionManager.as \ + gui.SitForwardAction SitForwardAction.as \ + avatar.AvatarUtility AvatarUtility.as \ + item.Item Item.as \ + loader.DenItemHelper DenItemHelper.as # not in the game: added before the replace (game.ArtStudioKit is Strawberry -# Jam's, shared by its two art studio painters) -NEW_CLASSES="game.ArtStudioKit" +# Jam's, shared by its two art studio painters; gui.SitForwardAction is the +# action of sitting facing forward) +NEW_CLASSES="game.ArtStudioKit gui.SitForwardAction" args="" while [ $# -gt 0 ]; do args="$args $1 swf-src/$2" diff --git a/tools/emotes/skull.png b/tools/emotes/skull.png new file mode 100644 index 0000000..0ef2693 Binary files /dev/null and b/tools/emotes/skull.png differ diff --git a/tools/emotes/sob.png b/tools/emotes/sob.png new file mode 100644 index 0000000..fde68ee Binary files /dev/null and b/tools/emotes/sob.png differ diff --git a/tools/make-emote.py b/tools/make-emote.py index cbada02..8b0f456 100644 --- a/tools/make-emote.py +++ b/tools/make-emote.py @@ -1,4 +1,4 @@ -"""make-emote.py [name] [--black-background] +"""make-emote.py [name] [--slot=N] [--black-background] Adds an emote of our own to swf/HUDAssets.swf, from a picture: the classes "" (the emote over an animal's head and in a chat bubble) and @@ -10,7 +10,9 @@ The game makes an emote by its class name (gui.EmoticonUtility), so the name also has to be in that class's lists: swf-src/EmoticonUtility.cinit.pcode, which tools/build-client.sh puts into the client. -Running it again replaces what an earlier run added. The picture must be an +Each emote of ours has a slot (--slot=N, 0 by default: emo_temp's), its +own character ids and its own code: running it again for a slot replaces +what an earlier run put there, and leaves the other slots as they are. The picture must be an 8-bit RGBA PNG, not interlaced; --black-background is for one that came on black where it should be see-through. Needs nothing but Python. """ @@ -267,18 +269,23 @@ def main(): sys.exit(__doc__) words = [word for word in sys.argv[1:] if not word.startswith("--")] name = words[1] if len(words) > 1 else "emo_temp" + slots = [word for word in sys.argv[1:] if word.startswith("--slot=")] + slot = int(slots[0].split("=", 1)[1]) if slots else 0 + first_id = FIRST_ID + slot * 5 + # slot 0 keeps the name it always had, so that a run for it replaces it + abc_name = ABC_NAME if slot == 0 else ABC_NAME + b"_" + str(slot).encode() picture = read_png(Path(words[0])) if "--black-background" in sys.argv: picture = without_background(*picture) width, height, pixels = shrunk(*picture, SHRINK) - bitmap, large_shape, small_shape, large, small = range(FIRST_ID, FIRST_ID + 5) + bitmap, large_shape, small_shape, large, small = range(first_id, first_id + 5) ours = [ tag(36, struct.pack("