mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 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,196 @@
|
||||
package shop
|
||||
{
|
||||
import collection.IitemCollection;
|
||||
import currency.UserCurrency;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.UpsellManager;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class BundleShop
|
||||
{
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _bundleShop:MovieClip;
|
||||
|
||||
private const SHOP_ID:int = 1;
|
||||
|
||||
private const MEDIA_ID:int = 8266;
|
||||
|
||||
private var _unfilteredItemArray:IitemCollection;
|
||||
|
||||
private var _unfilteredColorsArray:Array;
|
||||
|
||||
private var _shopItemArray:IitemCollection;
|
||||
|
||||
private var _itemColorsArray:Array;
|
||||
|
||||
private var _currShopItemArray:IitemCollection;
|
||||
|
||||
private var _diamondCost:int;
|
||||
|
||||
private var _closeCallback:Function;
|
||||
|
||||
public function BundleShop(param1:Function)
|
||||
{
|
||||
super();
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_closeCallback = param1;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(8266,onShopLoaded);
|
||||
}
|
||||
|
||||
private function onShopLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_bundleShop = param1.getChildAt(0) as MovieClip;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(8267,onImageLoaded);
|
||||
ItemXtCommManager.requestShopList(gotItemListCallback,1);
|
||||
}
|
||||
|
||||
private function onImageLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_bundleShop.itemLayer.addChild(param1.getChildAt(0));
|
||||
}
|
||||
|
||||
private function gotItemListCallback(param1:IitemCollection, param2:String, param3:Boolean, param4:int, param5:Array = null) : void
|
||||
{
|
||||
if(param3)
|
||||
{
|
||||
_diamondCost = param4;
|
||||
_unfilteredItemArray = param1;
|
||||
_unfilteredColorsArray = param5;
|
||||
LocalizationManager.translateId(_bundleShop.bodyTxt,35572);
|
||||
if(param2 != "")
|
||||
{
|
||||
LocalizationManager.translateId(_bundleShop.titleTxt,int(param2));
|
||||
}
|
||||
setupTags();
|
||||
filterItemLists();
|
||||
}
|
||||
}
|
||||
|
||||
private function filterItemLists() : void
|
||||
{
|
||||
_shopItemArray = new IitemCollection(_unfilteredItemArray.concatCollection(null));
|
||||
if(_unfilteredColorsArray)
|
||||
{
|
||||
_itemColorsArray = _unfilteredColorsArray.concat();
|
||||
}
|
||||
else
|
||||
{
|
||||
_itemColorsArray = null;
|
||||
}
|
||||
GenericListXtCommManager.filterIitems(_shopItemArray,true,_itemColorsArray);
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_shopItemArray.length == 0)
|
||||
{
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
_bundleShop.visible = true;
|
||||
_bundleShop.x = 900 * 0.5;
|
||||
_bundleShop.y = 550 * 0.5;
|
||||
GuiManager.guiLayer.addChild(_bundleShop);
|
||||
DarkenManager.darken(_bundleShop);
|
||||
addListeners();
|
||||
}
|
||||
|
||||
private function setupTags() : void
|
||||
{
|
||||
if(UserCurrency.hasEnoughCurrency(3,_diamondCost))
|
||||
{
|
||||
if(_bundleShop.tag.currentFrameLabel != "diamondgreen")
|
||||
{
|
||||
_bundleShop.tag.gotoAndPlay("diamondgreen");
|
||||
}
|
||||
_bundleShop.tag.txt.textColor = "0x386630";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_bundleShop.tag.currentFrameLabel != "diamondred")
|
||||
{
|
||||
_bundleShop.tag.gotoAndPlay("diamondred");
|
||||
}
|
||||
_bundleShop.tag.txt.textColor = "0x800000";
|
||||
}
|
||||
_bundleShop.tag.txt.text = Utility.convertNumberToString(_diamondCost);
|
||||
_bundleShop.tag.visible = true;
|
||||
}
|
||||
|
||||
private function addListeners() : void
|
||||
{
|
||||
_bundleShop.addEventListener("mouseDown",onPopupDown,false,0,true);
|
||||
_bundleShop.bx.addEventListener("mouseDown",onCloseBtn,false,0,true);
|
||||
_bundleShop.buyBtn.addEventListener("mouseDown",onBuyBtn,false,0,true);
|
||||
}
|
||||
|
||||
private function removeListeners() : void
|
||||
{
|
||||
_bundleShop.removeEventListener("mouseDown",onPopupDown);
|
||||
_bundleShop.bx.removeEventListener("mouseDown",onCloseBtn);
|
||||
_bundleShop.buyBtn.removeEventListener("mouseDown",onBuyBtn);
|
||||
}
|
||||
|
||||
private function onPopupDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
private function onCloseBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
destroy();
|
||||
}
|
||||
|
||||
private function onBuyBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(!gMainFrame.userInfo.isMember)
|
||||
{
|
||||
UpsellManager.displayPopup("diamondShop","buyBundle/");
|
||||
return;
|
||||
}
|
||||
if(!UserCurrency.hasEnoughCurrency(3,_diamondCost))
|
||||
{
|
||||
UpsellManager.displayPopup("","extraDiamonds");
|
||||
return;
|
||||
}
|
||||
ItemXtCommManager.requestBuyDiamondBundle(1,onDiamondPurchaseComplete);
|
||||
}
|
||||
|
||||
private function onDiamondPurchaseComplete(param1:Object) : void
|
||||
{
|
||||
destroy();
|
||||
if(param1[2] == "true")
|
||||
{
|
||||
UserCurrency.setCurrency(param1[3],3);
|
||||
GuiManager.setupInGameRedemptions();
|
||||
}
|
||||
}
|
||||
|
||||
private function destroy() : void
|
||||
{
|
||||
removeListeners();
|
||||
if(_mediaHelper)
|
||||
{
|
||||
_mediaHelper.destroy();
|
||||
_mediaHelper = null;
|
||||
}
|
||||
DarkenManager.unDarken(_bundleShop);
|
||||
GuiManager.guiLayer.removeChild(_bundleShop);
|
||||
_bundleShop = null;
|
||||
if(_closeCallback != null)
|
||||
{
|
||||
_closeCallback(false);
|
||||
_closeCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package shop
|
||||
{
|
||||
import collection.IitemCollection;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import inventory.Iitem;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class ItemSoldPopup
|
||||
{
|
||||
|
||||
private var _closeCallback:Function;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _soldPopup:MovieClip;
|
||||
|
||||
private var _itemCollection:IitemCollection;
|
||||
|
||||
private var _shopItem:Iitem;
|
||||
|
||||
private var _soldAmount:int;
|
||||
|
||||
private var _currencyType:int;
|
||||
|
||||
private var _passback:Object;
|
||||
|
||||
public function ItemSoldPopup(param1:Iitem, param2:int, param3:int, param4:Function, param5:Object)
|
||||
{
|
||||
super();
|
||||
_shopItem = param1;
|
||||
_soldAmount = param2;
|
||||
_currencyType = param3;
|
||||
_closeCallback = param4;
|
||||
_passback = param5;
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(7718,onPopupLoaded);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
removeEventListeners();
|
||||
_shopItem.destroy();
|
||||
DarkenManager.unDarken(_soldPopup);
|
||||
GuiManager.guiLayer.removeChild(_soldPopup);
|
||||
_soldPopup = null;
|
||||
}
|
||||
|
||||
private function onPopupLoaded(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
_soldPopup = MovieClip(param1.getChildAt(0));
|
||||
_soldPopup.x = 900 * 0.5;
|
||||
_soldPopup.y = 550 * 0.5;
|
||||
addEventListeners();
|
||||
_soldPopup.itemLayer.addChild(_shopItem.largeIcon);
|
||||
LocalizationManager.updateToFit(_soldPopup.item_name_txt,_shopItem.name);
|
||||
if(_currencyType == 3)
|
||||
{
|
||||
if(_soldAmount == 1)
|
||||
{
|
||||
_loc2_ = 33922;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = 33925;
|
||||
}
|
||||
}
|
||||
else if(_soldAmount == 1)
|
||||
{
|
||||
_loc2_ = 33919;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = 33923;
|
||||
}
|
||||
LocalizationManager.translateIdAndInsert(_soldPopup.soldTxt,_loc2_,_soldAmount);
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
GuiManager.guiLayer.addChild(_soldPopup);
|
||||
DarkenManager.darken(_soldPopup);
|
||||
}
|
||||
|
||||
private function addEventListeners() : void
|
||||
{
|
||||
_soldPopup.bx.addEventListener("mouseDown",onCloseBtn,false,0,true);
|
||||
_soldPopup.okBtn.addEventListener("mouseDown",onOkBtn,false,0,true);
|
||||
}
|
||||
|
||||
private function removeEventListeners() : void
|
||||
{
|
||||
_soldPopup.bx.removeEventListener("mouseDown",onCloseBtn);
|
||||
_soldPopup.okBtn.removeEventListener("mouseDown",onOkBtn);
|
||||
}
|
||||
|
||||
private function onOkBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
onCloseBtn(param1);
|
||||
}
|
||||
|
||||
private function onCloseBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(_closeCallback != null)
|
||||
{
|
||||
_closeCallback(_passback);
|
||||
_closeCallback = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package shop
|
||||
{
|
||||
public class MyShopData
|
||||
{
|
||||
|
||||
private var _state:String;
|
||||
|
||||
private var _shopItems:Vector.<MyShopItem>;
|
||||
|
||||
private var _storeInvId:int;
|
||||
|
||||
public function MyShopData(param1:int, param2:String, param3:Vector.<MyShopItem>)
|
||||
{
|
||||
super();
|
||||
_storeInvId = param1;
|
||||
_shopItems = param3;
|
||||
_state = param2;
|
||||
}
|
||||
|
||||
public function get storeInvId() : int
|
||||
{
|
||||
return _storeInvId;
|
||||
}
|
||||
|
||||
public function set storeInvId(param1:int) : void
|
||||
{
|
||||
_storeInvId = param1;
|
||||
}
|
||||
|
||||
public function get shopItems() : Vector.<MyShopItem>
|
||||
{
|
||||
return _shopItems;
|
||||
}
|
||||
|
||||
public function set shopItems(param1:Vector.<MyShopItem>) : void
|
||||
{
|
||||
_shopItems = param1;
|
||||
}
|
||||
|
||||
public function get state() : String
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public function set state(param1:String) : void
|
||||
{
|
||||
_state = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package shop
|
||||
{
|
||||
import inventory.Iitem;
|
||||
|
||||
public class MyShopItem
|
||||
{
|
||||
|
||||
private var _currItem:Iitem;
|
||||
|
||||
private var _currencyType:int;
|
||||
|
||||
private var _cost:int;
|
||||
|
||||
private var _shopInvIdx:int;
|
||||
|
||||
public function MyShopItem(param1:Iitem, param2:int, param3:int, param4:int)
|
||||
{
|
||||
super();
|
||||
_currItem = param1;
|
||||
_currencyType = param2;
|
||||
_cost = param3;
|
||||
_shopInvIdx = param4;
|
||||
}
|
||||
|
||||
public function get currItem() : Iitem
|
||||
{
|
||||
return _currItem;
|
||||
}
|
||||
|
||||
public function get currencyType() : int
|
||||
{
|
||||
return _currencyType;
|
||||
}
|
||||
|
||||
public function set currencyType(param1:int) : void
|
||||
{
|
||||
_currencyType = param1;
|
||||
}
|
||||
|
||||
public function get cost() : int
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
public function set cost(param1:int) : void
|
||||
{
|
||||
_cost = param1;
|
||||
}
|
||||
|
||||
public function get shopInvIdx() : int
|
||||
{
|
||||
return _shopInvIdx;
|
||||
}
|
||||
|
||||
public function set shopInvIdx(param1:int) : void
|
||||
{
|
||||
_shopInvIdx = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,343 @@
|
||||
package shop
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import flash.utils.Dictionary;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import inventory.Iitem;
|
||||
|
||||
public class ShopManager
|
||||
{
|
||||
|
||||
public static const SHOP_MEDIA_ID:int = 3934;
|
||||
|
||||
public static const SHOP_CHARM_BUY_MEDIA_ID:int = 6620;
|
||||
|
||||
public static const DEN_EDIT_TUTORIAL_SHOP_PREVIEW:int = 6;
|
||||
|
||||
public static const DEN_EDIT_TUTORIAL_SHOP_BUY:int = 7;
|
||||
|
||||
public static const DEN_EDIT_TUTORIAL_COMPLETE:int = 8;
|
||||
|
||||
public static const MAX_STORE_ITEMS:int = 24;
|
||||
|
||||
private static const EXTENDED_ITEM_COUNT_BIT_INDEX:int = 1;
|
||||
|
||||
private static const NUM_EXTRA_SLOTS_DEN:int = 1600;
|
||||
|
||||
private static const NUM_EXTRA_SLOTS_ACC:int = 900;
|
||||
|
||||
private static const NUM_ACC_SLOTS:int = 100;
|
||||
|
||||
private static const NUM_DEN_SLOTS:int = 400;
|
||||
|
||||
private static const NUM_AUDIO_SLOTS:int = 48;
|
||||
|
||||
private static const WARNING_ITEM_COUNT:int = 95;
|
||||
|
||||
private static const WARNING_DEN_ITEM_COUNT:int = 395;
|
||||
|
||||
private static const WARNING_DEN_AUDIO_COUNT:int = 45;
|
||||
|
||||
private static const WARNING_DEN_ROOM_COUNT_OFFSET:int = 3;
|
||||
|
||||
public static var currentOpenShopId:int = 0;
|
||||
|
||||
private static var _shop:Shop;
|
||||
|
||||
private static var _bundleShop:BundleShop;
|
||||
|
||||
private static var _numRemovedCount:int;
|
||||
|
||||
private static var _allRemovalsSucceeded:Boolean;
|
||||
|
||||
private static var _itemSoldPopup:ItemSoldPopup;
|
||||
|
||||
private static var _itemsSold:Array;
|
||||
|
||||
public static var myShopItems:Dictionary = new Dictionary();
|
||||
|
||||
public function ShopManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function get maxItems() : int
|
||||
{
|
||||
if((gMainFrame.userInfo.pendingFlags & 1 << 1) != 0)
|
||||
{
|
||||
return 100 + 900;
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
|
||||
public static function get maxDenItems() : int
|
||||
{
|
||||
if((gMainFrame.userInfo.pendingFlags & 1 << 1) != 0)
|
||||
{
|
||||
return 400 + 1600;
|
||||
}
|
||||
return 400;
|
||||
}
|
||||
|
||||
public static function get maxAudioItems() : int
|
||||
{
|
||||
return 48;
|
||||
}
|
||||
|
||||
public static function get warningItemCount() : int
|
||||
{
|
||||
if((gMainFrame.userInfo.pendingFlags & 1 << 1) != 0)
|
||||
{
|
||||
return 95 + 900;
|
||||
}
|
||||
return 95;
|
||||
}
|
||||
|
||||
public static function get warningDenItemCount() : int
|
||||
{
|
||||
if((gMainFrame.userInfo.pendingFlags & 1 << 1) != 0)
|
||||
{
|
||||
return 395 + 1600;
|
||||
}
|
||||
return 395;
|
||||
}
|
||||
|
||||
public static function get warningAudioItemCount() : int
|
||||
{
|
||||
return 45;
|
||||
}
|
||||
|
||||
public static function get warningDenRoomCount() : int
|
||||
{
|
||||
return 200 - 3;
|
||||
}
|
||||
|
||||
public static function isWorldShopOpen() : Boolean
|
||||
{
|
||||
return _shop != null;
|
||||
}
|
||||
|
||||
public static function closeWorldShop() : void
|
||||
{
|
||||
if(_shop)
|
||||
{
|
||||
_shop.destroy();
|
||||
_shop = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function launchStore(param1:int, param2:int) : void
|
||||
{
|
||||
if(_shop)
|
||||
{
|
||||
_shop.destroy();
|
||||
}
|
||||
if((param2 == 1000 || param1 == 168 || param1 == 415 || param1 == 626 || param1 >= 676 && param1 <= 681) && param1 != 338 && param1 != 669)
|
||||
{
|
||||
_shop = new ShopWithPreview();
|
||||
_shop.init(param1,param2,AvatarManager.playerAvatar,GuiManager.guiLayer,onShopClose);
|
||||
}
|
||||
else if(param1 == 1)
|
||||
{
|
||||
_bundleShop = new BundleShop(onShopClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop = new Shop();
|
||||
_shop.init(param1,param2,AvatarManager.playerAvatar,GuiManager.guiLayer,onShopClose);
|
||||
}
|
||||
}
|
||||
|
||||
public static function launchDenShopStore(param1:int) : void
|
||||
{
|
||||
if(_shop)
|
||||
{
|
||||
_shop.destroy();
|
||||
}
|
||||
currentOpenShopId = param1;
|
||||
_shop = new ShopToSell();
|
||||
_shop.init(param1,0,AvatarManager.playerAvatar,GuiManager.guiLayer,onShopClose);
|
||||
}
|
||||
|
||||
private static function onShopClose(param1:Boolean) : void
|
||||
{
|
||||
currentOpenShopId = 0;
|
||||
if(_shop)
|
||||
{
|
||||
_shop.destroy();
|
||||
_shop = null;
|
||||
}
|
||||
if(_bundleShop)
|
||||
{
|
||||
_bundleShop = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function ifShopToSellOpenCloseIt(param1:int = -1) : Boolean
|
||||
{
|
||||
if(_shop && _shop is ShopToSell)
|
||||
{
|
||||
if(param1 == -1 || (_shop as ShopToSell).isDenSaleShopOwner && (_shop as ShopToSell).shopInvId == param1)
|
||||
{
|
||||
onShopClose(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function addShopItemToMyList(param1:MyShopData) : void
|
||||
{
|
||||
if(myShopItems == null)
|
||||
{
|
||||
myShopItems = new Dictionary();
|
||||
}
|
||||
myShopItems[param1.storeInvId] = param1;
|
||||
}
|
||||
|
||||
public static function clearShopItems(param1:int) : void
|
||||
{
|
||||
delete myShopItems[param1];
|
||||
}
|
||||
|
||||
public static function updateShopState(param1:int, param2:String) : void
|
||||
{
|
||||
if(myShopItems[param1])
|
||||
{
|
||||
myShopItems[param1].state = param2;
|
||||
}
|
||||
if(_shop && _shop is ShopToSell)
|
||||
{
|
||||
(_shop as ShopToSell).updateMyShopDataState(param2,param1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeShopItemFromMyList(param1:int, param2:Iitem, param3:int) : void
|
||||
{
|
||||
var _loc6_:* = undefined;
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:MyShopData = myShopItems[param1];
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc6_ = _loc4_.shopItems;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc6_.length)
|
||||
{
|
||||
if(_loc6_[_loc5_].currItem.itemType == param2.itemType && _loc6_[_loc5_].currItem.defId == param2.defId && _loc6_[_loc5_].currItem.invIdx == param3)
|
||||
{
|
||||
_loc6_.splice(_loc5_,1);
|
||||
break;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(_shop && _shop is ShopToSell)
|
||||
{
|
||||
(_shop as ShopToSell).removeItemFromStore(param2,param3);
|
||||
}
|
||||
}
|
||||
|
||||
public static function findAndRemoveDenShopItems(param1:Vector.<MyShopItem>, param2:Function, param3:Object) : void
|
||||
{
|
||||
var _loc7_:MyShopData = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc4_:MyShopData = null;
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
var _loc5_:Dictionary = new Dictionary();
|
||||
_numRemovedCount = 0;
|
||||
_allRemovalsSucceeded = true;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param1.length)
|
||||
{
|
||||
_loc7_ = myShopItems[param1[_loc8_].shopInvIdx];
|
||||
if(_loc7_)
|
||||
{
|
||||
if(_loc5_[param1[_loc8_].shopInvIdx] == null)
|
||||
{
|
||||
_loc6_++;
|
||||
_loc5_[param1[_loc8_].shopInvIdx] = {
|
||||
"shopData":_loc7_,
|
||||
"removedItems":new Vector.<MyShopItem>()
|
||||
};
|
||||
}
|
||||
_loc5_[param1[_loc8_].shopInvIdx].removedItems.push(param1[_loc8_]);
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
if(_loc6_ > 0)
|
||||
{
|
||||
for each(var _loc9_:Object in _loc5_)
|
||||
{
|
||||
_loc4_ = _loc9_.shopData;
|
||||
ShopToSellXtCommManager.requestStoreUpdateItems(_loc4_.storeInvId,_loc4_.state,null,_loc9_.removedItems,null,onRemovalComplete,{
|
||||
"totalRequests":_loc6_,
|
||||
"callback":param2,
|
||||
"passback":param3
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
param2(true,param3);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onRemovalComplete(param1:Boolean, param2:Object) : void
|
||||
{
|
||||
if(!param1)
|
||||
{
|
||||
_allRemovalsSucceeded = false;
|
||||
}
|
||||
_numRemovedCount = _numRemovedCount + 1;
|
||||
if(param2.totalRequests == _numRemovedCount)
|
||||
{
|
||||
if(param2.callback != null)
|
||||
{
|
||||
param2.callback(_allRemovalsSucceeded,param2.passback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function showItemSoldPopup(param1:Iitem, param2:int, param3:int, param4:int = -1) : void
|
||||
{
|
||||
if(_itemSoldPopup)
|
||||
{
|
||||
if(_itemsSold == null)
|
||||
{
|
||||
_itemsSold = [];
|
||||
}
|
||||
_itemsSold.push({
|
||||
"shopItem":param1,
|
||||
"soldAmount":param2,
|
||||
"currencyType":param3
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_itemSoldPopup = new ItemSoldPopup(param1,param2,param3,onCloseSoldPopup,param4);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onCloseSoldPopup(param1:int) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(_itemSoldPopup)
|
||||
{
|
||||
_itemSoldPopup.destroy();
|
||||
_itemSoldPopup = null;
|
||||
}
|
||||
if(_itemsSold && _itemsSold.length > 0)
|
||||
{
|
||||
_loc2_ = _itemsSold.pop();
|
||||
_itemSoldPopup = new ItemSoldPopup(_loc2_.shopItem,_loc2_.soldAmount,_loc2_.currencyType,onCloseSoldPopup,param1);
|
||||
}
|
||||
else if(param1 != -1)
|
||||
{
|
||||
launchDenShopStore(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,933 @@
|
||||
package shop
|
||||
{
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarItem;
|
||||
import avatar.AvatarManager;
|
||||
import collection.AccItemCollection;
|
||||
import collection.DenItemCollection;
|
||||
import collection.IitemCollection;
|
||||
import collection.PetItemCollection;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import com.sbi.popup.SBYesNoPopup;
|
||||
import currency.UserCurrency;
|
||||
import den.DenItem;
|
||||
import den.DenXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.utils.Timer;
|
||||
import gui.DarkenManager;
|
||||
import gui.DenAndClothesItemSelect;
|
||||
import gui.DenSwitch;
|
||||
import gui.GuiRadioButtonGroup;
|
||||
import gui.PetInventory;
|
||||
import inventory.Iitem;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import localization.LocalizationManager;
|
||||
import pet.PetItem;
|
||||
import pet.PetManager;
|
||||
import pet.PetXtCommManager;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class ShopToSell extends Shop
|
||||
{
|
||||
|
||||
private var _itemSelect:DenAndClothesItemSelect;
|
||||
|
||||
private var _costTypeRadioBtns:GuiRadioButtonGroup;
|
||||
|
||||
private var _selectedItem:Iitem;
|
||||
|
||||
private var _addedItems:Vector.<MyShopItem>;
|
||||
|
||||
private var _removedItems:Vector.<MyShopItem>;
|
||||
|
||||
private var _modifiedItems:Vector.<MyShopItem>;
|
||||
|
||||
private var _myShopItems:Vector.<MyShopItem>;
|
||||
|
||||
private var _currMyShopItemsArray:Vector.<MyShopItem>;
|
||||
|
||||
private var _itemCurrentlyBeingUpdated:MyShopItem;
|
||||
|
||||
private var _clonedItems:AccItemCollection;
|
||||
|
||||
private var _clonedDenItems:DenItemCollection;
|
||||
|
||||
private var _clonedPetItems:PetItemCollection;
|
||||
|
||||
private var _myShopData:MyShopData;
|
||||
|
||||
private var _petInventory:PetInventory;
|
||||
|
||||
private var _selectedGemAmount:int;
|
||||
|
||||
private var _selectedDiamondAmount:int;
|
||||
|
||||
private var _counterMouseDown:Boolean;
|
||||
|
||||
private var _isIncrementing:Boolean;
|
||||
|
||||
private var _downTimer:Timer;
|
||||
|
||||
private var _myShopItemsReversed:Vector.<MyShopItem>;
|
||||
|
||||
private var _myShopItemsGemLow:Vector.<MyShopItem>;
|
||||
|
||||
private var _myShopItemsGemHigh:Vector.<MyShopItem>;
|
||||
|
||||
private var _myShopItemsNameLow:Vector.<MyShopItem>;
|
||||
|
||||
private var _myShopItemsNameHigh:Vector.<MyShopItem>;
|
||||
|
||||
public function ShopToSell()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function init(param1:int, param2:int, param3:Avatar, param4:DisplayLayer, param5:Function = null, param6:int = 0, param7:Function = null, param8:Boolean = false, param9:int = -1) : void
|
||||
{
|
||||
_isDenSaleShopOwner = param3.userName == RoomManagerWorld.instance.denOwnerName;
|
||||
_shopToSell = this;
|
||||
super.init(param1,1060,param3,param4,param5,param6,param7,param8,param9);
|
||||
}
|
||||
|
||||
public function get isDenSaleShopOwner() : Boolean
|
||||
{
|
||||
return _isDenSaleShopOwner;
|
||||
}
|
||||
|
||||
public function get shopInvId() : int
|
||||
{
|
||||
return _shopId;
|
||||
}
|
||||
|
||||
override public function applyAndClose() : void
|
||||
{
|
||||
if((_addedItems == null || _addedItems.length == 0) && (_removedItems == null || _removedItems.length == 0) && (_modifiedItems == null || _modifiedItems.length == 0))
|
||||
{
|
||||
_bItemsPurchased = false;
|
||||
super.applyAndClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
ShopToSellXtCommManager.requestStoreUpdateItems(_shopId,_myShopData.state,_addedItems,_removedItems,_modifiedItems,onUpdateStoreComplete);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeItemFromStore(param1:Iitem, param2:int) : void
|
||||
{
|
||||
var _loc4_:* = undefined;
|
||||
var _loc3_:int = 0;
|
||||
if(_myShopData)
|
||||
{
|
||||
_loc4_ = _myShopData.shopItems;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_.length)
|
||||
{
|
||||
if(_loc4_[_loc3_].currItem.itemType == param1.itemType && _loc4_[_loc3_].currItem.defId == param1.defId && _loc4_[_loc3_].currItem.invIdx == param2)
|
||||
{
|
||||
_loc4_.splice(_loc3_,1);
|
||||
break;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateMyShopDataState(param1:String, param2:int) : void
|
||||
{
|
||||
if(_myShopData && _myShopData.storeInvId == param2)
|
||||
{
|
||||
_myShopData.state = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function setupNewShopLists() : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
removeItemFromStore(currShopItem.currItem,currShopItem.currItem.invIdx);
|
||||
onShopInfoResponse(_myShopData,null,false);
|
||||
setupShopWindows();
|
||||
}
|
||||
|
||||
private function onUpdateStoreComplete(param1:Boolean, param2:Object) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(param1)
|
||||
{
|
||||
super.applyAndClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.applyAndClose();
|
||||
ShopManager.clearShopItems(_shopId);
|
||||
new SBOkPopup(_popupLayer,LocalizationManager.translateIdOnly(33933));
|
||||
}
|
||||
}
|
||||
|
||||
override protected function requestShopList(param1:Function, param2:int) : void
|
||||
{
|
||||
if(_isDenSaleShopOwner && ShopManager.myShopItems[param2] != null)
|
||||
{
|
||||
onShopInfoResponse(ShopManager.myShopItems[param2],null);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopToSellXtCommManager.requestStoreInfo(RoomManagerWorld.instance.denOwnerName,_shopId,onShopInfoResponse,null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onShopInfoResponse(param1:MyShopData, param2:Object, param3:Boolean = true) : void
|
||||
{
|
||||
var i:int;
|
||||
var shopData:MyShopData = param1;
|
||||
var passback:Object = param2;
|
||||
var initialize:Boolean = param3;
|
||||
if(_shop)
|
||||
{
|
||||
_myShopData = shopData;
|
||||
_myShopItems = shopData.shopItems.concat();
|
||||
_currMyShopItemsArray = _myShopItems;
|
||||
_shopItemArray = new IitemCollection();
|
||||
i = 0;
|
||||
while(i < _myShopItems.length)
|
||||
{
|
||||
_shopItemArray.pushIitem(_myShopItems[i].currItem);
|
||||
i = i + 1;
|
||||
}
|
||||
_myShopItemsReversed = _myShopItems.concat().reverse();
|
||||
_myShopItemsGemLow = _myShopItems.concat().sort(function(param1:MyShopItem, param2:MyShopItem):int
|
||||
{
|
||||
if(param1.currencyType > param2.currencyType)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(param1.currencyType == param2.currencyType)
|
||||
{
|
||||
if(param1.cost < param2.cost)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(param1.cost > param2.cost)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if(param1.currencyType < param2.currencyType)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
_myShopItemsGemHigh = _myShopItemsGemLow.concat().reverse();
|
||||
_shopItemArrayGemLow = new IitemCollection();
|
||||
i = 0;
|
||||
while(i < _myShopItemsGemLow.length)
|
||||
{
|
||||
_shopItemArrayGemLow.setIitem(i,_myShopItemsGemLow[i].currItem);
|
||||
i = i + 1;
|
||||
}
|
||||
_shopItemArrayGemHigh = new IitemCollection(_shopItemArrayGemLow.getCoreArray().concat().reverse());
|
||||
_myShopItemsNameLow = _myShopItems.concat().sort(function(param1:MyShopItem, param2:MyShopItem):int
|
||||
{
|
||||
if(param1.currItem.name > param2.currItem.name)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(param1.currItem.name < param2.currItem.name)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
_myShopItemsNameHigh = _myShopItemsNameLow.concat().reverse();
|
||||
_currShopItemArray = _shopItemArray;
|
||||
if(initialize)
|
||||
{
|
||||
initialShopSetup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onSortButton(param1:String, param2:Boolean) : void
|
||||
{
|
||||
if(param1 == "timeBtn")
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_currMyShopItemsArray = _myShopItemsReversed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currMyShopItemsArray = _myShopItems;
|
||||
}
|
||||
}
|
||||
else if(param1 == "gemBtn")
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_currMyShopItemsArray = _myShopItemsGemHigh;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currMyShopItemsArray = _myShopItemsGemLow;
|
||||
}
|
||||
}
|
||||
else if(param1 == "abcBtn")
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_currMyShopItemsArray = _myShopItemsNameLow;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currMyShopItemsArray = _myShopItemsNameHigh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override protected function initialShopSetup() : void
|
||||
{
|
||||
_isCombinedCurrencyStore = false;
|
||||
setupCombinedCurrencyItems(_isCombinedCurrencyStore);
|
||||
setupDiamondItems(_shopItemArray.length > 0 ? _shopItemArray.getIitem(0).currencyType == 3 && _glDefType != 1060 : false);
|
||||
if(_isDenSaleShopOwner)
|
||||
{
|
||||
LocalizationManager.translateId(_shop.titleTxt,33912);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalizationManager.translateIdAndInsert(_shop.titleTxt,33975,RoomManagerWorld.instance.denOwnerName);
|
||||
}
|
||||
super.setupCurrencyAmounts();
|
||||
super.shopSetupCommon();
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
}
|
||||
|
||||
override protected function setupClickedWindow(param1:int) : void
|
||||
{
|
||||
var _loc2_:Iitem = _currShopItemArray.getIitem(_itemIdx);
|
||||
if(!_loc2_)
|
||||
{
|
||||
if(_isDenSaleShopOwner && _numItems < 24)
|
||||
{
|
||||
if(_clonedItems == null)
|
||||
{
|
||||
_clonedItems = new AccItemCollection(gMainFrame.userInfo.playerAvatarInfo.getFullItems().concatCollection(null));
|
||||
_clonedDenItems = new DenItemCollection(AvatarManager.playerAvatar.inventoryDenFull.denItemCollection.concatCollection(null));
|
||||
_clonedPetItems = new PetItemCollection(PetManager.myPetListAsIitem.concatCollection(null));
|
||||
}
|
||||
_itemCurrentlyBeingUpdated = null;
|
||||
_itemSelect = new DenAndClothesItemSelect();
|
||||
_itemSelect.init(_clonedItems,_clonedDenItems,_clonedPetItems,_popupLayer,null,onChooseItemsClose,2,null,_currShopItemArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.colorCycleFlash.visible = false;
|
||||
_shop.colorCycleBtn.visible = false;
|
||||
if(_shop.buyBigPopup)
|
||||
{
|
||||
_shop.buyBigPopup.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_isDenSaleShopOwner)
|
||||
{
|
||||
_itemCurrentlyBeingUpdated = _currMyShopItemsArray[_itemIdx];
|
||||
onChooseItemsClose(_shopItemArray.getIitem(_itemIdx));
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setupClickedWindow(param1);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function setupBuyPopup() : void
|
||||
{
|
||||
_itemColorIdx = 0;
|
||||
_itemToBuy = _currShopItemArray.getIitem(_itemIdx).clone();
|
||||
_itemToBuy.asShopItemSized = true;
|
||||
if(_itemToBuy.isMemberOnly)
|
||||
{
|
||||
_shop.buyPopup.banner.visible = true;
|
||||
LocalizationManager.translateId(_shop.buyPopup.banner.txtCont.txt,11376);
|
||||
if(_isMember)
|
||||
{
|
||||
_shop.buyPopup.lockOpen.visible = true;
|
||||
_shop.buyPopup.lock.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyPopup.lock.visible = true;
|
||||
_shop.buyPopup.lockOpen.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyPopup.banner.visible = false;
|
||||
_shop.buyPopup.lockOpen.visible = false;
|
||||
_shop.buyPopup.lock.visible = false;
|
||||
}
|
||||
if(_itemToBuy.isOcean)
|
||||
{
|
||||
_shop.buyPopup.buyGreenBG.visible = false;
|
||||
_shop.buyPopup.ocean.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyPopup.buyGreenBG.visible = true;
|
||||
_shop.buyPopup.ocean.visible = false;
|
||||
}
|
||||
_shop.buyPopup.avtSpecificIcon.visible = false;
|
||||
_shop.buyPopup.newTag.visible = false;
|
||||
_shop.buyPopup.clearanceTag.visible = false;
|
||||
_shop.buyPopup.daysLeftTag.visible = false;
|
||||
_shop.buyPopup.saleTag.visible = false;
|
||||
_shop.buyPopup.rareDiamondTag.visible = false;
|
||||
_shop.buyPopup.customDiamond.visible = false;
|
||||
_shop.buyPopup.rareTag.visible = false;
|
||||
_shop.buyPopup.diamond.visible = false;
|
||||
if(_itemToBuy.isRareDiamond)
|
||||
{
|
||||
_shop.buyPopup.rareDiamondTag.visible = true;
|
||||
}
|
||||
else if(_itemToBuy.isCustom)
|
||||
{
|
||||
_shop.buyPopup.customDiamond.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_itemToBuy.isRare)
|
||||
{
|
||||
_shop.buyPopup.rareTag.visible = true;
|
||||
_shop.buyPopup.rareTag.gotoAndStop("noColor");
|
||||
}
|
||||
_shop.buyPopup.diamond.visible = _itemToBuy.isDiamond;
|
||||
}
|
||||
if(_itemToBuy.isDiamond)
|
||||
{
|
||||
_shop.buyPopup.buyGreenBGDiamond.visible = true;
|
||||
_shop.buyPopup.buyGreenBG.visible = false;
|
||||
_shop.buyPopup.buyBlueBGDiamond.visible = true;
|
||||
_shop.buyPopup.buyBlueBG.visible = false;
|
||||
_shop.buyPopup.bgDiamond.visible = true;
|
||||
_shop.buyPopup.bg.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyPopup.buyGreenBGDiamond.visible = false;
|
||||
_shop.buyPopup.buyGreenBG.visible = true;
|
||||
_shop.buyPopup.buyBlueBGDiamond.visible = false;
|
||||
_shop.buyPopup.buyBlueBG.visible = true;
|
||||
_shop.buyPopup.bgDiamond.visible = false;
|
||||
_shop.buyPopup.bg.visible = true;
|
||||
}
|
||||
if(_shop.buyPopup.itemLayer.numChildren > 1)
|
||||
{
|
||||
_shop.buyPopup.itemLayer.removeChildAt(1);
|
||||
}
|
||||
_shop.buyPopup.itemLayer.addChild(_itemToBuy.largeIcon);
|
||||
setupShopItemPrizeTags(_shop.buyPopup,_itemIdx,_shop.buyBtnGreen);
|
||||
LocalizationManager.updateToFit(_shop.buyPopupItemNameTxt,_itemToBuy.name);
|
||||
if(_shop.buyPopupItemNameTxt.text == _shop.buyPopupItemNameTxtMultiline.text)
|
||||
{
|
||||
_shop.buyPopup["bg" + _appendString].gotoAndStop("multi");
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyPopup["bg" + _appendString].gotoAndStop("single");
|
||||
}
|
||||
_shop.colorCycleFlash.visible = false;
|
||||
_shop.colorCycleBtn.visible = false;
|
||||
if(_shopWithPreview == null)
|
||||
{
|
||||
DarkenManager.darken(_shop.buyPopup);
|
||||
}
|
||||
_shop.buyPopup.visible = true;
|
||||
AJAudio.playSubMenuBtnClick();
|
||||
if(_itemToBuy.isOcean && _itemToBuy is DenItem && !DenSwitch.haveOceanDen())
|
||||
{
|
||||
new SBOkPopup(_popupLayer,LocalizationManager.translateIdOnly(14799));
|
||||
}
|
||||
_shop.buyBtnGreen.setButtonState(1);
|
||||
}
|
||||
|
||||
override protected function sendBuyRequest(param1:Iitem) : void
|
||||
{
|
||||
if(param1.itemType == 2)
|
||||
{
|
||||
ItemXtCommManager.setItemBuyIlCallback(putOnPurchasedItem);
|
||||
}
|
||||
else if(param1.itemType == 0)
|
||||
{
|
||||
DenXtCommManager.denEditorDIResponseCallback = onDenItemPurchaseInventoryResponse;
|
||||
}
|
||||
else if(param1.itemType == 1)
|
||||
{
|
||||
if(PetManager.myPetList.length + 1 > PetManager.getPetInventoryMax())
|
||||
{
|
||||
new SBYesNoPopup(_popupLayer,LocalizationManager.translateIdOnly(14783),true,confirmPetRecycle);
|
||||
return;
|
||||
}
|
||||
PetXtCommManager.petCreateCallback = OnPetFinderClose;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
ShopToSellXtCommManager.requestStoreBuy(RoomManagerWorld.instance.denOwnerName,currShopItem,_myShopData.state,confirmPurchase);
|
||||
}
|
||||
|
||||
private function confirmPetRecycle(param1:Object) : void
|
||||
{
|
||||
if(param1.status)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_petInventory = new PetInventory();
|
||||
_petInventory.init(onPetInventoryClose,true);
|
||||
}
|
||||
}
|
||||
|
||||
private function onPetInventoryClose(param1:Boolean) : void
|
||||
{
|
||||
_petInventory = null;
|
||||
if(param1)
|
||||
{
|
||||
attemptToPurchaseItem();
|
||||
}
|
||||
}
|
||||
|
||||
public function setupShopItemPrizeTags(param1:MovieClip, param2:int, param3:MovieClip = null) : void
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc5_:MyShopItem = _currMyShopItemsArray.length > param2 ? _currMyShopItemsArray[param2] : null;
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc4_ = "";
|
||||
if(_loc5_.currencyType == 1)
|
||||
{
|
||||
_loc4_ = "ticket";
|
||||
}
|
||||
else if(_loc5_.currencyType == 2)
|
||||
{
|
||||
_loc4_ = "earth";
|
||||
}
|
||||
else if(_loc5_.currencyType == 3)
|
||||
{
|
||||
_loc4_ = "diamond";
|
||||
}
|
||||
if(UserCurrency.hasEnoughCurrency(_loc5_.currencyType,_loc5_.cost))
|
||||
{
|
||||
if(param1.tag.currentFrameLabel != _loc4_ + "green")
|
||||
{
|
||||
param1.tag.gotoAndPlay(_loc4_ + "green");
|
||||
}
|
||||
param1.tag.txt.textColor = "0x386630";
|
||||
if(param3 != null)
|
||||
{
|
||||
param3.visible = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param1.tag.currentFrameLabel != _loc4_ + "red")
|
||||
{
|
||||
param1.tag.gotoAndPlay(_loc4_ + "red");
|
||||
}
|
||||
param1.tag.txt.textColor = "0x800000";
|
||||
if(param3 != null)
|
||||
{
|
||||
param3.visible = false;
|
||||
}
|
||||
}
|
||||
param1.tag.txt.text = Utility.convertNumberToString(_loc5_.cost);
|
||||
param1.tag.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.tag.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function onEditBtn(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
param1.stopPropagation();
|
||||
if(param1.currentTarget.parent.name == _shop.iw0.name)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw1.name)
|
||||
{
|
||||
_loc3_ = 1;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw2.name)
|
||||
{
|
||||
_loc3_ = 2;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw3.name)
|
||||
{
|
||||
_loc3_ = 3;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw4.name)
|
||||
{
|
||||
_loc3_ = 4;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw5.name)
|
||||
{
|
||||
_loc3_ = 5;
|
||||
}
|
||||
var _loc2_:int = _loc3_ + _itemOffset;
|
||||
_itemCurrentlyBeingUpdated = _currMyShopItemsArray[_loc2_];
|
||||
onChooseItemsClose(_shopItemArray.getIitem(_loc2_));
|
||||
}
|
||||
|
||||
public function onDeleteBtn(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:Boolean = false;
|
||||
var _loc5_:int = 0;
|
||||
param1.stopPropagation();
|
||||
if(param1.currentTarget.parent.name == _shop.iw0.name)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw1.name)
|
||||
{
|
||||
_loc7_ = 1;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw2.name)
|
||||
{
|
||||
_loc7_ = 2;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw3.name)
|
||||
{
|
||||
_loc7_ = 3;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw4.name)
|
||||
{
|
||||
_loc7_ = 4;
|
||||
}
|
||||
else if(param1.currentTarget.parent.name == _shop.iw5.name)
|
||||
{
|
||||
_loc7_ = 5;
|
||||
}
|
||||
var _loc4_:int = _loc7_ + _itemOffset;
|
||||
var _loc6_:Iitem = _shopItemArray.getIitem(_loc4_);
|
||||
if(_addedItems)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _addedItems.length)
|
||||
{
|
||||
if(_addedItems[_loc5_].currItem.itemType == _loc6_.itemType && _addedItems[_loc5_].currItem.defId == _loc6_.defId)
|
||||
{
|
||||
_addedItems.splice(_loc5_,1);
|
||||
_loc3_ = true;
|
||||
break;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(_modifiedItems)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _modifiedItems.length)
|
||||
{
|
||||
if(_modifiedItems[_loc5_].currItem.itemType == _loc6_.itemType && _modifiedItems[_loc5_].currItem.defId == _loc6_.defId)
|
||||
{
|
||||
_modifiedItems.splice(_loc5_,1);
|
||||
break;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
var _loc2_:MyShopItem = _currMyShopItemsArray.splice(_loc4_,1)[0];
|
||||
if(!_loc3_)
|
||||
{
|
||||
if(_removedItems == null)
|
||||
{
|
||||
_removedItems = new Vector.<MyShopItem>();
|
||||
}
|
||||
_removedItems.push(_loc2_);
|
||||
}
|
||||
_shopItemArray.getCoreArray().splice(_loc4_,1);
|
||||
_currShopItemArray = _shopItemArray;
|
||||
setupShopWindows();
|
||||
}
|
||||
|
||||
public function get currShopItem() : MyShopItem
|
||||
{
|
||||
return _currMyShopItemsArray[_itemIdx];
|
||||
}
|
||||
|
||||
private function onChooseItemsClose(param1:Iitem) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
displaySetCostPopup(param1);
|
||||
}
|
||||
if(_itemSelect)
|
||||
{
|
||||
_itemSelect.destroy();
|
||||
_itemSelect = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function displaySetCostPopup(param1:Iitem) : void
|
||||
{
|
||||
var _loc2_:MovieClip = null;
|
||||
_selectedItem = param1.clone();
|
||||
_shop.setItemCostCont.item_name_txt.text = _selectedItem.name;
|
||||
_costTypeRadioBtns = new GuiRadioButtonGroup(_shop.setItemCostCont.options);
|
||||
_costTypeRadioBtns.selected = _itemCurrentlyBeingUpdated ? (_itemCurrentlyBeingUpdated.currencyType == 3 ? 1 : 0) : 1;
|
||||
_costTypeRadioBtns.currRadioButton.addEventListener("mouseDown",onCostDown,false,0,true);
|
||||
_shop.setItemCostCont.numTxt.text = _itemCurrentlyBeingUpdated ? _itemCurrentlyBeingUpdated.cost : (_costTypeRadioBtns.selected == 1 ? 1 : 50);
|
||||
_selectedDiamondAmount = 1;
|
||||
_selectedGemAmount = 50;
|
||||
setPriceTag();
|
||||
if(_selectedItem.isOcean)
|
||||
{
|
||||
_shop.setItemCostCont.buyBlueBG.visible = true;
|
||||
_shop.setItemCostCont.buyGreenBG.visible = false;
|
||||
_loc2_ = _shop.setItemCostCont.buyBlueBG;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.setItemCostCont.buyGreenBG.visible = true;
|
||||
_shop.setItemCostCont.buyBlueBG.visible = false;
|
||||
_loc2_ = _shop.setItemCostCont.buyGreenBG;
|
||||
}
|
||||
while(_loc2_.numChildren > 1)
|
||||
{
|
||||
_loc2_.removeChildAt(_loc2_.numChildren - 1);
|
||||
}
|
||||
_selectedItem.asShopItemSized = true;
|
||||
if(_selectedItem is Item)
|
||||
{
|
||||
(_selectedItem as Item).specialScale = 1.25;
|
||||
}
|
||||
_loc2_.addChild(_selectedItem.icon);
|
||||
if(!(_selectedItem is DenItem) && !(_selectedItem is AvatarItem) && !(_selectedItem is PetItem))
|
||||
{
|
||||
_selectedItem.icon.filters = [new GlowFilter(5586479,1,2,2,4)];
|
||||
}
|
||||
_downTimer = new Timer(500);
|
||||
_downTimer.addEventListener("timer",onTimer,false,0,true);
|
||||
_shop.setItemCostCont.setCostBtn.addEventListener("mouseDown",onSetCostDown,false,0,true);
|
||||
_shop.setItemCostCont.closeBtn.addEventListener("mouseDown",onCloseCostPopup,false,0,true);
|
||||
_shop.setItemCostCont.upBtn.addEventListener("mouseDown",onUpDownBtn,false,0,true);
|
||||
_shop.setItemCostCont.downBtn.addEventListener("mouseDown",onUpDownBtn,false,0,true);
|
||||
_shop.setItemCostCont.upBtn.addEventListener("mouseUp",onUpDownBtnUp,false,0,true);
|
||||
_shop.setItemCostCont.downBtn.addEventListener("mouseUp",onUpDownBtnUp,false,0,true);
|
||||
_shop.setItemCostCont.upBtn.addEventListener("rollOut",onUpDownBtnUp,false,0,true);
|
||||
_shop.setItemCostCont.downBtn.addEventListener("rollOut",onUpDownBtnUp,false,0,true);
|
||||
_shop.setItemCostCont.addEventListener("enterFrame",onEnterFrame,false,0,true);
|
||||
_shop.setItemCostCont.visible = true;
|
||||
}
|
||||
|
||||
private function onCostDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(_costTypeRadioBtns.selected == 1)
|
||||
{
|
||||
_shop.setItemCostCont.numTxt.text = _selectedDiamondAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.setItemCostCont.numTxt.text = _selectedGemAmount;
|
||||
}
|
||||
setPriceTag();
|
||||
}
|
||||
|
||||
private function onSetCostDown(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:MyShopItem = null;
|
||||
param1.stopPropagation();
|
||||
if(_itemCurrentlyBeingUpdated)
|
||||
{
|
||||
if(_modifiedItems == null)
|
||||
{
|
||||
_modifiedItems = new Vector.<MyShopItem>();
|
||||
}
|
||||
_itemCurrentlyBeingUpdated.cost = int(_shop.setItemCostCont.numTxt.text);
|
||||
_itemCurrentlyBeingUpdated.currencyType = _costTypeRadioBtns.selected == 1 ? 3 : 0;
|
||||
if(_addedItems)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _addedItems.length)
|
||||
{
|
||||
if(_addedItems[_loc4_].currItem.itemType == _itemCurrentlyBeingUpdated.currItem.itemType && _addedItems[_loc4_].currItem.defId == _itemCurrentlyBeingUpdated.currItem.defId)
|
||||
{
|
||||
_loc2_ = true;
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
if(!_loc2_)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _modifiedItems.length)
|
||||
{
|
||||
if(_modifiedItems[_loc4_].currItem.itemType == _itemCurrentlyBeingUpdated.currItem.itemType && _modifiedItems[_loc4_].currItem.defId == _itemCurrentlyBeingUpdated.currItem.defId)
|
||||
{
|
||||
_loc2_ = true;
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
if(!_loc2_)
|
||||
{
|
||||
_modifiedItems.push(_itemCurrentlyBeingUpdated);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_removedItems)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _removedItems.length)
|
||||
{
|
||||
if(_removedItems[_loc4_].currItem.itemType == _selectedItem.itemType && _removedItems[_loc4_].currItem.defId == _selectedItem.defId)
|
||||
{
|
||||
if((_costTypeRadioBtns.selected == 1 ? 3 : 0) == _removedItems[_loc4_].currencyType && int(_shop.setItemCostCont.numTxt.text) == _removedItems[_loc4_].cost)
|
||||
{
|
||||
_loc2_ = true;
|
||||
}
|
||||
_removedItems.splice(_loc4_,1);
|
||||
break;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
_shopItemArray.pushIitem(_selectedItem.clone());
|
||||
_loc3_ = new MyShopItem(_selectedItem.clone(),_costTypeRadioBtns.selected == 1 ? 3 : 0,int(_shop.setItemCostCont.numTxt.text),_shopId);
|
||||
if(!_loc2_)
|
||||
{
|
||||
if(_addedItems == null)
|
||||
{
|
||||
_addedItems = new Vector.<MyShopItem>();
|
||||
}
|
||||
_addedItems.push(_loc3_);
|
||||
}
|
||||
_currMyShopItemsArray.push(_loc3_);
|
||||
}
|
||||
_currShopItemArray = _shopItemArray;
|
||||
setupShopWindows();
|
||||
onCloseCostPopup(param1);
|
||||
}
|
||||
|
||||
private function onCloseCostPopup(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_shop.setItemCostCont.setCostBtn.removeEventListener("mouseDown",onSetCostDown);
|
||||
_shop.setItemCostCont.closeBtn.removeEventListener("mouseDown",onCloseCostPopup);
|
||||
_shop.setItemCostCont.upBtn.removeEventListener("mouseDown",onUpDownBtn);
|
||||
_shop.setItemCostCont.downBtn.removeEventListener("mouseDown",onUpDownBtn);
|
||||
_shop.setItemCostCont.upBtn.removeEventListener("mouseUp",onUpDownBtnUp);
|
||||
_shop.setItemCostCont.downBtn.removeEventListener("mouseUp",onUpDownBtnUp);
|
||||
_shop.setItemCostCont.upBtn.removeEventListener("rollOut",onUpDownBtnUp);
|
||||
_shop.setItemCostCont.downBtn.removeEventListener("rollOut",onUpDownBtnUp);
|
||||
_shop.setItemCostCont.removeEventListener("enterFrame",onEnterFrame);
|
||||
_downTimer.removeEventListener("timer",onTimer);
|
||||
_downTimer.reset();
|
||||
_downTimer = null;
|
||||
_costTypeRadioBtns.destroy();
|
||||
_costTypeRadioBtns = null;
|
||||
_selectedItem = null;
|
||||
_shop.setItemCostCont.visible = false;
|
||||
}
|
||||
|
||||
private function setPriceTag() : void
|
||||
{
|
||||
var _loc1_:String = "";
|
||||
if(_costTypeRadioBtns.selected == 1)
|
||||
{
|
||||
_loc1_ = "diamond";
|
||||
_shop.setItemCostCont.gemHighlight.visible = false;
|
||||
_shop.setItemCostCont.diamondHighlight.visible = true;
|
||||
_selectedDiamondAmount = _shop.setItemCostCont.numTxt.text;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.setItemCostCont.gemHighlight.visible = true;
|
||||
_shop.setItemCostCont.diamondHighlight.visible = false;
|
||||
_selectedGemAmount = _shop.setItemCostCont.numTxt.text;
|
||||
}
|
||||
if(_shop.setItemCostCont.tag.currentFrameLabel != _loc1_ + "green")
|
||||
{
|
||||
_shop.setItemCostCont.tag.gotoAndPlay(_loc1_ + "green");
|
||||
}
|
||||
_shop.setItemCostCont.tag.txt.textColor = "0x386630";
|
||||
_shop.setItemCostCont.tag.txt.text = Utility.convertNumberToString(_shop.setItemCostCont.numTxt.text);
|
||||
_shop.setItemCostCont.tag.visible = true;
|
||||
}
|
||||
|
||||
private function onEnterFrame(param1:Event) : void
|
||||
{
|
||||
if(_counterMouseDown)
|
||||
{
|
||||
if(_downTimer.currentCount == 0)
|
||||
{
|
||||
_downTimer.start();
|
||||
}
|
||||
else if(_downTimer.currentCount == 1)
|
||||
{
|
||||
updateCost(_isIncrementing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onTimer(param1:TimerEvent) : void
|
||||
{
|
||||
_downTimer.stop();
|
||||
}
|
||||
|
||||
private function onUpDownBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_counterMouseDown = true;
|
||||
if(param1.currentTarget == _shop.setItemCostCont.upBtn)
|
||||
{
|
||||
_isIncrementing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isIncrementing = false;
|
||||
}
|
||||
updateCost(_isIncrementing);
|
||||
}
|
||||
|
||||
private function onUpDownBtnUp(param1:Event) : void
|
||||
{
|
||||
_counterMouseDown = false;
|
||||
_downTimer.reset();
|
||||
}
|
||||
|
||||
private function updateCost(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:int = _costTypeRadioBtns.selected == 1 ? 1 : 50;
|
||||
var _loc3_:int = _costTypeRadioBtns.selected == 1 ? 500 : 15000;
|
||||
var _loc4_:int = int(_shop.setItemCostCont.numTxt.text);
|
||||
if(param1)
|
||||
{
|
||||
_shop.setItemCostCont.numTxt.text = Math.min(int(_shop.setItemCostCont.numTxt.text) + _loc2_,_loc3_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.setItemCostCont.numTxt.text = Math.max(_loc2_,int(_shop.setItemCostCont.numTxt.text) - _loc2_);
|
||||
}
|
||||
var _loc5_:int = int(_shop.setItemCostCont.numTxt.text);
|
||||
if(_loc4_ != _loc5_)
|
||||
{
|
||||
setPriceTag();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,766 @@
|
||||
package shop
|
||||
{
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarInfo;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.UserInfo;
|
||||
import collection.AccItemCollection;
|
||||
import collection.DenItemCollection;
|
||||
import collection.PetItemCollection;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import currency.UserCurrency;
|
||||
import den.DenItem;
|
||||
import den.DenMannequinInventory;
|
||||
import den.DenXtCommManager;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.StartupPopups;
|
||||
import inventory.Iitem;
|
||||
import item.Item;
|
||||
import localization.LocalizationManager;
|
||||
import pet.PetItem;
|
||||
import pet.PetManager;
|
||||
import pet.PetXtCommManager;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class ShopToSellXtCommManager
|
||||
{
|
||||
|
||||
private static var _itemsAdded:Vector.<MyShopItem>;
|
||||
|
||||
private static var _itemsRemoved:Vector.<MyShopItem>;
|
||||
|
||||
private static var _itemsChanged:Vector.<MyShopItem>;
|
||||
|
||||
private static var _storeInvId:int;
|
||||
|
||||
private static var _dsbCallback:Function;
|
||||
|
||||
private static var _dsbPassback:Object;
|
||||
|
||||
private static var _dsbResponsesToProcess:Array;
|
||||
|
||||
private static var _dsuCallbacks:Array = [];
|
||||
|
||||
private static var _dsiCallbacks:Array = [];
|
||||
|
||||
public function ShopToSellXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function requestStoreUpdateItems(param1:int, param2:String, param3:Vector.<MyShopItem>, param4:Vector.<MyShopItem>, param5:Vector.<MyShopItem>, param6:Function = null, param7:Object = null) : void
|
||||
{
|
||||
var _loc10_:int = 0;
|
||||
_storeInvId = param1;
|
||||
_itemsAdded = param3;
|
||||
_itemsRemoved = param4;
|
||||
_itemsChanged = param5;
|
||||
var _loc9_:Array = [];
|
||||
var _loc8_:Array = [];
|
||||
var _loc11_:Array = [_storeInvId,param2];
|
||||
if(param3)
|
||||
{
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < param3.length)
|
||||
{
|
||||
_loc9_.push(param3[_loc10_].currItem.itemType);
|
||||
_loc9_.push(param3[_loc10_].currItem.invIdx);
|
||||
_loc9_.push(param3[_loc10_].currencyType);
|
||||
_loc9_.push(param3[_loc10_].cost);
|
||||
_loc10_++;
|
||||
}
|
||||
}
|
||||
if(param5)
|
||||
{
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < param5.length)
|
||||
{
|
||||
_loc9_.push(param5[_loc10_].currItem.itemType);
|
||||
_loc9_.push(param5[_loc10_].currItem.invIdx);
|
||||
_loc9_.push(param5[_loc10_].currencyType);
|
||||
_loc9_.push(param5[_loc10_].cost);
|
||||
_loc10_++;
|
||||
}
|
||||
}
|
||||
if(param4)
|
||||
{
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < param4.length)
|
||||
{
|
||||
_loc8_.push(param4[_loc10_].currItem.itemType);
|
||||
_loc8_.push(param4[_loc10_].currItem.invIdx);
|
||||
_loc10_++;
|
||||
}
|
||||
}
|
||||
if(_loc9_.length > 0)
|
||||
{
|
||||
_loc11_.push(_loc9_.length / 4);
|
||||
_loc11_ = _loc11_.concat(_loc9_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_.push(0);
|
||||
}
|
||||
if(_loc8_.length > 0)
|
||||
{
|
||||
_loc11_.push(_loc8_.length / 2);
|
||||
_loc11_ = _loc11_.concat(_loc8_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_.push(0);
|
||||
}
|
||||
_dsuCallbacks.push({
|
||||
"callback":param6,
|
||||
"passback":param7
|
||||
});
|
||||
gMainFrame.server.setXtObject_Str("dsu",_loc11_);
|
||||
}
|
||||
|
||||
public static function requestStoreInfo(param1:String, param2:int, param3:Function, param4:Object) : void
|
||||
{
|
||||
_dsiCallbacks.push({
|
||||
"callback":param3,
|
||||
"passback":param4,
|
||||
"forMyself":param1.toLowerCase() == gMainFrame.userInfo.myUserName.toLowerCase()
|
||||
});
|
||||
_storeInvId = param2;
|
||||
gMainFrame.server.setXtObject_Str("dsi",[param1,param2]);
|
||||
}
|
||||
|
||||
public static function requestStoreBuy(param1:String, param2:MyShopItem, param3:String, param4:Function) : void
|
||||
{
|
||||
_dsbCallback = param4;
|
||||
gMainFrame.server.setXtObject_Str("dsb",[param1,param2.shopInvIdx,param3,param2.currItem.itemType,param2.currItem.invIdx,param2.currencyType,param2.cost]);
|
||||
}
|
||||
|
||||
public static function get hasBuysToProcess() : Boolean
|
||||
{
|
||||
return _dsbResponsesToProcess != null && _dsbResponsesToProcess.length > 0;
|
||||
}
|
||||
|
||||
public static function processBuyResponses() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
if(_dsbResponsesToProcess && _dsbResponsesToProcess.length > 0)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _dsbResponsesToProcess.length)
|
||||
{
|
||||
onDenStoreBuy(_dsbResponsesToProcess.shift());
|
||||
_loc1_--;
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
_dsbResponsesToProcess = null;
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Object = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "dsu":
|
||||
onDenStoreUpdate(_loc2_);
|
||||
break;
|
||||
case "dsi":
|
||||
onDenStoreInfo(_loc2_ as Array);
|
||||
break;
|
||||
case "dsb":
|
||||
onDenStoreBuy(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("ShopToSellXtCommManager: Received illegal cmd: " + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDenStoreUpdate(param1:Object) : void
|
||||
{
|
||||
var _loc11_:String = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc10_:UserInfo = null;
|
||||
var _loc8_:Object = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc12_:int = 0;
|
||||
var _loc7_:Avatar = null;
|
||||
var _loc9_:AccItemCollection = null;
|
||||
var _loc13_:AccItemCollection = null;
|
||||
var _loc3_:Array = null;
|
||||
var _loc4_:Object = _dsuCallbacks.shift();
|
||||
if(param1[2] == "1")
|
||||
{
|
||||
_loc11_ = param1[3];
|
||||
_loc10_ = gMainFrame.userInfo.playerUserInfo;
|
||||
_loc8_ = gMainFrame.userInfo.playerUserInfo.avList;
|
||||
_loc2_ = int(gMainFrame.userInfo.playerAvatarInfo.type);
|
||||
_loc12_ = int(gMainFrame.userInfo.playerAvatarInfo.perUserAvId);
|
||||
_loc7_ = AvatarManager.getAvatarByUsernamePerUserAvId(_loc10_.userName,_loc12_);
|
||||
_loc9_ = _loc10_.getFullItemList(false);
|
||||
_loc13_ = _loc7_.inventoryClothing.itemCollection;
|
||||
_loc3_ = PetManager.myPetList;
|
||||
if(_itemsAdded)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _itemsAdded.length)
|
||||
{
|
||||
_itemsAdded[_loc5_].currItem.denStoreInvId = _storeInvId;
|
||||
updateInDenShopValues(_loc9_,_loc13_,_loc10_.denItemsFull,_loc3_,_itemsAdded[_loc5_].currItem.itemType,_itemsAdded[_loc5_].currItem.invIdx,true);
|
||||
updateMyDenShopList(_storeInvId,_itemsAdded[_loc5_].currItem,true,_itemsAdded[_loc5_].currencyType,_itemsAdded[_loc5_].cost);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(_itemsRemoved)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _itemsRemoved.length)
|
||||
{
|
||||
_itemsRemoved[_loc5_].currItem.denStoreInvId = 0;
|
||||
updateInDenShopValues(_loc9_,_loc13_,_loc10_.denItemsFull,_loc3_,_itemsRemoved[_loc5_].currItem.itemType,_itemsRemoved[_loc5_].currItem.invIdx,false);
|
||||
updateMyDenShopList(_storeInvId,_itemsRemoved[_loc5_].currItem,false,-1,-1);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(ShopManager.myShopItems && ShopManager.myShopItems.length > 0)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _itemsChanged.length)
|
||||
{
|
||||
updateMyDenShopList(_storeInvId,_itemsChanged[_loc5_].currItem,true,_itemsChanged[_loc5_].currencyType,_itemsChanged[_loc5_].cost);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
ShopManager.updateShopState(_storeInvId,_loc11_);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopManager.clearShopItems(_storeInvId);
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(33933));
|
||||
}
|
||||
}
|
||||
GuiManager.resetWindowsAndTabsToNormal();
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc4_.callback(param1[2] == "1",_loc4_.passback);
|
||||
}
|
||||
}
|
||||
|
||||
private static function updateInDenShopValues(param1:AccItemCollection, param2:AccItemCollection, param3:DenItemCollection, param4:Array, param5:int, param6:int, param7:Boolean) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
if(param5 == 2)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param1.length)
|
||||
{
|
||||
if(param1.getAccItem(_loc8_).invIdx == param6)
|
||||
{
|
||||
param1.getAccItem(_loc8_).denStoreInvId = param7 ? _storeInvId : 0;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param2.length)
|
||||
{
|
||||
if(param2.getAccItem(_loc8_).invIdx == param6)
|
||||
{
|
||||
param2.getAccItem(_loc8_).denStoreInvId = param7 ? _storeInvId : 0;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
else if(param5 == 0)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param3.length)
|
||||
{
|
||||
if(param3.getDenItem(_loc8_).invIdx == param6)
|
||||
{
|
||||
param3.getDenItem(_loc8_).denStoreInvId = param7 ? _storeInvId : 0;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
else if(param5 == 1)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param4.length)
|
||||
{
|
||||
if(param4[_loc8_].idx == param6)
|
||||
{
|
||||
param4[_loc8_].denStoreInvId = param7 ? _storeInvId : 0;
|
||||
gMainFrame.userInfo.updatePetsDenShopUse(param6,param7 ? _storeInvId : 0,false);
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function updateMyDenShopList(param1:int, param2:Iitem, param3:Boolean, param4:int, param5:int) : void
|
||||
{
|
||||
var _loc9_:MyShopItem = null;
|
||||
var _loc6_:Boolean = false;
|
||||
var _loc10_:* = undefined;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:MyShopData = ShopManager.myShopItems[param1];
|
||||
if(_loc7_)
|
||||
{
|
||||
_loc10_ = _loc7_.shopItems;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc10_.length)
|
||||
{
|
||||
_loc9_ = _loc10_[_loc8_];
|
||||
if(_loc9_.currItem.itemType == param2.itemType && _loc9_.currItem.invIdx == param2.invIdx)
|
||||
{
|
||||
if(!param3)
|
||||
{
|
||||
_loc10_.splice(_loc8_,1);
|
||||
break;
|
||||
}
|
||||
_loc9_.currencyType = param4;
|
||||
_loc9_.cost = param5;
|
||||
_loc6_ = true;
|
||||
break;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
if(!_loc6_ && param3)
|
||||
{
|
||||
_loc10_.push(new MyShopItem(param2,param4,param5,param1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDenStoreInfo(param1:Array) : void
|
||||
{
|
||||
var _loc6_:MyShopData = null;
|
||||
var _loc10_:* = null;
|
||||
var _loc16_:Iitem = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc28_:int = 0;
|
||||
var _loc22_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc15_:int = 0;
|
||||
var _loc17_:String = null;
|
||||
var _loc24_:UserInfo = null;
|
||||
var _loc23_:AccItemCollection = null;
|
||||
var _loc5_:PetItemCollection = null;
|
||||
var _loc4_:DenItemCollection = null;
|
||||
var _loc20_:int = 0;
|
||||
var _loc12_:* = undefined;
|
||||
var _loc26_:Boolean = false;
|
||||
var _loc18_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc14_:Boolean = false;
|
||||
var _loc11_:Iitem = null;
|
||||
var _loc27_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc19_:int = 2;
|
||||
var _loc25_:Boolean = Boolean(param1[_loc19_++] = "1");
|
||||
var _loc21_:int = int(param1[_loc19_++]);
|
||||
var _loc13_:Vector.<MyShopItem> = new Vector.<MyShopItem>();
|
||||
var _loc9_:Object = _dsiCallbacks.shift();
|
||||
if(_loc21_ > -1)
|
||||
{
|
||||
_loc17_ = param1.length > _loc19_ ? param1[_loc19_++] : "";
|
||||
if(_loc9_.forMyself)
|
||||
{
|
||||
_loc24_ = gMainFrame.userInfo.playerUserInfo;
|
||||
_loc23_ = _loc24_.getFullItemList(false);
|
||||
_loc5_ = PetManager.myPetListAsIitem;
|
||||
_loc4_ = _loc24_.denItemsPartial;
|
||||
_loc12_ = new Vector.<MyShopItem>();
|
||||
}
|
||||
_loc18_ = 0;
|
||||
while(_loc18_ < _loc21_)
|
||||
{
|
||||
_loc2_ = int(param1[_loc19_++]);
|
||||
_loc15_ = int(param1[_loc19_++]);
|
||||
_loc3_ = int(param1[_loc19_++]);
|
||||
_loc28_ = int(param1[_loc19_++]);
|
||||
_loc22_ = int(param1[_loc19_++]);
|
||||
_loc16_ = null;
|
||||
_loc26_ = false;
|
||||
if(2 == _loc3_)
|
||||
{
|
||||
if(_loc9_.forMyself)
|
||||
{
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc23_.length)
|
||||
{
|
||||
if(_loc23_.getAccItem(_loc20_).invIdx == _loc28_)
|
||||
{
|
||||
_loc16_ = _loc23_.getAccItem(_loc20_);
|
||||
break;
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
if(_loc16_ == null)
|
||||
{
|
||||
_loc26_ = true;
|
||||
_loc16_ = new Item();
|
||||
(_loc16_ as Item).init(_loc22_,_loc28_,0,null,false,-1,_storeInvId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = new Item();
|
||||
(_loc16_ as Item).init(_loc22_,_loc28_,param1[_loc19_++],null,false,-1,_storeInvId);
|
||||
}
|
||||
}
|
||||
else if(0 == _loc3_)
|
||||
{
|
||||
if(_loc9_.forMyself)
|
||||
{
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc4_.length)
|
||||
{
|
||||
if(_loc4_.getDenItem(_loc20_).invIdx == _loc28_)
|
||||
{
|
||||
_loc16_ = _loc4_.getDenItem(_loc20_);
|
||||
break;
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
if(_loc16_ == null)
|
||||
{
|
||||
_loc26_ = true;
|
||||
_loc16_ = new DenItem();
|
||||
(_loc16_ as DenItem).init(_loc22_,_loc28_,0,0,0,null,true,"","",-1,"",null,_storeInvId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = new DenItem();
|
||||
(_loc16_ as DenItem).init(_loc22_,_loc28_,0,param1[_loc19_++],0,null,param1[_loc19_++],param1[_loc19_++],"",param1[_loc19_++],param1[_loc19_++],null,_storeInvId);
|
||||
}
|
||||
}
|
||||
else if(1 == _loc3_)
|
||||
{
|
||||
if(_loc9_.forMyself)
|
||||
{
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc5_.length)
|
||||
{
|
||||
if(_loc5_.getPetItem(_loc20_).invIdx == _loc28_)
|
||||
{
|
||||
_loc16_ = _loc5_.getPetItem(_loc20_);
|
||||
break;
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
if(_loc16_ == null)
|
||||
{
|
||||
_loc26_ = true;
|
||||
_loc16_ = new PetItem();
|
||||
(_loc16_ as PetItem).init(0,_loc22_,[0,0,0],0,0,0,_loc28_,null,false,null,null,_storeInvId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = new PetItem();
|
||||
(_loc16_ as PetItem).init(param1[_loc19_++],_loc22_,[param1[_loc19_++],param1[_loc19_++],param1[_loc19_++]],param1[_loc19_++],param1[_loc19_++],param1[_loc19_++],_loc28_,param1[_loc19_++],false,null,null,_storeInvId);
|
||||
_loc8_ = int(param1[_loc19_++]);
|
||||
}
|
||||
}
|
||||
if(_loc26_)
|
||||
{
|
||||
_loc12_.push(new MyShopItem(_loc16_,_loc2_,_loc15_,_storeInvId));
|
||||
DebugUtility.debugTrace("Item is null in den store");
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_.push(new MyShopItem(_loc16_,_loc2_,_loc15_,_storeInvId));
|
||||
}
|
||||
_loc18_++;
|
||||
}
|
||||
_loc6_ = new MyShopData(_storeInvId,_loc17_,_loc13_);
|
||||
if(_loc9_.forMyself)
|
||||
{
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc23_.length)
|
||||
{
|
||||
_loc11_ = _loc23_.getAccItem(_loc20_);
|
||||
if(_loc11_.denStoreInvId == _storeInvId)
|
||||
{
|
||||
_loc27_ = _loc11_.invIdx;
|
||||
_loc7_ = _loc11_.itemType;
|
||||
_loc14_ = false;
|
||||
_loc18_ = 0;
|
||||
while(_loc18_ < _loc13_.length)
|
||||
{
|
||||
if(_loc27_ == _loc13_[_loc18_].currItem.invIdx && _loc7_ == _loc13_[_loc18_].currItem.itemType)
|
||||
{
|
||||
_loc14_ = true;
|
||||
break;
|
||||
}
|
||||
_loc18_++;
|
||||
}
|
||||
if(!_loc14_)
|
||||
{
|
||||
_loc12_.push(new MyShopItem(_loc11_,0,0,_storeInvId));
|
||||
}
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc4_.length)
|
||||
{
|
||||
_loc11_ = _loc4_.getDenItem(_loc20_);
|
||||
if(_loc11_.denStoreInvId == _storeInvId)
|
||||
{
|
||||
_loc27_ = _loc11_.invIdx;
|
||||
_loc7_ = _loc11_.itemType;
|
||||
_loc14_ = false;
|
||||
_loc18_ = 0;
|
||||
while(_loc18_ < _loc13_.length)
|
||||
{
|
||||
if(_loc27_ == _loc13_[_loc18_].currItem.invIdx && _loc7_ == _loc13_[_loc18_].currItem.itemType)
|
||||
{
|
||||
_loc14_ = true;
|
||||
break;
|
||||
}
|
||||
_loc18_++;
|
||||
}
|
||||
if(!_loc14_)
|
||||
{
|
||||
_loc12_.push(new MyShopItem(_loc11_,0,0,_storeInvId));
|
||||
}
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc5_.length)
|
||||
{
|
||||
_loc11_ = _loc5_.getPetItem(_loc20_);
|
||||
if(_loc11_.denStoreInvId == _storeInvId)
|
||||
{
|
||||
_loc27_ = _loc11_.invIdx;
|
||||
_loc7_ = _loc11_.itemType;
|
||||
_loc14_ = false;
|
||||
_loc18_ = 0;
|
||||
while(_loc18_ < _loc13_.length)
|
||||
{
|
||||
if(_loc27_ == _loc13_[_loc18_].currItem.invIdx && _loc7_ == _loc13_[_loc18_].currItem.itemType)
|
||||
{
|
||||
_loc14_ = true;
|
||||
break;
|
||||
}
|
||||
_loc18_++;
|
||||
}
|
||||
if(!_loc14_)
|
||||
{
|
||||
_loc12_.push(new MyShopItem(_loc11_,0,0,_storeInvId));
|
||||
}
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
ShopManager.addShopItemToMyList(_loc6_);
|
||||
if(_loc12_ && _loc12_.length > 0)
|
||||
{
|
||||
requestStoreUpdateItems(_storeInvId,_loc17_,null,_loc12_,null,onAutoFixItems,{
|
||||
"callbackData":_loc9_,
|
||||
"newShopData":_loc6_
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new MyShopData(_storeInvId,"",_loc13_);
|
||||
}
|
||||
if(_loc9_.callback != null)
|
||||
{
|
||||
_loc9_.callback(_loc6_,_loc9_.passback);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onAutoFixItems(param1:int, param2:Object) : void
|
||||
{
|
||||
if(param2.callbackData != null)
|
||||
{
|
||||
param2.callbackData.callback(param2.newShopData,param2.callbackData.passback);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDenStoreBuy(param1:Object) : void
|
||||
{
|
||||
var _loc17_:String = null;
|
||||
var _loc9_:Boolean = false;
|
||||
var _loc15_:int = 0;
|
||||
var _loc16_:int = 0;
|
||||
var _loc20_:String = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc21_:int = 0;
|
||||
var _loc14_:int = 0;
|
||||
var _loc7_:Iitem = null;
|
||||
var _loc11_:int = 0;
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc3_:UserInfo = null;
|
||||
var _loc10_:AvatarInfo = null;
|
||||
var _loc19_:AccItemCollection = null;
|
||||
var _loc13_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc18_:int = 0;
|
||||
if(!StartupPopups.HAS_LOADED_STARTUP_POPUPS)
|
||||
{
|
||||
if(_dsbResponsesToProcess == null)
|
||||
{
|
||||
_dsbResponsesToProcess = [];
|
||||
}
|
||||
_dsbResponsesToProcess.push(param1);
|
||||
return;
|
||||
}
|
||||
var _loc12_:int = 2;
|
||||
var _loc22_:int = int(param1[_loc12_++]);
|
||||
if(_loc22_ == 1)
|
||||
{
|
||||
_loc17_ = param1[_loc12_++];
|
||||
_loc9_ = _loc17_ != gMainFrame.userInfo.myUserName;
|
||||
_loc15_ = int(param1[_loc12_++]);
|
||||
if(_loc9_)
|
||||
{
|
||||
_loc16_ = int(param1[_loc12_++]);
|
||||
_loc20_ = param1[_loc12_++];
|
||||
}
|
||||
_loc2_ = int(param1[_loc12_++]);
|
||||
_loc6_ = int(param1[_loc12_++]);
|
||||
_loc4_ = int(param1[_loc12_++]);
|
||||
_loc21_ = int(param1[_loc12_++]);
|
||||
_loc14_ = int(param1[_loc12_++]);
|
||||
if(_loc4_ == 2)
|
||||
{
|
||||
_loc7_ = new Item();
|
||||
(_loc7_ as Item).init(_loc14_,_loc16_,param1[_loc12_++]);
|
||||
_loc3_ = gMainFrame.userInfo.getUserInfoByUserName(gMainFrame.userInfo.myUserName);
|
||||
_loc10_ = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(gMainFrame.userInfo.myUserName,_loc3_.currPerUserAvId);
|
||||
(_loc7_ as Item).setInUse(_loc10_.avInvId,true);
|
||||
_loc19_ = _loc10_.getFullItems(true);
|
||||
if(_loc9_)
|
||||
{
|
||||
_loc19_.getCoreArray().unshift(_loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = int(_loc19_.length);
|
||||
_loc11_ = 0;
|
||||
while(_loc11_ < _loc13_)
|
||||
{
|
||||
if(_loc19_.getAccItem(_loc11_).invIdx == _loc21_)
|
||||
{
|
||||
_loc19_.getAccItem(_loc11_).setInUse(_loc10_.avInvId,false);
|
||||
_loc19_.getCoreArray().splice(_loc11_,1);
|
||||
DenMannequinInventory.removeItemFromUse(_loc21_);
|
||||
break;
|
||||
}
|
||||
_loc11_++;
|
||||
}
|
||||
}
|
||||
_loc10_.fullItemList = _loc19_;
|
||||
gMainFrame.userInfo.setAvatarInfoByUsernamePerUserAvId(_loc10_.perUserAvId,_loc10_);
|
||||
if(AvatarManager.playerAvatar)
|
||||
{
|
||||
AvatarManager.playerAvatar.itemResponseIntegrate(_loc10_.getItems(true),false);
|
||||
}
|
||||
if(RoomManagerWorld.instance.isMyDen)
|
||||
{
|
||||
RoomManagerWorld.instance.denItemHolder.rebuildMannequins();
|
||||
}
|
||||
}
|
||||
else if(_loc4_ == 0)
|
||||
{
|
||||
_loc7_ = new DenItem();
|
||||
(_loc7_ as DenItem).init(_loc14_,_loc21_,0,param1[_loc12_++],0,null,param1[_loc12_++],param1[_loc12_++],"",param1[_loc12_++],param1[_loc12_++]);
|
||||
DenXtCommManager.requestDenItems(onDenItemsRequestCallback);
|
||||
_loc8_ = true;
|
||||
}
|
||||
else if(_loc4_ == 1)
|
||||
{
|
||||
_loc7_ = new PetItem();
|
||||
(_loc7_ as PetItem).init(param1[_loc12_++],_loc14_,[param1[_loc12_++],param1[_loc12_++],param1[_loc12_++]],param1[_loc12_++],param1[_loc12_++],param1[_loc12_++],_loc16_,param1[_loc12_++]);
|
||||
_loc5_ = int(param1[_loc12_++]);
|
||||
if(_loc9_)
|
||||
{
|
||||
PetManager.insertPetItem(_loc7_ as PetItem,false,_loc5_);
|
||||
PetXtCommManager.sendPetSwitchRequest(_loc7_.invIdx,onPetSwitch);
|
||||
_loc8_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PetManager.removePetInvIdx([_loc21_]);
|
||||
}
|
||||
gMainFrame.userInfo.updatePetsDenShopUse((_loc7_ as PetItem).invIdx,_loc15_,!_loc9_);
|
||||
}
|
||||
if(_loc20_ != null)
|
||||
{
|
||||
ShopManager.updateShopState(_loc15_,_loc20_);
|
||||
}
|
||||
ShopManager.removeShopItemFromMyList(_loc15_,_loc7_,_loc21_);
|
||||
_loc18_ = int(param1[_loc12_++]);
|
||||
UserCurrency.setCurrency(_loc18_,_loc2_);
|
||||
_dsbPassback = {
|
||||
"status":_loc22_,
|
||||
"newCurrencyCount":_loc18_,
|
||||
"itemInvId":_loc21_,
|
||||
"currencyType":_loc2_
|
||||
};
|
||||
if(!_loc8_ && _dsbCallback != null)
|
||||
{
|
||||
_dsbCallback(_loc22_,_loc18_,_loc21_,_loc2_);
|
||||
_dsbCallback = null;
|
||||
}
|
||||
if(!_loc9_)
|
||||
{
|
||||
GuiManager.closeAnyInventoryRelatedWindows();
|
||||
ShopManager.clearShopItems(_loc15_);
|
||||
ShopManager.showItemSoldPopup(_loc7_,_loc6_,_loc2_,ShopManager.ifShopToSellOpenCloseIt(_loc15_) ? _loc15_ : -1);
|
||||
}
|
||||
}
|
||||
else if(_dsbCallback != null)
|
||||
{
|
||||
_dsbCallback(_loc22_,0,0,0);
|
||||
_dsbCallback = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopManager.clearShopItems(_storeInvId);
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(33933));
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDenItemsRequestCallback() : void
|
||||
{
|
||||
if(_dsbCallback != null)
|
||||
{
|
||||
_dsbCallback(_dsbPassback.status,_dsbPassback.newCurrencyCount,_dsbPassback.itemInvId,_dsbPassback.currencyType);
|
||||
_dsbPassback = null;
|
||||
_dsbCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPetSwitch(param1:*) : void
|
||||
{
|
||||
if(_dsbCallback != null)
|
||||
{
|
||||
_dsbCallback(_dsbPassback.status,_dsbPassback.newCurrencyCount,_dsbPassback.itemInvId,_dsbPassback.currencyType);
|
||||
_dsbPassback = null;
|
||||
_dsbCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
package shop
|
||||
{
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarEditorView;
|
||||
import avatar.AvatarUtility;
|
||||
import avatar.AvatarView;
|
||||
import collection.AccItemCollection;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import currency.UserCurrency;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.GuiSoundToggleButton;
|
||||
import gui.LoadingSpiral;
|
||||
import inventory.Iitem;
|
||||
import item.Item;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class ShopWithPreview extends Shop
|
||||
{
|
||||
|
||||
private static const SHOP_WITH_PREVIEW_MEDIA_ID:int = 4753;
|
||||
|
||||
private static const NUM_COLOR_ICONS:int = 8;
|
||||
|
||||
private var _avtEditorView:AvatarEditorView;
|
||||
|
||||
private var _loadingSpiralAvatar:LoadingSpiral;
|
||||
|
||||
private var _accShownItems:AccItemCollection;
|
||||
|
||||
private var _isShowingAnItem:Boolean;
|
||||
|
||||
private var _lastItemAdded:Item;
|
||||
|
||||
private var _currColorIdx:int;
|
||||
|
||||
private var _lastWindowIx:int;
|
||||
|
||||
private var _lastItemOffset:int;
|
||||
|
||||
public function ShopWithPreview()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function init(param1:int, param2:int, param3:Avatar, param4:DisplayLayer, param5:Function = null, param6:int = 0, param7:Function = null, param8:Boolean = false, param9:int = -1) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
SBTracker.push();
|
||||
_shopId = param1;
|
||||
_glDefType = param2;
|
||||
_playerAvatar = param3;
|
||||
_popupLayer = param4;
|
||||
_appendString = "";
|
||||
_isMember = gMainFrame.userInfo.isMember;
|
||||
_denRoomShopCallback = param7;
|
||||
_isShopOnlyDen = param8;
|
||||
_isInFFM = GuiManager.isInFFM;
|
||||
_useStartupShopIndex = param9;
|
||||
_denItemIdx = param6;
|
||||
_closeCallback = param5;
|
||||
_shopWithPreview = this;
|
||||
_lastItemAdded = null;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(4753,onShopLoaded);
|
||||
}
|
||||
|
||||
public function checkAndRemovePrevItem(param1:Iitem, param2:int, param3:Boolean = false) : void
|
||||
{
|
||||
if(_lastItemAdded && param1 is Item && param1.defId != _lastItemAdded.defId || _lastWindowIx != param2 || _lastItemOffset != _itemOffset || param3)
|
||||
{
|
||||
_shop["iw" + _lastWindowIx].yellowBG.visible = false;
|
||||
(_shop["iconItemWindow_" + (_currColorIdx + 1)] as GuiSoundToggleButton).downToUpState();
|
||||
_currColorIdx = _itemColorIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function handleItemEquip(param1:Iitem, param2:int, param3:Boolean = false) : void
|
||||
{
|
||||
checkAndRemovePrevItem(param1,param2,param3);
|
||||
_lastWindowIx = param2;
|
||||
_lastItemOffset = _itemOffset;
|
||||
_shop["iw" + param2].yellowBG.visible = !_shop["iw" + param2].yellowBG.visible;
|
||||
if(param1 is Item)
|
||||
{
|
||||
if((param1 as Item).getInUse(_playerAvatar.avInvId))
|
||||
{
|
||||
hideItem(Item(param1));
|
||||
_lastItemOffset = 0;
|
||||
_lastWindowIx = 0;
|
||||
_itemIdx = -1;
|
||||
}
|
||||
else if(!(param1 as Item).getInUse(_playerAvatar.avInvId))
|
||||
{
|
||||
showItem(Item(param1));
|
||||
}
|
||||
if(_shop.buyPopup.visible)
|
||||
{
|
||||
if(_itemIdx == -1)
|
||||
{
|
||||
onBuyPopupCloseBtnDown(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
setupBuyPopup();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Error("Trying to equip item that is not an Item");
|
||||
}
|
||||
|
||||
public function purchaseComplete() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
_lastItemAdded.setInUse(_playerAvatar.avInvId,false);
|
||||
_lastItemAdded.setIconColor(_lastItemAdded.layerId,_itemColorsArray[_itemToBuy.defId][0]);
|
||||
_lastItemAdded = null;
|
||||
setBtnsAndName(false,null);
|
||||
if(_avtEditorView)
|
||||
{
|
||||
_shop.charBox.removeChild(_avtEditorView);
|
||||
}
|
||||
_loc2_ = 1;
|
||||
while(_loc2_ <= 8)
|
||||
{
|
||||
(_shop["iconItemWindow_" + _loc2_] as GuiSoundToggleButton).downToUpState();
|
||||
_loc2_++;
|
||||
}
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 6)
|
||||
{
|
||||
_shop["iw" + _loc2_].yellowBG.visible = false;
|
||||
_loc2_++;
|
||||
}
|
||||
_avtEditorView = new AvatarEditorView();
|
||||
_avtEditorView.init(_playerAvatar,null,onAvatarChanged);
|
||||
var _loc1_:Point = AvatarUtility.getAvatarViewPosition(_avtEditorView.avTypeId);
|
||||
_avtEditorView.x = _loc1_.x;
|
||||
_avtEditorView.y = _loc1_.y;
|
||||
if(Utility.isOcean(_playerAvatar.enviroTypeFlag))
|
||||
{
|
||||
if(Utility.isLand(_playerAvatar.enviroTypeFlag))
|
||||
{
|
||||
_shop.charBox.gotoAndStop(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.charBox.gotoAndStop(2);
|
||||
}
|
||||
}
|
||||
_shop.charBox.addChild(_avtEditorView);
|
||||
_avtEditorView.playAnim(13,false,1,onAvatarLoaded);
|
||||
_accShownItems = new AccItemCollection(_avtEditorView.accShownItems.concatCollection(null));
|
||||
}
|
||||
|
||||
public function adjustColor() : void
|
||||
{
|
||||
if(_itemToBuy)
|
||||
{
|
||||
setColorsOnIcons(_itemColorIdx);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkIfThisItemEquipped(param1:int, param2:int) : void
|
||||
{
|
||||
var _loc3_:Iitem = _currShopItemArray.getIitem(param1 + param2);
|
||||
if(_lastItemAdded && _loc3_ is Item && _lastItemAdded.defId == _loc3_.defId)
|
||||
{
|
||||
_shop["iw" + param1].yellowBG.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop["iw" + param1].yellowBG.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function toggleInitialVisibility() : void
|
||||
{
|
||||
super.toggleInitialVisibility();
|
||||
setBtnsAndName(false,null);
|
||||
_loadingSpiralAvatar = new LoadingSpiral(_shop.charBox);
|
||||
_avtEditorView = new AvatarEditorView();
|
||||
_avtEditorView.init(_playerAvatar,null,onAvatarChanged);
|
||||
var _loc1_:Point = AvatarUtility.getAvatarViewPosition(_avtEditorView.avTypeId);
|
||||
_avtEditorView.x = _loc1_.x;
|
||||
_avtEditorView.y = _loc1_.y;
|
||||
if(Utility.isOcean(_playerAvatar.enviroTypeFlag))
|
||||
{
|
||||
if(Utility.isLand(_playerAvatar.enviroTypeFlag))
|
||||
{
|
||||
_shop.charBox.gotoAndStop(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.charBox.gotoAndStop(2);
|
||||
}
|
||||
}
|
||||
_shop.charBox.addChild(_avtEditorView);
|
||||
_avtEditorView.playAnim(13,false,1,onAvatarLoaded);
|
||||
_accShownItems = new AccItemCollection(_avtEditorView.accShownItems.concatCollection(null));
|
||||
}
|
||||
|
||||
override protected function addListeners() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
super.addListeners();
|
||||
_shop.buyBtnGreenPreview.addEventListener("mouseDown",onBuyBtn,false,0,true);
|
||||
_shop.buyBtnRedPreview.addEventListener("mouseDown",onBuyBtn,false,0,true);
|
||||
_shop.zoomBtn.addEventListener("mouseDown",onZoomBtn,false,0,true);
|
||||
_loc1_ = 1;
|
||||
while(_loc1_ <= 8)
|
||||
{
|
||||
_shop["iconItemWindow_" + _loc1_].addEventListener("mouseDown",onIconItemDown,false,0,true);
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function removeListeners() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
super.removeListeners();
|
||||
_shop.buyBtnGreenPreview.removeEventListener("mouseDown",onBuyBtn);
|
||||
_shop.buyBtnRedPreview.removeEventListener("mouseDown",onBuyBtn);
|
||||
_shop.zoomBtn.removeEventListener("mouseDown",onZoomBtn);
|
||||
_loc1_ = 1;
|
||||
while(_loc1_ <= 8)
|
||||
{
|
||||
_shop["iconItemWindow_" + _loc1_].removeEventListener("mouseDown",onIconItemDown);
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function onAvatarLoaded(param1:LayerAnim, param2:int) : void
|
||||
{
|
||||
if(_loadingSpiralAvatar)
|
||||
{
|
||||
_loadingSpiralAvatar.destroy();
|
||||
_loadingSpiralAvatar = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onAvatarChanged(param1:AvatarView) : void
|
||||
{
|
||||
_avtEditorView.playAnim(13,false,1,onAvatarLoaded);
|
||||
}
|
||||
|
||||
private function showItem(param1:Item, param2:Function = null) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
if(_lastItemAdded != null)
|
||||
{
|
||||
hideItem(_lastItemAdded);
|
||||
}
|
||||
_lastItemAdded = param1;
|
||||
_avtEditorView.showAccessory(param1,param2);
|
||||
_itemToBuy = _currShopItemArray.getIitem(_itemIdx).clone();
|
||||
setBtnsAndName(true,param1);
|
||||
setupColorIcons();
|
||||
}
|
||||
}
|
||||
|
||||
private function hideItem(param1:Item) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
_avtEditorView.hideAccessory(param1);
|
||||
_lastItemAdded = null;
|
||||
_itemToBuy = null;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _accShownItems.length)
|
||||
{
|
||||
_avtEditorView.showAccessory(_accShownItems.getAccItem(_loc2_));
|
||||
_loc2_++;
|
||||
}
|
||||
setBtnsAndName(false,null);
|
||||
}
|
||||
}
|
||||
|
||||
private function setBtnsAndName(param1:Boolean, param2:Item) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
if(UserCurrency.hasEnoughCurrency(param2.currencyType,param2.value))
|
||||
{
|
||||
_shop.buyBtnGreenPreview.visible = true;
|
||||
_shop.buyBtnRedPreview.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyBtnGreenPreview.visible = false;
|
||||
_shop.buyBtnRedPreview.visible = true;
|
||||
}
|
||||
LocalizationManager.updateToFit(_shop.itemNameTxt,param2.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop.buyBtnGreenPreview.visible = false;
|
||||
_shop.buyBtnRedPreview.visible = false;
|
||||
}
|
||||
_shop.itemNameBa.visible = param1;
|
||||
_shop.itemNameTxt.visible = param1;
|
||||
_shop.previewBtnBa.visible = param1;
|
||||
_shop.zoomBtn.activateGrayState(!param1);
|
||||
_loc3_ = 1;
|
||||
while(_loc3_ <= 8)
|
||||
{
|
||||
_shop["iconItemWindow_" + _loc3_].visible = param1;
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function setupColorIcons() : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc2_:Item = null;
|
||||
var _loc1_:int = 0;
|
||||
if(_itemToBuy is Item && _itemColorsArray)
|
||||
{
|
||||
_loc3_ = _itemColorsArray[_itemToBuy.defId];
|
||||
_loc2_ = _itemToBuy.clone() as Item;
|
||||
_loc2_.specialScale = 0.5;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 8)
|
||||
{
|
||||
if(_loc3_[_loc1_] != null)
|
||||
{
|
||||
_loc2_.color = _loc3_[_loc1_];
|
||||
(_shop["iconItemWindow_" + (_loc1_ + 1)] as GuiSoundToggleButton).insertIitem(_loc2_,"itemLayer");
|
||||
_shop["iconItemWindow_" + (_loc1_ + 1)].mouseEnabled = true;
|
||||
_shop["iconItemWindow_" + (_loc1_ + 1)].mouseChildren = true;
|
||||
_shop["iconItemWindow_" + (_loc1_ + 1)].visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shop["iconItemWindow_" + (_loc1_ + 1)].mouseEnabled = false;
|
||||
_shop["iconItemWindow_" + (_loc1_ + 1)].mouseChildren = false;
|
||||
_shop["iconItemWindow_" + (_loc1_ + 1)].visible = false;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
(_itemToBuy as Item).color = _loc3_[_itemColorIdx];
|
||||
(_shop["iconItemWindow_" + (_itemColorIdx + 1)] as GuiSoundToggleButton).upToDownState();
|
||||
}
|
||||
}
|
||||
|
||||
private function onZoomBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(!param1.currentTarget.isGray)
|
||||
{
|
||||
setupBuyPopup();
|
||||
}
|
||||
}
|
||||
|
||||
private function onBuyBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
buyBtnDownHandler(null);
|
||||
}
|
||||
|
||||
private function onIconItemDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
setColorsOnIcons(param1.currentTarget.name.split("_")[1] - 1);
|
||||
}
|
||||
|
||||
private function setColorsOnIcons(param1:int) : void
|
||||
{
|
||||
(_shop["iconItemWindow_" + (_currColorIdx + 1)] as GuiSoundToggleButton).downToUpState();
|
||||
_currColorIdx = _itemColorIdx = param1;
|
||||
(_shop["iconItemWindow_" + (_currColorIdx + 1)] as GuiSoundToggleButton).upToDownState();
|
||||
(_itemToBuy as Item).color = _itemColorsArray[_itemToBuy.defId][_itemColorIdx];
|
||||
_avtEditorView.replaceAccItem(_itemToBuy as Item,_itemToBuy as Item);
|
||||
if(_shop.buyPopup.visible)
|
||||
{
|
||||
_itemToBuy.largeIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user