Files
Burrowdev 33f56074a4 feat: discord linking, @tags, music and sfx sliders, required device ids
- Discord: the account page links a player's Discord account through
  Discord's sign-in (lib/discord.js); only linked names are shown on cards
  (typed ones are cleared). A bot keeps the Server Booster badge on linked
  accounts that boost. The game tells the client where the player is, for
  the client's Discord rich presence (flashvars discordAppId).
- @username tags in chat, chat balloons and wall posts: only real players'
  names (asked of the server, "xmn"), names with spaces too, drawn on a
  blue box; a click opens the player's card.
- Settings: separate Music and SFX volume sliders for the old one.
- Device ids required: a launcher that sends none (before 1.3.0) is told
  at the game's login "Your client is outdated. Update at
  https://burrow.moe/download". AJ_REQUIRE_DEVICE=0 turns it off.
- Panels: clear a player's Jammer Wall posts; turning away masterpieces
  and player items asks first.
- Item Giver: negative colour ids (the same colour written signed).
- buildVersion 71; the client rebuilt with Snipzil's sitting fix.
2026-10-18 19:35:51 +03:00

427 lines
14 KiB
ActionScript

package gui.itemWindows
{
import avatar.Avatar;
import avatar.AvatarDef;
import avatar.AvatarUtility;
import avatar.AvatarView;
import avatar.AvatarXtCommManager;
import buddy.Buddy;
import buddy.BuddyList;
import buddy.BuddyManager;
import collection.AccItemCollection;
import com.sbi.corelib.input.SBTextField;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.text.TextField;
import flash.utils.setTimeout;
import gui.LoadingSpiral;
import item.EquippedAvatars;
import item.Item;
import loader.MediaHelper;
import localization.LocalizationManager;
import playerWall.PostMessage;
public class ItemWindowPost extends ItemWindowBase
{
private var _iconMediaHelper:MediaHelper;
private var _onReportDown:Function;
private var _onDeleteDown:Function;
private var _onReplyDown:Function;
private var _smileyText:SBTextField;
// the field the message is drawn in, and its tags once the server has
// said which "@"s are players' (AJClient.resolveMentions)
private var _messageField:TextField;
private var _mentions:Array = [];
private var _isMyPost:Boolean;
private var _patternWindow:ItemWindowPattern;
private var _hasSetInitialConditions:Boolean;
public function ItemWindowPost(param1:Function, param2:Object, param3:String, param4:int, param5:Function = null, param6:Function = null, param7:Function = null, param8:Function = null, param9:Object = null)
{
_onReportDown = param9.reportMsgBtnMouseDown;
_onDeleteDown = param9.deleteMsgBtnMouseDown;
_onReplyDown = param9.replyMsgBtnMouseDown;
_isMyPost = param9.isMyPost;
tabEnabled = false;
super(1501,param1,param2,param3,param4,param5,param6,param7,param8);
}
public function get msgId() : String
{
return _currItem.msgId;
}
public function get senderUserName() : String
{
return _currItem.senderUserName;
}
public function get senderModeratedUserName() : String
{
return _currItem.senderModeratedUserName;
}
public function get parentOrMyPostMessageId() : String
{
if((_currItem as PostMessage).parentMessageId != null)
{
return (_currItem as PostMessage).parentMessageId;
}
return msgId;
}
public function get sizeCont() : MovieClip
{
return MovieClip(_window.parent).sizeCont;
}
public function darken(param1:Boolean) : void
{
if(_window)
{
_window.darkCont.visible = param1;
}
}
public function update() : void
{
var _loc1_:Number = new Date().valueOf();
_loc1_ += Utility.getTimeOffset();
var _loc2_:Object = Utility.calculateTime((_loc1_ - _currItem.postTime) / 1000);
if(_loc2_.mins < 0)
{
_loc2_.mins = 0;
}
if(_loc2_.mins == 0 && _loc2_.hours < 1 && _loc2_.days < 1)
{
_window.dark.timeTxt.text = Utility.calculatePrintTimeToNearest(_loc2_.mins,_loc2_.hours,true,_loc2_.days);
}
else
{
LocalizationManager.translateIdAndInsert(_window.dark.timeTxt,11360,Utility.calculatePrintTimeToNearest(_loc2_.mins,_loc2_.hours,true,_loc2_.days));
}
}
public function updateWithInput(param1:PostMessage) : void
{
if(_smileyText && param1)
{
_smileyText.text = param1.message;
showMentions();
}
}
override public function destroy() : void
{
removeEventListeners();
if(_iconMediaHelper)
{
_iconMediaHelper.destroy();
_iconMediaHelper = null;
}
_onReportDown = null;
_onDeleteDown = null;
if(_smileyText)
{
_smileyText.destroy();
_smileyText = null;
}
_messageField = null;
_window = null;
_windowLoadedCallback = null;
_currItem = null;
_mouseDown = null;
_mouseOver = null;
_mouseOut = null;
}
override public function loadCurrItem(param1:int = 0, param2:int = 0) : void
{
_itemYLocation = param1;
_itemXLocation = param2;
if(_currItem && !_isCurrItemLoaded)
{
if(!_spiral)
{
_spiral = new LoadingSpiral(_window.iconLayer);
}
else
{
_spiral.setNewParent(_window.iconLayer);
}
_messageField = _window.dark.messageTxt;
_smileyText = new SBTextField(null,_messageField,_window.textItemHolder,true);
_smileyText.text = _currItem.message;
showMentions();
_smileyText.mouseEnabled = false;
_smileyText.selectable = false;
if(!_isMyPost)
{
_window.reportMessageBtn.x += _window.reportMessageBtn.width;
}
_isCurrItemLoaded = true;
setupCurrAvtImage();
}
}
override public function setStatesForVisibility(param1:Boolean, param2:Object = null) : void
{
}
override protected function onWindowLoadCallback() : void
{
setChildrenAndInitialConditions();
super.onWindowLoadCallback();
}
override protected function setChildrenAndInitialConditions() : void
{
if(!_hasSetInitialConditions)
{
_hasSetInitialConditions = true;
if(_currItem)
{
if(_currItem.senderUserName.toLowerCase() == gMainFrame.userInfo.myUserName.toLowerCase())
{
if(hasParent())
{
_window.gotoAndStop("playerReply");
_window = _window.playerReply;
}
else
{
_window.gotoAndStop("player");
_window = _window.player;
}
}
else if(hasParent())
{
_window.gotoAndStop("buddiesReply");
_window = _window.buddiesReply;
}
else
{
_window.gotoAndStop("buddies");
_window = _window.buddies;
}
darken(false);
loadPostPattern();
_window.reportMessageBtn.visible = false;
_window.deleteMessageBtn.visible = false;
_window.replyMessageBtn.visible = false;
_window.updateColor(_currItem.colorId);
_window.dark.messageTxt.text = "";
_window.dark.messageTxt.selectable = false;
LocalizationManager.updateToFit(_window.dark.nameTxt,_currItem.senderModeratedUserName);
_window.dark.timeTxt.autoSize = "right";
if(_window.newIcon != null)
{
_window.newIcon.visible = false;
}
if(_currItem.isBuddy && _currItem.senderUserName.toLowerCase() != gMainFrame.userInfo.myUserName.toLowerCase())
{
_window.buddyIcon.visible = true;
}
else
{
_window.buddyIcon.visible = false;
}
update();
}
addEventListeners();
}
}
override protected function addEventListeners() : void
{
if(_isMyPost)
{
_window.deleteMessageBtn.addEventListener("mouseDown",_onDeleteDown,false,0,true);
}
_window.reportMessageBtn.addEventListener("mouseDown",_onReportDown,false,0,true);
_window.replyMessageBtn.addEventListener("mouseDown",_onReplyDown,false,0,true);
_window.darkCont.addEventListener("mouseDown",onDarkCont,false,0,true);
addEventListener("rollOver",onPostRollOverOut,false,0,true);
addEventListener("rollOut",onPostRollOverOut,false,0,true);
addEventListener("mouseDown",onPostDown,false,0,true);
}
override protected function removeEventListeners() : void
{
if(_isMyPost)
{
_window.deleteMessageBtn.removeEventListener("mouseDown",_onDeleteDown);
}
_window.reportMessageBtn.removeEventListener("mouseDown",_onReportDown);
_window.replyMessageBtn.removeEventListener("mouseDown",_onReplyDown);
_window.darkCont.removeEventListener("mouseDown",onDarkCont);
removeEventListener("rollOver",onPostRollOverOut);
removeEventListener("rollOut",onPostRollOverOut);
removeEventListener("mouseDown",onPostDown);
}
// tags: light blue and underlined; a click on one opens that player's
// card (onPostDown), anywhere else the writer's.
private function showMentions() : void
{
var field:TextField = _messageField;
var shown:String = field != null ? field.text : "";
_mentions = [];
AJClient.drawMentionBacks(field,null);
if(shown.indexOf("@") == -1)
{
return;
}
AJClient.resolveMentions(shown,function(param1:Array):void
{
if(_messageField == field && field.text == shown)
{
_mentions = param1;
AJClient.styleMentions(field,param1,false);
// and their backgrounds, now and once laid out for sure
AJClient.drawMentionBacks(field,param1,AJClient.MENTION_BACK_LIGHT);
setTimeout(function():void
{
if(_messageField == field && field.text == shown)
{
AJClient.drawMentionBacks(field,param1,AJClient.MENTION_BACK_LIGHT);
}
},42);
}
});
}
private function hasParent() : Boolean
{
return (_currItem as PostMessage).parentMessageId != null && (_currItem as PostMessage).parentMessageId.length > 0;
}
private function onDarkCont(param1:MouseEvent) : void
{
param1.stopPropagation();
}
private function onPostDown(param1:MouseEvent) : void
{
param1.stopPropagation();
var _loc2_:String = AJClient.mentionAt(_messageField,_mentions);
if(_loc2_ != null)
{
AJClient.openProfile(_loc2_);
return;
}
if(_window && _currItem.senderUserName.toLowerCase() != gMainFrame.userInfo.myUserName.toLowerCase())
{
BuddyList.requestBuddyListIfNeeded(onBuddyListRequested);
}
}
private function onBuddyListRequested() : void
{
var _loc1_:Buddy = BuddyManager.getBuddyByUserName(_currItem.senderUserName);
if(_loc1_)
{
BuddyManager.showBuddyCard({
"userName":_loc1_.userName,
"onlineStatus":_loc1_.onlineStatus
});
return;
}
AvatarXtCommManager.requestAvatarGet(_currItem.senderUserName,onUserLookUpReceived,true);
}
private function onUserLookUpReceived(param1:String, param2:Boolean, param3:int) : void
{
if(param2)
{
BuddyManager.showBuddyCard({
"userName":param1,
"onlineStatus":param3
});
}
}
private function onPostRollOverOut(param1:MouseEvent) : void
{
param1.stopPropagation();
if(_window)
{
if(_window.messageHighlight.currentFrameLabel != "on")
{
_window.messageHighlight.gotoAndStop("on");
_window.reportMessageBtn.visible = _currItem.senderUserName != gMainFrame.userInfo.myUserName;
_window.replyMessageBtn.visible = true;
if(_isMyPost)
{
_window.deleteMessageBtn.visible = true;
}
}
else
{
_window.messageHighlight.gotoAndStop("off");
_window.reportMessageBtn.visible = false;
_window.replyMessageBtn.visible = false;
if(_isMyPost)
{
_window.deleteMessageBtn.visible = false;
}
}
}
}
private function loadPostPattern() : void
{
_patternWindow = new ItemWindowPattern(null,3983,"",0,null,null,null,null,{
"type":(hasParent() ? "reply" : "message"),
"colorIndex":_currItem.colorId,
"patternIndex":_currItem.patternId
});
_window.messageBodyHolder.addChild(_patternWindow);
}
private function setupCurrAvtImage() : void
{
var _loc5_:Avatar = new Avatar();
_loc5_.init(-1,-1,"",_currItem.avtDefId,_currItem.avtColors,_currItem.avtCustomId,null,_currItem.senderUserName);
var _loc3_:AccItemCollection = new AccItemCollection();
var _loc2_:Item = new Item();
_loc3_.setAccItem(0,_loc2_);
_loc2_.init(1,1,0,EquippedAvatars.forced());
_loc2_ = new Item();
_loc3_.setAccItem(1,_loc2_);
_loc2_.init(_currItem.avtEyeDefId > 0 ? _currItem.avtEyeDefId : 2,2,0,EquippedAvatars.forced());
var _loc6_:AvatarDef = gMainFrame.userInfo.getAvatarDefByAvatar(_loc5_);
if(_currItem.avtCustomId != -1 && _loc6_ && _currItem.avtPatternDefId < 1)
{
_currItem.avtPatternDefId = _loc6_.patternRefIds[0];
}
if(_currItem.avtPatternDefId > 0)
{
_loc2_ = new Item();
_loc3_.setAccItem(2,_loc2_);
_loc2_.init(_currItem.avtPatternDefId,3,0,EquippedAvatars.forced());
}
_loc5_.itemResponseIntegrate(_loc3_);
var _loc1_:AvatarView = new AvatarView();
_loc1_.init(_loc5_,null);
_loc1_.playAnim(15,false,1,null,true);
var _loc4_:Point = AvatarUtility.getAvatarHudPosition(_loc1_.avTypeId);
_loc1_.x = _loc4_.x + _window.charCont.width * 0.5;
_loc1_.y = _loc4_.y + _window.charCont.height * 0.5;
_window.charCont.charLayer.addChild(_loc1_);
}
}
}