mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,174 @@
|
||||
package gui
|
||||
{
|
||||
import avatar.AvatarXtCommManager;
|
||||
import buddy.Buddy;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class PlayerSearch
|
||||
{
|
||||
|
||||
public static const SEARCH_MEDIA_ID:int = 396;
|
||||
|
||||
public static const LOADING_SPIRAL_ID:int = 397;
|
||||
|
||||
private var _searchPopup:MovieClip;
|
||||
|
||||
private var _searchMediaHelper:MediaHelper;
|
||||
|
||||
private var _lastSearchedName:String;
|
||||
|
||||
public function PlayerSearch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() : void
|
||||
{
|
||||
this._searchMediaHelper = new MediaHelper();
|
||||
this._searchMediaHelper.init(SEARCH_MEDIA_ID,this.searchMediaCallback,true);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.removeListeners();
|
||||
this._searchMediaHelper.destroy();
|
||||
GuiManager.guiLayer.removeChild(this._searchPopup);
|
||||
DarkenManager.unDarken(this._searchPopup);
|
||||
this._searchPopup = null;
|
||||
}
|
||||
|
||||
private function searchMediaCallback(param1:MovieClip) : void
|
||||
{
|
||||
this._searchPopup = MovieClip(param1.getChildAt(0));
|
||||
this._searchPopup.x = MainFrame.VIEW_WIDTH * 0.5;
|
||||
this._searchPopup.y = MainFrame.VIEW_HEIGHT * 0.5;
|
||||
GuiManager.guiLayer.addChild(this._searchPopup);
|
||||
this.addListeners();
|
||||
this.setInitialConditions();
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
DarkenManager.darken(this._searchPopup);
|
||||
this._searchMediaHelper = new MediaHelper();
|
||||
this._searchMediaHelper.init(LOADING_SPIRAL_ID,this.loadingSpiralCallback,true);
|
||||
}
|
||||
|
||||
private function loadingSpiralCallback(param1:MovieClip) : void
|
||||
{
|
||||
if(this._searchPopup)
|
||||
{
|
||||
this._searchPopup.itemBlock.addChild(param1);
|
||||
this._searchPopup.itemBlock.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function setInitialConditions() : void
|
||||
{
|
||||
this._searchPopup.userNameTxt.text = "";
|
||||
this._searchPopup.userNameTxt.restrict = "A-Za-z0-9";
|
||||
this._searchPopup.userNameTxt.maxChars = 32;
|
||||
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
|
||||
this._searchPopup.notFoundTab.visible = false;
|
||||
}
|
||||
|
||||
private function popupCloseHandler(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
private function onSearchBtnHandler(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
this.performSearch();
|
||||
}
|
||||
|
||||
private function keyDownListener(param1:KeyboardEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(param1.keyCode == 13)
|
||||
{
|
||||
this.performSearch();
|
||||
}
|
||||
}
|
||||
|
||||
private function performSearch() : void
|
||||
{
|
||||
var _loc3_:Buddy = null;
|
||||
this._searchPopup.notFoundTab.visible = true;
|
||||
this._searchPopup.notFoundTab.getChildAt(1).text = "That Jammer couldn\'t be found!";
|
||||
var _loc1_:String = this._searchPopup.userNameTxt.text;
|
||||
if(gMainFrame.userInfo.myUserName.toLowerCase() == _loc1_.toLowerCase())
|
||||
{
|
||||
this._searchPopup.notFoundTab.getChildAt(1).text = "You can\'t search for yourself!";
|
||||
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
|
||||
return;
|
||||
}
|
||||
var _loc2_:String = _loc1_.toLowerCase();
|
||||
if(this._lastSearchedName != _loc2_)
|
||||
{
|
||||
this._lastSearchedName = _loc2_;
|
||||
_loc3_ = BuddyManager.getBuddyByUserName(_loc2_);
|
||||
if(_loc3_)
|
||||
{
|
||||
this._searchPopup.notFoundTab.visible = false;
|
||||
BuddyCard.showBuddyCard({
|
||||
"userName":_loc3_.userName,
|
||||
"onlineStatus":_loc3_.onlineStatus
|
||||
});
|
||||
this.destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._searchPopup.notFoundTab.visible = false;
|
||||
this._searchPopup.itemBlock.visible = true;
|
||||
AvatarXtCommManager.requestAvatarGet(_loc1_,this.onUserLookUpReceived,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onUserLookUpReceived(param1:String, param2:Boolean, param3:int) : void
|
||||
{
|
||||
if(this._searchPopup)
|
||||
{
|
||||
this._searchPopup.itemBlock.visible = false;
|
||||
if(param2 && param1.toLowerCase() == this._searchPopup.userNameTxt.text.toLowerCase())
|
||||
{
|
||||
BuddyCard.showBuddyCard({
|
||||
"userName":param1,
|
||||
"onlineStatus":param3
|
||||
});
|
||||
this.destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._searchPopup.notFoundTab.visible = true;
|
||||
gMainFrame.stage.focus = this._searchPopup.userNameTxt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onPopup(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
private function addListeners() : void
|
||||
{
|
||||
this._searchPopup["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler,false,0,true);
|
||||
this._searchPopup.searchBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onSearchBtnHandler,false,0,true);
|
||||
this._searchPopup.userNameTxt.addEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener,false,0,true);
|
||||
this._searchPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
|
||||
}
|
||||
|
||||
private function removeListeners() : void
|
||||
{
|
||||
this._searchPopup["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.popupCloseHandler);
|
||||
this._searchPopup.searchBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onSearchBtnHandler);
|
||||
this._searchPopup.userNameTxt.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownListener);
|
||||
this._searchPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user