mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 09:37:50 -05:00
174 lines
5.5 KiB
ActionScript
174 lines
5.5 KiB
ActionScript
package gui
|
|
{
|
|
import achievement.AchievementXtCommManager;
|
|
import com.sbi.analytics.SBTracker;
|
|
import com.sbi.popup.SBPollPopup;
|
|
import flash.display.MovieClip;
|
|
import flash.events.MouseEvent;
|
|
import loader.MediaHelper;
|
|
import loader.PollDefHelper;
|
|
|
|
public class PollManager
|
|
{
|
|
|
|
private static var _pollDefCache:Array;
|
|
|
|
private static var _pollLocs:Array;
|
|
|
|
private static var _pollDefHelpers:Array;
|
|
|
|
private static var _tabMediaHelper:MediaHelper;
|
|
|
|
private static var _tabTemplate:MovieClip;
|
|
|
|
private static var _guiLayer:DisplayLayer;
|
|
|
|
private static var _worldLayer:DisplayLayer;
|
|
|
|
private static var _pollPopup:SBPollPopup;
|
|
|
|
private static const POLL_MEDIA_ID_TAB:int = 153;
|
|
|
|
private static const POLL_TAB_FRAME_LABEL:String = "poll";
|
|
|
|
private static const POLL_IMAGE_TAB_FRAME_LABEL:String = "tshirtPoll";
|
|
|
|
private static const POLL_COUNT_USERVAR:int = 113;
|
|
|
|
public function PollManager()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function init(param1:DisplayLayer, param2:DisplayLayer) : void
|
|
{
|
|
_guiLayer = param1;
|
|
_worldLayer = param2;
|
|
_pollDefCache = [];
|
|
_tabMediaHelper = new MediaHelper();
|
|
_tabMediaHelper.init(POLL_MEDIA_ID_TAB,mediaHelperHandler,true);
|
|
}
|
|
|
|
public static function setUpPolls(param1:Array, param2:Array) : void
|
|
{
|
|
var _loc4_:Object = null;
|
|
var _loc5_:PollDefHelper = null;
|
|
_pollLocs = param2;
|
|
_pollDefHelpers = [];
|
|
var _loc3_:int = 0;
|
|
while(_loc3_ < param1.length)
|
|
{
|
|
_loc4_ = _pollDefCache[param1[_loc3_]];
|
|
if(!_loc4_)
|
|
{
|
|
_loc5_ = new PollDefHelper();
|
|
_loc5_.init(param1[_loc3_],onPollDefReceived);
|
|
_pollDefHelpers[param1[_loc3_]] = _loc5_;
|
|
}
|
|
else
|
|
{
|
|
setUpPoll(_loc4_);
|
|
}
|
|
_loc3_++;
|
|
}
|
|
}
|
|
|
|
private static function onPollDefReceived(param1:PollDefHelper) : void
|
|
{
|
|
var _loc2_:Object = param1.def;
|
|
var _loc3_:Object = {
|
|
"id":int(_loc2_.id),
|
|
"mediaId":int(_loc2_.mediaRef),
|
|
"userVarId":int(_loc2_.userVarRef),
|
|
"poll":_loc2_.poll,
|
|
"title":_loc2_.title
|
|
};
|
|
_pollDefCache[_loc3_.id] = _loc3_;
|
|
_pollDefHelpers[_loc3_.id] = null;
|
|
setUpPoll(_loc3_);
|
|
}
|
|
|
|
private static function setUpPoll(param1:Object) : void
|
|
{
|
|
var _loc2_:MovieClip = null;
|
|
var _loc3_:int = 0;
|
|
if(gMainFrame.userInfo.userVarCache.getUserVarValueById(int(param1.userVarId)) < 0)
|
|
{
|
|
if(_tabTemplate)
|
|
{
|
|
_loc2_ = new _tabTemplate.constructor();
|
|
_loc2_.def = param1;
|
|
_loc3_ = int(_loc2_.id = int(param1.id));
|
|
_loc2_.x = _pollLocs[_loc3_].x;
|
|
_loc2_.y = _pollLocs[_loc3_].y;
|
|
if(param1.id == 27)
|
|
{
|
|
_loc2_.gotoAndPlay(POLL_IMAGE_TAB_FRAME_LABEL);
|
|
}
|
|
else
|
|
{
|
|
_loc2_.gotoAndPlay(POLL_TAB_FRAME_LABEL);
|
|
}
|
|
_loc2_.addEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown,false,0,true);
|
|
_worldLayer.addChild(_loc2_);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static function mediaHelperHandler(param1:MovieClip) : void
|
|
{
|
|
var _loc2_:int = int(param1.mediaHelper.id);
|
|
_tabTemplate = MovieClip(param1.getChildAt(0));
|
|
_tabMediaHelper.destroy();
|
|
_tabMediaHelper = null;
|
|
}
|
|
|
|
private static function onTabMouseDown(param1:MouseEvent) : void
|
|
{
|
|
param1.stopPropagation();
|
|
var _loc2_:MovieClip = MovieClip(param1.currentTarget);
|
|
SBTracker.push();
|
|
SBTracker.trackPageview("/game/play/popup/vote/" + _loc2_.def.id);
|
|
if(param1.currentTarget.currentFrameLabel == POLL_IMAGE_TAB_FRAME_LABEL)
|
|
{
|
|
ImagePoll.displayPoll(_loc2_.def.userVarId,ImagePoll.TSHIRT_MEDIA_ID,3,_loc2_,onImagePollClose);
|
|
}
|
|
else
|
|
{
|
|
DarkenManager.showLoadingSpiral(true);
|
|
_pollPopup = new SBPollPopup();
|
|
_pollPopup.init(_guiLayer,_loc2_,onPollVote,onPollDone,true);
|
|
}
|
|
}
|
|
|
|
private static function onImagePollClose(param1:MovieClip) : void
|
|
{
|
|
if(param1.parent)
|
|
{
|
|
param1.parent.removeChild(param1);
|
|
}
|
|
param1.removeEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown);
|
|
SBTracker.pop();
|
|
}
|
|
|
|
private static function onPollVote(param1:MovieClip, param2:int) : void
|
|
{
|
|
if(param1.parent)
|
|
{
|
|
param1.parent.removeChild(param1);
|
|
}
|
|
param1.removeEventListener(MouseEvent.MOUSE_DOWN,onTabMouseDown);
|
|
AchievementXtCommManager.requestSetUserVar(param1.def.userVarId,param2);
|
|
AchievementXtCommManager.requestSetUserVar(POLL_COUNT_USERVAR,1);
|
|
}
|
|
|
|
private static function onPollDone() : void
|
|
{
|
|
SBTracker.pop();
|
|
_pollPopup.destroy();
|
|
_pollPopup = null;
|
|
}
|
|
}
|
|
}
|
|
|