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.
This commit is contained in:
Burrowdev committed 2026-10-18 19:35:51 +03:00
1 parent 1d9b70f32e
commit 33f56074a4
35 files changed
+2076 -101

No files matched your search

+507 -4
View File
@@ -2,6 +2,11 @@ package
{
import avatar.AvatarManager;
import avatar.AvatarWorldView;
import buddy.Buddy;
import buddy.BuddyManager;
import com.sbi.corelib.audio.SBAudio;
import com.sbi.corelib.audio.SBMusic;
import com.sbi.corelib.audio.SBSound;
import com.sbi.debug.DebugUtility;
import com.sbi.graphics.PaletteHelper;
import den.DenXtCommManager;
@@ -27,9 +32,11 @@ package
import flash.geom.Matrix;
import flash.utils.ByteArray;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.media.SoundTransform;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLLoader;
@@ -47,6 +54,7 @@ package
import flash.utils.Dictionary;
import flash.utils.Timer;
import flash.utils.getTimer;
import flash.utils.setTimeout;
import game.MinigameManager;
import gamePlayFlow.GamePlay;
import gskinner.motion.GTween;
@@ -2291,7 +2299,8 @@ package
finderButtonText(_finderKindButton,"All items");
_finderKindButton.addEventListener("mouseDown",onFinderKindClick);
_loc2_.addChild(_finderKindButton);
_finderColourBar = finderSearchBar(93,-160,156,"Colour ID or #hex","0-9a-fA-F# ,",31,false);
// a colour id may be negative: the signed way of writing it (lib/admin.js)
_finderColourBar = finderSearchBar(93,-160,156,"Colour ID or #hex","0-9a-fA-F# ,\\-",31,false);
_finderColourInput = _finderColourBar.searchTxt;
_finderColourInput.addEventListener("change",onFinderColourTyped);
_loc2_.addChild(_finderColourBar);
@@ -2880,6 +2889,499 @@ package
});
}
// tags: "@name" in chat and on Jammer Walls, when the name is a
// player's, is drawn light blue and underlined, and opens that player's
// card when clicked. which names are players' the server says (xmn,
// lib/world.js): the longest name the text after the "@" starts with,
// spaces and all ("@John Smith hi"), ending where a word does. a "@"
// counts at the start or after a character no name has ("me@home" is
// no tag). what is no player's name stays plain text.
public static const MENTION_COLOR:uint = 4895732; // #4ab3f4
private static const MENTION_TEXT:int = 40; // characters after an "@" asked about
private static const MENTION_ASK_MOST:int = 10; // texts in one question, as the server takes
private static const MENTION_WAIT_MS:int = 3000; // no answer by then: no tags in that text
private static const MENTION_KEEP:int = 2000; // answers kept before starting over
private static var _mentionKnown:Object = {}; // lowercased text after an "@" -> {length, name} or null
private static var _mentionKnownCount:int = 0;
private static var _mentionOnline:Object = {}; // lowercased name -> 1 | 0, as last heard
private static var _mentionAsks:Object = {}; // question id -> {texts, finish}
private static var _mentionNextId:int = 1;
// the "@"s that could start a tag: [{at, text}], `text` what follows,
// up to a "%" or a line's end (neither is in a name).
private static function mentionStarts(param1:String) : Array
{
var _loc2_:Array = [];
var _loc3_:int = param1 == null ? -1 : param1.indexOf("@");
var _loc4_:String = null;
var _loc5_:String = null;
while(_loc3_ != -1)
{
_loc4_ = _loc3_ > 0 ? param1.charAt(_loc3_ - 1) : " ";
if(!/[A-Za-z0-9.\-@]/.test(_loc4_) && /[A-Za-z0-9]/.test(param1.charAt(_loc3_ + 1)))
{
_loc5_ = param1.substr(_loc3_ + 1,MENTION_TEXT).split("%")[0].split("\r")[0].split("\n")[0];
_loc2_.push({
"at":_loc3_,
"text":_loc5_
});
}
_loc3_ = param1.indexOf("@",_loc3_ + 1);
}
return _loc2_;
}
// [{at, length, name}] for the starts the server has said are tags:
// `at` at the "@", `length` with it, `name` as the account spells it.
private static function mentionsFound(param1:Array) : Array
{
var _loc2_:Array = [];
var _loc3_:Object = null;
var _loc4_:Object = null;
for each(_loc3_ in param1)
{
_loc4_ = _mentionKnown[String(_loc3_.text).toLowerCase()];
if(_loc4_ != null)
{
_loc2_.push({
"at":_loc3_.at,
"length":_loc4_.length + 1,
"name":_loc4_.name
});
}
}
return _loc2_;
}
// the tags in a text, given to `param2` as [{at, length, name}]: at
// once when every name in it is known, else when the server answers
// (or does not, in MENTION_WAIT_MS: then only the known ones).
public static function resolveMentions(param1:String, param2:Function) : void
{
var _loc3_:Array = mentionStarts(param1);
var _loc4_:Array = [];
var _loc5_:Array = [];
var _loc6_:Object = null;
var _loc7_:String = null;
var _loc8_:int = 0;
var _loc9_:Function = null;
for each(_loc6_ in _loc3_)
{
_loc7_ = String(_loc6_.text).toLowerCase();
if(!(_loc7_ in _mentionKnown) && _loc5_.indexOf(_loc7_) == -1 && _loc4_.length < MENTION_ASK_MOST)
{
_loc5_.push(_loc7_);
_loc4_.push(_loc6_.text);
}
}
if(_loc4_.length == 0)
{
param2(mentionsFound(_loc3_));
return;
}
_loc8_ = _mentionNextId++;
_loc9_ = function():void
{
if(_loc8_ in _mentionAsks)
{
delete _mentionAsks[_loc8_];
param2(mentionsFound(_loc3_));
}
};
_mentionAsks[_loc8_] = {
"texts":_loc4_,
"finish":_loc9_
};
gMainFrame.server.setXtObject_Str("xmn",[_loc8_].concat(_loc4_));
setTimeout(_loc9_,MENTION_WAIT_MS);
}
// "xmn": [.., .., id, then for each text asked about: length of the
// name it starts with (0: none), the name, 1 if they are online].
public static function onMentions(param1:Object) : void
{
var _loc2_:Object = _mentionAsks[int(param1[2])];
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc5_:String = null;
if(_loc2_ == null)
{
return;
}
if(_mentionKnownCount > MENTION_KEEP)
{
_mentionKnown = {};
_mentionKnownCount = 0;
}
_loc3_ = 0;
while(_loc3_ < _loc2_.texts.length && 5 + _loc3_ * 3 < param1.length)
{
_loc4_ = int(param1[3 + _loc3_ * 3]);
_loc5_ = String(param1[4 + _loc3_ * 3]);
_mentionKnown[String(_loc2_.texts[_loc3_]).toLowerCase()] = _loc4_ > 0 ? {
"length":_loc4_,
"name":_loc5_
} : null;
_mentionKnownCount++;
if(_loc4_ > 0)
{
_mentionOnline[_loc5_.toLowerCase()] = int(param1[5 + _loc3_ * 3]);
}
_loc3_++;
}
_loc2_.finish();
}
// colours tags (resolveMentions) in a text field that reads as it did
// then: MENTION_COLOR, or `param4` when given. with `param3`, each is
// also a link ("event:@name", heard as a "link" event).
public static function styleMentions(param1:TextField, param2:Array, param3:Boolean, param4:int = -1) : void
{
var _loc4_:Object = null;
var _loc5_:TextFormat = null;
if(param1 == null || param2 == null)
{
return;
}
for each(_loc4_ in param2)
{
if(_loc4_.at + _loc4_.length <= param1.length)
{
_loc5_ = new TextFormat();
_loc5_.color = param4 >= 0 ? param4 : MENTION_COLOR;
_loc5_.underline = true;
if(param3)
{
_loc5_.url = "event:@" + _loc4_.name;
}
param1.setTextFormat(_loc5_,_loc4_.at,_loc4_.at + _loc4_.length);
}
}
}
// the name of the tag under the mouse in a text field, or null.
public static function mentionAt(param1:TextField, param2:Array) : String
{
var _loc3_:int = param1 == null || param2 == null ? -1 : param1.getCharIndexAtPoint(param1.mouseX,param1.mouseY);
var _loc4_:Object = null;
if(_loc3_ < 0)
{
return null;
}
for each(_loc4_ in param2)
{
if(_loc3_ >= _loc4_.at && _loc3_ < _loc4_.at + _loc4_.length)
{
return _loc4_.name;
}
}
return null;
}
// a tagged player's card (the server has said the name is theirs).
public static function openProfile(param1:String) : void
{
var _loc2_:Buddy = null;
if(param1 == null || param1 == "")
{
return;
}
_loc2_ = BuddyManager.getBuddyByUserName(param1);
BuddyManager.showBuddyCard({
"userName":(_loc2_ != null ? _loc2_.userName : param1),
"onlineStatus":(_loc2_ != null ? _loc2_.onlineStatus : int(_mentionOnline[param1.toLowerCase()]))
});
}
// a tag's background, as Discord draws a mention: a rounded box of
// the tag's colour, see-through, behind its words (one a line, should a
// tag wrap). a text field has no background for part of its text, so
// it is drawn on a Shape just under the field (over it, faintly, if
// the field paints its own background), kept a field.
// how strong the box is: the chat log's dark panel shows a fainter one
// well, the white balloons and the wall posts need it stronger (a
// balloon is see-through itself).
public static const MENTION_BACK_DARK:Number = 0.4;
public static const MENTION_BACK_LIGHT:Number = 0.6;
private static var _mentionBacks:Dictionary = new Dictionary(true); // text field -> Shape
// the tags in a text field whose tags are links ("event:@name", the
// chat log's): [{at, length}].
public static function mentionLinks(param1:TextField) : Array
{
var _loc2_:Array = [];
var _loc3_:String = param1 == null ? "" : param1.text;
var _loc4_:int = _loc3_.indexOf("@");
var _loc5_:String = null;
var _loc6_:int = 0;
while(_loc4_ != -1)
{
_loc5_ = param1.getTextFormat(_loc4_,_loc4_ + 1).url;
if(_loc5_ != null && _loc5_.indexOf("event:@") == 0)
{
_loc6_ = _loc4_ + 1;
while(_loc6_ < _loc3_.length && param1.getTextFormat(_loc6_,_loc6_ + 1).url == _loc5_)
{
_loc6_++;
}
_loc2_.push({
"at":_loc4_,
"length":_loc6_ - _loc4_
});
_loc4_ = _loc3_.indexOf("@",_loc6_);
}
else
{
_loc4_ = _loc3_.indexOf("@",_loc4_ + 1);
}
}
return _loc2_;
}
// draws the backgrounds of `param2` ([{at, length}]) for a text field
// as it is laid out and scrolled now, `param3` strong; none, with no tags.
public static function drawMentionBacks(param1:TextField, param2:Array, param3:Number = 0.6) : void
{
var _loc3_:Shape = _mentionBacks[param1];
var _loc4_:Object = null;
var _loc5_:Object = null;
var _loc6_:Object = null;
var _loc7_:Rectangle = null;
var _loc8_:int = 0;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:Number = 0;
var _loc13_:int = 0;
if(param1 == null)
{
return;
}
if(_loc3_ == null)
{
if(param2 == null || param2.length == 0)
{
return;
}
_loc3_ = new Shape();
_mentionBacks[param1] = _loc3_;
}
_loc3_.graphics.clear();
if(param1.parent == null || param2 == null || param2.length == 0)
{
return;
}
if(_loc3_.parent != null)
{
_loc3_.parent.removeChild(_loc3_);
}
_loc13_ = param1.parent.getChildIndex(param1);
param1.parent.addChildAt(_loc3_,param1.background ? _loc13_ + 1 : _loc13_);
_loc3_.transform.matrix = param1.transform.matrix;
// only the lines in view; their place as the field is scrolled now
_loc9_ = param1.scrollV - 1;
_loc10_ = param1.bottomScrollV - 1;
if(_loc9_ > 0)
{
_loc7_ = param1.getCharBoundaries(param1.getLineOffset(_loc9_));
_loc12_ = _loc7_ != null ? _loc7_.y - 2 : 0;
}
for each(_loc4_ in param2)
{
_loc5_ = {};
_loc8_ = _loc4_.at;
while(_loc8_ < _loc4_.at + _loc4_.length && _loc8_ < param1.length)
{
_loc11_ = param1.getLineIndexOfChar(_loc8_);
_loc7_ = _loc11_ >= _loc9_ && _loc11_ <= _loc10_ ? param1.getCharBoundaries(_loc8_) : null;
if(_loc7_ != null && _loc7_.width > 0)
{
_loc6_ = _loc5_[_loc11_];
if(_loc6_ == null)
{
_loc5_[_loc11_] = {
"left":_loc7_.x,
"right":_loc7_.x + _loc7_.width,
"top":_loc7_.y,
"height":_loc7_.height
};
}
else
{
_loc6_.left = Math.min(_loc6_.left,_loc7_.x);
_loc6_.right = Math.max(_loc6_.right,_loc7_.x + _loc7_.width);
_loc6_.height = Math.max(_loc6_.height,_loc7_.height);
}
}
_loc8_++;
}
for each(_loc6_ in _loc5_)
{
_loc3_.graphics.beginFill(MENTION_COLOR,param3);
_loc3_.graphics.drawRoundRect(_loc6_.left - 3,_loc6_.top - _loc12_,_loc6_.right - _loc6_.left + 6,_loc6_.height,8,8);
_loc3_.graphics.endFill();
}
}
}
// sound settings (MySettings' Music and SFX sliders): music and sound
// effects apart, each a volume from 0 to 1, kept on this computer in
// the game's shared object (musicVolume, sfxVolume). both start at the
// game's one old volume ("volume"), which is then left at full under
// them.
// music: every SBMusic (the rooms', the minigames' streams). sound
// effects: every SBSound (the interface's too), the minigames'
// SoundManager sounds, and what artwork plays by itself (gMainFrame's
// soundTransform; music plays apart from the display, so not under it).
// the HUD's speaker button still turns everything off and on.
private static var _musicVolume:Number = 1;
private static var _sfxVolume:Number = 1;
public static function musicLevel() : Number
{
return _musicVolume;
}
public static function sfxLevel() : Number
{
return _sfxVolume;
}
// "music" or "sfx"
public static function soundVolume(param1:String) : Number
{
return param1 == "music" ? _musicVolume : _sfxVolume;
}
private static function volumeFrom(param1:*, param2:Number) : Number
{
var _loc3_:Number = param1 == null ? param2 : Number(param1);
return isNaN(_loc3_) ? param2 : Math.max(0,Math.min(1,_loc3_));
}
// once the game has read its shared object (GuiManager.setupSharedObject)
public static function loadSoundSettings() : void
{
var _loc1_:Object = GuiManager.sharedObj != null ? GuiManager.sharedObj.data : null;
var _loc2_:Number = volumeFrom(_loc1_ != null ? _loc1_.volume : null,1);
_musicVolume = volumeFrom(_loc1_ != null ? _loc1_.musicVolume : null,_loc2_);
_sfxVolume = volumeFrom(_loc1_ != null ? _loc1_.sfxVolume : null,_loc2_);
if(SBAudio.currentVolume != 1)
{
SBAudio.setVolumeAll(1);
}
applySoundSettings();
}
// a volume (0 to 1); `param3` keeps it (a slider being dragged does
// not, until it is let go)
public static function setSoundVolume(param1:String, param2:Number, param3:Boolean = true) : void
{
param2 = volumeFrom(param2,1);
if(param1 == "music")
{
_musicVolume = param2;
}
else
{
_sfxVolume = param2;
}
applySoundSettings();
if(param3)
{
saveSoundSettings();
}
}
public static function saveSoundSettings() : void
{
if(GuiManager.sharedObj == null)
{
return;
}
GuiManager.sharedObj.data.musicVolume = _musicVolume;
GuiManager.sharedObj.data.sfxVolume = _sfxVolume;
try
{
GuiManager.sharedObj.flush();
}
catch(e:Error)
{
}
}
private static function applySoundSettings() : void
{
SBMusic.refreshAll();
SBSound.refreshAll();
if(gMainFrame != null)
{
gMainFrame.soundTransform = new SoundTransform(sfxLevel());
}
}
// where the player is, for the client's Discord rich presence (game.html
// ajPresence, the client's app/discord.js): the room's name as the game
// shows it, but never another player's name: a den or a player's party
// is named after its owner, so it is only "In their den", "Visiting a
// den" and the like. which room it is goes by its name on the server
// (lib/world.js): "den<owner>", "pparty<host>", "party<id>_<den>".
private static var _presenceShown:String = null;
public static function presenceRoom(param1:String) : void
{
var _loc2_:String = "";
var _loc3_:String = gMainFrame.userInfo.myUserName != null ? String(gMainFrame.userInfo.myUserName).toLowerCase() : "";
var _loc4_:String = null;
try
{
_loc2_ = String(gMainFrame.server.getCurrentRoomName() || "");
}
catch(e:Error)
{
}
if(_loc2_.indexOf("den") == 0)
{
_loc4_ = _loc2_.substr(3).toLowerCase() == _loc3_ ? "In their den" : "Visiting a den";
}
else if(_loc2_.indexOf("pparty") == 0)
{
_loc4_ = _loc2_.substr(6).toLowerCase() == _loc3_ ? "Hosting a party" : "At a party";
}
else if(_loc2_.indexOf("party") == 0 && _loc2_.indexOf("_") != -1)
{
_loc4_ = "At a party";
}
else
{
_loc4_ = param1 != null && param1 != "" ? "In " + param1 : "Playing";
}
if(_loc4_ == _presenceShown || !ExternalInterface.available)
{
return;
}
_presenceShown = _loc4_;
try
{
ExternalInterface.call("ajPresence",_loc4_);
}
catch(e:Error)
{
}
}
private function startEmojiButton() : void
{
_emojiTimer = new Timer(500);
@@ -3940,7 +4442,7 @@ package
};
if(_finderColourInput.text.length > 0 && _loc2_.kind != "den")
{
if(_finderColourInput.text.indexOf("#") >= 0 ? finderHexColours(_finderColourInput.text) == null : !/^\s*[0-9]+\s*$/.test(_finderColourInput.text))
if(_finderColourInput.text.indexOf("#") >= 0 ? finderHexColours(_finderColourInput.text) == null : !/^\s*-?[0-9]+\s*$/.test(_finderColourInput.text))
{
_finderStatus.text = "Colour: an id, or #RRGGBB";
return;
@@ -4001,8 +4503,9 @@ package
return _finderHexId;
}
}
else if(/^[0-9]+$/.test(_loc2_))
else if(/^-?[0-9]+$/.test(_loc2_))
{
// a negative id is the same colour written signed
return uint(Number(_loc2_));
}
_loc4_ = ItemXtCommManager.getItemDef(int(param1.id));
@@ -4104,7 +4607,7 @@ package
private function onFinderColourTyped(param1:Event) : void
{
var _loc2_:String = _finderColourInput.text.replace(/^\s+|\s+$/g,"");
if(_loc2_.length == 0 || /^[0-9]+$/.test(_loc2_) || finderHexColours(_loc2_) != null)
if(_loc2_.length == 0 || /^-?[0-9]+$/.test(_loc2_) || finderHexColours(_loc2_) != null)
{
for(var _loc3_:String in _finderIcons)
{
+51
View File
@@ -3,9 +3,11 @@ package gui
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TextEvent;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.setTimeout;
import loader.MediaHelper;
import localization.LocalizationManager;
@@ -133,6 +135,7 @@ package gui
this.visible = true;
}
clearInline();
clearMentionBacks();
_msgTxt.text = inlineEmotes(param1);
_msgTxt.height;
// AJClient.whisperNext is set by the server's "xw" just ahead of a
@@ -167,6 +170,33 @@ package gui
{
_msgTxt.textColor = 4477529;
}
// tags (AJClient.resolveMentions): once the server says which "@"s
// are players', light blue and underlined, each a link to that
// player's card, if the balloon still says the same. (the field is
// another on some frames.)
if(!param2 && _msgTxt is TextField && _msgTxt.text.indexOf("@") != -1)
{
var field:TextField = TextField(_msgTxt);
var shown:String = field.text;
field.addEventListener("link",onMentionLink,false,0,true);
AJClient.resolveMentions(shown,function(param1:Array):void
{
if(field.text == shown)
{
// in the message's own colour here: the blue box marks it
AJClient.styleMentions(field,param1,true,4477529);
// and their backgrounds, now and once laid out for sure
AJClient.drawMentionBacks(field,param1,AJClient.MENTION_BACK_LIGHT);
setTimeout(function():void
{
if(field.text == shown)
{
AJClient.drawMentionBacks(field,param1,AJClient.MENTION_BACK_LIGHT);
}
},42);
}
});
}
_timeout = 8000;
if(param3 && this.parent)
{
@@ -438,6 +468,7 @@ package gui
public function setCustomAdventureMessage(param1:String, param2:String, param3:int, param4:Boolean = false, param5:Boolean = false) : void
{
clearMentionBacks();
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc8_:Array = param2.split("|");
@@ -582,6 +613,25 @@ package gui
}
}
// the backgrounds of the tags of the text before (setText)
private function clearMentionBacks() : void
{
if(_msgTxt is TextField)
{
AJClient.drawMentionBacks(TextField(_msgTxt),null);
}
}
// a tag clicked: "@name" (setText)
private function onMentionLink(param1:TextEvent) : void
{
param1.stopPropagation();
if(param1.text && param1.text.charAt(0) == "@")
{
AJClient.openProfile(param1.text.substr(1));
}
}
private function onBtnBG(param1:MouseEvent) : void
{
param1.stopPropagation();
@@ -610,6 +660,7 @@ package gui
public function setEmote(param1:Sprite, param2:int = -1) : void
{
clearMentionBacks();
if(this.currentFrameLabel != "advBtn")
{
_permEmoteMediaId = param2;
+94 -14
View File
@@ -209,6 +209,82 @@ package gui
}
return param1.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split("\"").join("&quot;");
}
// a line's words as plain() makes them, with each tag (`param2`,
// AJClient.resolveMentions) as typed, made a link to that player's card.
private static function withMentions(param1:String, param2:Array) : String
{
var _loc3_:String = "";
var _loc4_:int = 0;
var _loc5_:Object = null;
if(param1 == null)
{
return "";
}
for each(_loc5_ in param2)
{
_loc3_ += plain(param1.substring(_loc4_,_loc5_.at)) + "<a href=\"event:@" + plain(_loc5_.name) + "\"><span class=\"mention\">" + plain(param1.substr(_loc5_.at,_loc5_.length)) + "</span></a>";
_loc4_ = _loc5_.at + _loc5_.length;
}
return _loc3_ + plain(param1.substr(_loc4_));
}
// lines wait here, in the order they came, while the server is asked
// which "@"s in them are players' (AJClient.resolveMentions; a line
// without one goes on at once, unless one ahead of it is waiting).
// each is {before, words, after: HTML around the words, found}.
private var _lines:Array = [];
private function addLine(param1:String, param2:String, param3:String) : void
{
var line:Object = {
"before":param1,
"words":param2,
"after":param3,
"found":null
};
_lines.push(line);
AJClient.resolveMentions(param2,function(param1:Array):void
{
line.found = param1;
showLines();
});
}
private function showLines() : void
{
var _loc1_:Object = null;
var _loc2_:String = null;
while(_lines.length > 0 && _lines[0].found != null)
{
_loc1_ = _lines.shift();
if(_chatText == null)
{
continue;
}
_chatText.htmlText += _loc1_.before + withMentions(_loc1_.words,_loc1_.found) + _loc1_.after;
if(_chatText.numLines >= 100)
{
_loc2_ = _chatText.htmlText;
_chatText.htmlText = _loc2_.substr(_loc2_.indexOf("\n") + 1);
}
if(!_isOverChatText)
{
_chatText.scrollV = _chatText.maxScrollV;
}
}
drawMentionBacks();
}
// the tags' backgrounds (AJClient.drawMentionBacks), for the lines in
// view: again after each new line and each scroll.
private function drawMentionBacks(param1:Event = null) : void
{
if(_chatText != null)
{
AJClient.drawMentionBacks(_chatText,AJClient.mentionLinks(_chatText),AJClient.MENTION_BACK_DARK);
}
}
public function addMessage(param1:String, param2:String, param3:String, param4:String) : void
{
@@ -217,10 +293,9 @@ package gui
var _loc5_:Boolean = false;
var _loc6_:* = 0;
var _loc7_:int = 0;
var _loc8_:String = null;
if(_chatText && param1 != null && param1.length > 0 && param2 && param4)
{
_chatText.htmlText += "<a href=\"event:" + plain(param2) + "\">" + plain(Utility.isSettingOn(MySettings.SETTINGS_USERNAME_BADGE) ? param3 : param1) + ": " + "</a>" + plain(param4) + "\n";
addLine("<a href=\"event:" + plain(param2) + "\">" + plain(Utility.isSettingOn(MySettings.SETTINGS_USERNAME_BADGE) ? param3 : param1) + ": " + "</a>",param4,"\n");
if(_chatRepeatWindow && AvatarManager.playerAvatar && param2.toLowerCase() == AvatarManager.playerAvatar.userName.toLowerCase())
{
_loc7_ = 0;
@@ -254,16 +329,7 @@ package gui
}
else
{
_chatText.htmlText += "\"" + plain(param4) + "\"" + "\n";
}
if(_chatText.numLines >= 100)
{
_loc8_ = _chatText.htmlText;
_chatText.htmlText = _loc8_.substr(_loc8_.indexOf("\n") + 1);
}
if(!_isOverChatText)
{
_chatText.scrollV = _chatText.maxScrollV;
addLine("\"",param4,"\"" + "\n");
}
}
@@ -293,11 +359,11 @@ package gui
{
if(param2 == null)
{
_chatText.htmlText += plain(param1) + ": " + plain(param3) + "\n";
addLine(plain(param1) + ": ",param3,"\n");
}
else
{
_chatText.htmlText += plain(param1) + " to " + plain(param2) + ": " + plain(param3) + "\n";
addLine(plain(param1) + " to " + plain(param2) + ": ",param3,"\n");
}
}
}
@@ -322,9 +388,11 @@ package gui
public function clearChat() : void
{
_lines = [];
if(_chatText)
{
_chatText.htmlText = "";
AJClient.drawMentionBacks(_chatText,null);
}
_chatRepeatArray = [];
setupRepeatChat();
@@ -582,12 +650,18 @@ package gui
{
_chatText.addEventListener("mouseDown",chatClickHandler,false,0,true);
_chatText.addEventListener("link",onChatLink,false,0,true);
_chatText.addEventListener("scroll",drawMentionBacks,false,0,true);
_chatText.addEventListener("mouseOver",overChatText,false,0,true);
_chatText.addEventListener("mouseOut",outChatText,false,0,true);
_loc13_ = new StyleSheet();
_loc12_ = {};
_loc12_.color = "#ff9900";
_loc13_.setStyle("a:hover",_loc12_);
// tags (withMentions)
_loc13_.setStyle(".mention",{
"color":"#4ab3f4",
"textDecoration":"underline"
});
_chatText.styleSheet = _loc13_;
}
chatMsgText.addEventListener("change",onTextFieldChanged,false,0,true);
@@ -732,6 +806,12 @@ package gui
private function onChatLink(param1:TextEvent) : void
{
// a tag: "@name" (withMentions)
if(param1.text && param1.text.charAt(0) == "@")
{
AJClient.openProfile(param1.text.substr(1));
return;
}
if(param1.text && param1.text != "" && param1.text != gMainFrame.userInfo.myUserName)
{
BuddyManager.showBuddyCard({
+4
View File
@@ -382,6 +382,8 @@ package gui
}
}
AJAudio.setupSharedObject(_sharedObj);
// music and sound effects apart (AJClient's sound settings)
AJClient.loadSoundSettings();
PlayerWallManager.init(mainHud.playerWall);
}
@@ -2829,6 +2831,8 @@ package gui
var _loc5_:UserInfo = null;
_currRoomDisplayName = param1;
_currRoomDisplayNameId = param2;
// for the client's Discord rich presence
AJClient.presenceRoom(param1);
if(mainHud.zoneNameTxt)
{
if(param1.indexOf(gMainFrame.userInfo.myUserName) == 0)
+426
View File
@@ -0,0 +1,426 @@
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_);
}
}
}
+23 -3
View File
@@ -138,7 +138,13 @@ package gui.itemWindows
_window.scrubBtn.scrubBG.gotoAndStop("up");
_window.scrubBtn.addEventListener("rollOver",handleMouseOver,false,0,true);
_window.scrubBtn.addEventListener("rollOut",handleMouseOut,false,0,true);
if(GuiManager.sharedObj && GuiManager.sharedObj.data.volume != null)
if(_currItem.sound)
{
// music or sound effects (AJClient's sound settings)
_window.scrubBtn.scrubKnob.x = AJClient.soundVolume(_currItem.sound) * 82 + 15;
_window.labelTxtCont.labelTxt.text = _currItem.labelLabel;
}
else if(GuiManager.sharedObj && GuiManager.sharedObj.data.volume != null)
{
_window.scrubBtn.scrubKnob.x = GuiManager.sharedObj.data.volume * 82 + 15;
}
@@ -767,7 +773,15 @@ package gui.itemWindows
param1.stopPropagation();
if(_currItem.type == MySettings.TOGGLE_TYPE_SCRUB && _window.scrubBtn.scrubKnob.dragging)
{
SBAudio.setVolumeAll((int(_window.scrubBtn.scrubKnob.x - 15)) / 82);
if(_currItem.sound)
{
// heard as it moves, kept when let go (handleStopScrubbing)
AJClient.setSoundVolume(_currItem.sound,(int(_window.scrubBtn.scrubKnob.x - 15)) / 82,false);
}
else
{
SBAudio.setVolumeAll((int(_window.scrubBtn.scrubKnob.x - 15)) / 82);
}
}
}
@@ -843,7 +857,13 @@ package gui.itemWindows
private function handleStopScrubbing() : void
{
if(_window.scrubBtn.scrubKnob.dragging)
if(_window.scrubBtn.scrubKnob.dragging && _currItem.sound)
{
_window.scrubBtn.scrubKnob.dragging = false;
_window.scrubBtn.scrubKnob.stopDrag();
AJClient.setSoundVolume(_currItem.sound,(int(_window.scrubBtn.scrubKnob.x - 15)) / 82);
}
else if(_window.scrubBtn.scrubKnob.dragging)
{
_window.scrubBtn.scrubKnob.dragging = false;
_window.scrubBtn.scrubKnob.stopDrag();
+8 -6
View File
@@ -268,15 +268,17 @@ package gui
"onTxt":6324,
"offTxt":6322
},{
"type":TOGGLE_TYPE_TOGGLE_BTN,
"frame":"music",
"labelTxt":6373,
"onTxt":6324,
"offTxt":6322
// music and sound effects apart, a volume each (AJClient's
// sound settings), for the game's one sound switch and volume
"type":TOGGLE_TYPE_SCRUB,
"frame":"",
"sound":"music",
"labelLabel":"Music"
},{
"type":TOGGLE_TYPE_SCRUB,
"frame":"",
"labelTxt":14666
"sound":"sfx",
"labelLabel":"SFX"
},{
"type":TOGGLE_TYPE_CURSOR,
"frame":"",
+251
View File
@@ -0,0 +1,251 @@
package com.sbi.corelib.audio
{
import com.sbi.loader.LoaderCache;
import flash.events.IOErrorEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundLoaderContext;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.utils.Dictionary;
public class SBMusic
{
private var _hashKey:String;
private var _previouslyPlayedFilename:String;
private var _currFilename:String;
private var _previousVolume:Number;
private var _currVolume:Number;
public var paused:Boolean = false;
public var muted:Boolean = false;
public var mutedVolume:Number = 1;
public var playVolume:Number = 1;
public var s:Sound;
public var sc:SoundChannel;
public var position:Number;
// every piece of music, for the music setting (AJClient.musicLevel):
// each plays at the volume the game gives it times that setting, and
// again so when the setting changes (refreshAll).
private static var _all:Dictionary = new Dictionary(true);
private var _setVolume:Number = 1;
public static function refreshAll() : void
{
var _loc1_:Object = null;
var _loc2_:SBMusic = null;
for(_loc1_ in _all)
{
_loc2_ = _loc1_ as SBMusic;
if(_loc2_ != null && _loc2_.sc != null)
{
_loc2_.setTransformVolume(_loc2_._setVolume);
}
}
}
public function SBMusic(param1:String, param2:Boolean = true, param3:Number = 1, param4:Number = 1000, param5:Boolean = true)
{
super();
_all[this] = true;
playNewMusic(param1,param2,param3,param4,param5);
SBAudio.addMusic(this);
}
public function playNewMusic(param1:String, param2:Boolean = true, param3:Number = 1, param4:Number = 1000, param5:Boolean = true) : void
{
_previouslyPlayedFilename = _currFilename;
_currFilename = param1;
_previousVolume = _currVolume;
_currVolume = param3 * SBAudio.currentVolume;
var _loc6_:URLRequest = LoaderCache.fetchCDNURLRequest("audio/" + param1);
if(s)
{
s.removeEventListener("ioError",handleIOError);
s = null;
}
if(sc)
{
sc.stop();
sc = null;
}
s = new Sound(_loc6_,new SoundLoaderContext(param4,param5));
volume = _currVolume;
if(param2)
{
play();
}
else
{
stop();
}
s.addEventListener("ioError",handleIOError,false,0,true);
}
public function play(param1:Number = 0, param2:int = 2147483647, param3:SoundTransform = null) : void
{
if(s == null)
{
return;
}
sc = s.play(param1,param2,param3);
if(sc == null)
{
return;
}
setTransformVolume(playVolume);
}
// the game's own volume for it, before the music setting
public function get volume() : Number
{
return sc ? _setVolume : -1;
}
public function set volume(param1:Number) : void
{
if(muted)
{
mutedVolume = param1;
}
else
{
playVolume = param1;
}
if(sc)
{
setTransformVolume(param1);
}
}
public function toggleMute() : void
{
if(muted)
{
unmute();
}
else
{
mute();
}
}
public function mute() : void
{
if(!muted)
{
mutedVolume = volume;
volume = 0;
muted = true;
}
}
public function unmute() : void
{
if(muted)
{
volume = mutedVolume;
muted = false;
}
}
public function togglePause() : void
{
if(paused)
{
unpause();
}
else
{
pause();
}
}
public function pause() : void
{
if(s && sc && !paused)
{
position = sc.position;
sc.stop();
paused = true;
}
}
public function unpause() : void
{
if(s && sc && paused)
{
sc = s.play(position);
setTransformVolume(playVolume);
paused = false;
}
}
public function stop() : void
{
if(sc)
{
sc.stop();
}
paused = false;
muted = false;
}
public function get previouslyPlayedFilename() : String
{
return _previouslyPlayedFilename;
}
public function get previousVolume() : Number
{
return _previousVolume;
}
public function get currFilename() : String
{
return _currFilename;
}
public function get currVolume() : Number
{
return _currVolume;
}
private function setTransformVolume(param1:Number) : void
{
_setVolume = param1;
var _loc2_:SoundTransform = sc.soundTransform;
_loc2_.volume = param1 * AJClient.musicLevel();
sc.soundTransform = _loc2_;
}
private function handleIOError(param1:IOErrorEvent) : void
{
if(s)
{
trace("WARNING - IOError while attempting to load music:" + s.url);
s = null;
}
if(sc)
{
sc.stop();
sc = null;
}
SBAudio.removeMusic(this);
}
}
}
+184
View File
@@ -0,0 +1,184 @@
package com.sbi.corelib.audio
{
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.utils.Dictionary;
public class SBSound
{
public var paused:Boolean = false;
public var playVolume:Number = 1;
public var s:Sound;
public var sc:SoundChannel;
private var _soundPlaying:Boolean;
private var _onSoundComplete:Function;
// every sound effect, for the sound effects setting (AJClient.sfxLevel):
// each plays at the volume the game gives it times that setting, and
// again so when the setting changes (refreshAll).
private static var _all:Dictionary = new Dictionary(true);
private var _setVolume:Number = 1;
public static function refreshAll() : void
{
var _loc1_:Object = null;
var _loc2_:SBSound = null;
for(_loc1_ in _all)
{
_loc2_ = _loc1_ as SBSound;
if(_loc2_ != null && _loc2_.sc != null)
{
_loc2_.setTransformVolume(_loc2_._setVolume);
}
}
}
public function SBSound(param1:Class, param2:Boolean = true, param3:Number = 1)
{
super();
_all[this] = true;
s = new param1();
volume = param3;
if(param2)
{
play();
}
else
{
stop();
}
SBAudio.addSound(this);
}
public function play(param1:Number = 0, param2:int = 0, param3:SoundTransform = null, param4:Function = null) : void
{
if(param2 == -1)
{
param2 = 2147483647;
}
if(s == null)
{
return;
}
sc = s.play(param1,param2,param3);
if(sc == null)
{
return;
}
_soundPlaying = true;
_onSoundComplete = param4;
sc.addEventListener("soundComplete",soundStoppedHandler,false,0,true);
setTransformVolume(playVolume);
}
public function destroy() : void
{
stop();
sc = null;
s = null;
SBAudio.removeSound(this);
}
// the game's own volume for it, before the sound effects setting
public function get volume() : Number
{
return sc ? _setVolume : -1;
}
public function set volume(param1:Number) : void
{
playVolume = param1;
if(sc)
{
setTransformVolume(param1);
}
}
public function get isPlaying() : Boolean
{
return _soundPlaying;
}
public function togglePause() : void
{
if(paused)
{
unpause();
}
else
{
pause();
}
}
public function pause() : void
{
if(sc && !paused)
{
sc.stop();
paused = true;
_soundPlaying = false;
}
}
public function unpause() : void
{
if(s && sc && paused)
{
sc = s.play(sc.position);
if(sc == null)
{
return;
}
_soundPlaying = true;
sc.addEventListener("soundComplete",soundStoppedHandler,false,0,true);
setTransformVolume(playVolume);
paused = false;
}
}
public function stop() : void
{
if(sc)
{
sc.stop();
}
paused = false;
_soundPlaying = false;
}
private function setTransformVolume(param1:Number) : void
{
_setVolume = param1;
var _loc2_:SoundTransform = sc.soundTransform;
if(SBAudio.isMusicMuted)
{
_loc2_.volume = 0;
}
else
{
_loc2_.volume = param1 * AJClient.sfxLevel();
}
sc.soundTransform = _loc2_;
}
private function soundStoppedHandler(param1:Event) : void
{
_soundPlaying = false;
if(_onSoundComplete != null)
{
_onSoundComplete();
}
}
}
}
+9 -9
View File
@@ -194,7 +194,8 @@ package game
}
else
{
_loc5_ = Number(_soundVolume[_loc8_]);
// times the sound effects setting (AJClient.sfxLevel)
_loc5_ = Number(_soundVolume[_loc8_]) * AJClient.sfxLevel();
}
_loc7_ = new SoundTransform(_loc5_,0);
if(_soundLimit > 0)
@@ -234,7 +235,7 @@ package game
}
else
{
_loc4_ = Number(_soundVolume[_loc7_]);
_loc4_ = Number(_soundVolume[_loc7_]) * AJClient.sfxLevel();
}
_loc6_ = new SoundTransform(_loc4_,0);
if(_soundLimit > 0)
@@ -276,9 +277,8 @@ package game
gMainFrame.stage.removeEventListener("enterFrame",doFadeIn);
}
var _loc2_:Number = _musicVolume[_fadeInStream] * _loc4_;
var _loc5_:SoundChannel = _fadeInStream.sc;
var _loc3_:SoundTransform = new SoundTransform(_loc2_,0);
_fadeInStream.sc.soundTransform = _loc3_;
// through SBMusic's volume, which takes the music setting
_fadeInStream.volume = _loc2_;
if(_loc4_ == 1)
{
_fadeInStream = null;
@@ -301,8 +301,7 @@ package game
gMainFrame.stage.removeEventListener("enterFrame",doFadeOut);
}
var _loc2_:Number = _musicVolume[_fadeOutStream] * (1 - _loc4_);
var _loc3_:SoundTransform = new SoundTransform(_loc2_,0);
_fadeOutStream.sc.soundTransform = _loc3_;
_fadeOutStream.volume = _loc2_;
if(_loc4_ == 1)
{
_fadeOutStream.sc.stop();
@@ -374,7 +373,7 @@ package game
_loc6_ = new SoundTransform(_loc5_,0);
if(_fadeOutStream.sc != null)
{
_fadeOutStream.sc.soundTransform = _loc6_;
_fadeOutStream.volume = _loc5_;
return _fadeOutStream.sc;
}
return null;
@@ -397,7 +396,8 @@ package game
return null;
}
_musicChannel[param1] = param1.sc;
param1.sc.soundTransform = _loc6_;
// the stream's volume through SBMusic, which takes the music setting
param1.volume = _loc6_.volume;
if(SBAudio.isMusicMuted)
{
param1.mute();
+5
View File
@@ -119,6 +119,11 @@ package
AJClient.onInvisible(param1.obj);
return;
}
if(param1.obj[0] == "xmn")
{
AJClient.onMentions(param1.obj);
return;
}
if(param1.obj[0] == "xty")
{
AJClient.onTyping(param1.obj);