diff --git a/config.js b/config.js index e0594fc..708a513 100644 --- a/config.js +++ b/config.js @@ -387,6 +387,11 @@ module.exports = { chatWindowMs: 3000, // ... in this long roomActionsPerWindow: 6, // emotes, actions and the like one player may send a room ... roomActionWindowMs: 3000, // ... in this long (the rest reach nobody) + // eco den items (lib/eco.js): credits an hour for each point of eco power + // placed in a den, and what an account is given the first time it looks + // (an Eco Solar Panel's price) + ecoCreditsPerPointHour: 1, + ecoStartCredits: 1500, maxBytesPerTenSeconds: 512 * 1024, // per game socket; saving a full den is about 40 KB // custom colours (lib/colours.js). every one ever made is sent to every // player at every login and is never taken out again, so there is an end diff --git a/lib/defpacks.js b/lib/defpacks.js index 1f7af3d..27f9cdc 100644 --- a/lib/defpacks.js +++ b/lib/defpacks.js @@ -44,8 +44,9 @@ const DEF_WORLD_ITEMS = 1064; const DEF_NPC = 1025; const DEF_NAMEBAR_BADGE = 1049; const DEF_EMOTICON = 1036; +const DEF_NEWSPAPER = 1065; // the Jamaa Journal's pages (newspaper.NewspaperManager) -const OFFERED_SPECIAL_TYPES = ["0", "4"]; // den items: plain, mannequin +const OFFERED_SPECIAL_TYPES = ["0", "4", "6", "7"]; // den items: plain, mannequin, eco producer and consumer (lib/eco.js) const DEN_ITEM_MASTERPIECE = 2725; const packs = new Map(); @@ -487,6 +488,7 @@ let npcDefs = new Map(); // the characters of the adventures, see lib/disguises. // An avatar attachment is named by its emoticon definition id on the wire, // while AvatarWorldView needs the media id stored by that definition. let emoticonMediaIds = new Map(); +let journalPages = []; // the Jamaa Journal's pages: {id, page (media id), start (seconds)} // A pack whose feature can be done without: missing (offline and never // cached) just leaves that feature empty. @@ -516,8 +518,9 @@ const init = async () => { petIds = [...petDefs.keys()]; denItemDefs = new Map((await load(DEF_DEN_ITEM)).map(def => [Number(def.id), def])); // special types carry extra state (a den portal's destination, a shop's - // stock, ...). of those only mannequins (4) are modelled, in lib/dens.js, - // so plain den items and mannequins are what is offered. + // stock, ...). of those mannequins (4) are modelled, in lib/dens.js, and + // the eco items (6, 7) in lib/eco.js, so those and plain den items are + // what is offered. // the Masterpiece item is a painting's frame, made in the Art Studio and // nowhere else (lib/masterpieces.js). denItemIds = [...denItemDefs].filter(([id, def]) => OFFERED_SPECIAL_TYPES.includes(def.specialType) && id !== DEN_ITEM_MASTERPIECE).map(([id]) => id); @@ -554,6 +557,8 @@ const init = async () => { petToyDefs = await loadOptional(DEF_PET_TOY); npcDefs = new Map((await loadOptional(DEF_NPC)).map(def => [Number(def.id), def])); emoticonMediaIds = new Map((await loadOptional(DEF_EMOTICON)).map(def => [Number(def.id), Number(def.mediaRef)])); + journalPages = (await loadOptional(DEF_NEWSPAPER)).map(def => ({id: Number(def.id), page: Number(def.pageMediaRefId), + start: Number(def.availabilityStartTime) || 0})).filter(page => page.page > 0); partyDefs = new Map((await loadOptional(DEF_PARTY)).map(def => { const room = roomPathsById.get(Number(def.roomDefId)); return [Number(def.id), { @@ -665,6 +670,9 @@ module.exports = { badgeIds: () => badgeIds, npcDef: id => npcDefs.get(Number(id)), emoticonMediaId: id => emoticonMediaIds.get(Number(id)) || 0, + // the media ids of the newest Jamaa Journal pages out by `now` (seconds), newest first + newestJournalPages: (count, now = Date.now() / 1000) => journalPages.filter(page => page.start <= now) + .sort((one, other) => other.start - one.start || other.id - one.id).slice(0, count).map(page => page.page), oddDenItemIds: () => oddDenItemIds, // den items that exist to be given by id and are in no shop. unsoldDenItemIds: () => extraMusic.ids, diff --git a/lib/dens.js b/lib/dens.js index 5eeccb5..5b0a29a 100644 --- a/lib/dens.js +++ b/lib/dens.js @@ -8,6 +8,7 @@ const defpacks = require("./defpacks.js"); const wearRules = require("./wearrules.js"); const epicDens = require("./epicdens.js"); const masterpieces = require("./masterpieces.js"); +const eco = require("./eco.js"); const {CURRENCIES, MAX_DEN_ITEMS, hasRoom, activeAvatar, resolvePurchase, isUint} = require("./player.js"); // den items: owning, placing and recycling furniture (client side: @@ -119,9 +120,14 @@ const petsInDen = account => account.pets.filter(pet => pet.inDen && pet.inDen.d // it is not placed there. the three after "approved" are a masterpiece's // (lib/masterpieces.js); one not approved yet the client keeps out of dens, // trades and the recycler. +// an item whose def is gone (a custom item deleted) is left out of both: the +// client skipped it without reading all its fields, and read every item after +// it wrong, placed ones as not placed and the den's floor and wallpaper lost. +const known = item => Boolean(defpacks.denItemDef(item.def)); + const sendDenItems = session => { const {account} = session; - const {denItems} = account; + const denItems = account.denItems.filter(known); const pets = petsInDen(account); session.sendXt("di", -1, account.activeDen, denItems.length, pets.length, ...denItems.flatMap(item => { @@ -134,13 +140,13 @@ const sendDenItems = session => { // DenXtCommManager.denStateResponse: [itemCount, petCount, forceReload, // (invIdx, defId, placed, x, y, version, flipped, userNameLink, imageId, -// creatorDbId, creatorUuid, [mannequin], ?)..., (invIdx, lBits, uBits, eBits, +// creatorDbId, creatorUuid, [mannequin], eco state)..., (invIdx, lBits, uBits, eBits, // category, x, y, flipped, createdTs, personality, toy, food, name)...]. // forceReload makes the client finish a pending room change, so it is set // when the den has just been entered. const sendDenState = (session, room, forceReload = true) => { const owner = room.denOwner; - const placed = itemsInDen(owner).filter(item => masterpieces.itemApproved(item)); + const placed = itemsInDen(owner).filter(item => known(item) && masterpieces.itemApproved(item)); const pets = petsInDen(owner); session.sendXt("ds", room.id, placed.length, pets.length, forceReload ? 1 : 0, ...placed.flatMap(item => { @@ -149,7 +155,7 @@ const sendDenState = (session, room, forceReload = true) => { // object as category 1 made wall/floor items enter the wrong display // layer when a den was reloaded or another player visited. return [item.inv, item.def, spot.cat || 1, spot.x, spot.y, item.version, spot.flip, "", ...masterpieces.itemFields(item), - ...mannequinShownFields(owner, item), 0]; + ...mannequinShownFields(owner, item), eco.consumerState(owner, item)]; }), ...pets.flatMap(pet => [pet.inv, pet.lBits, pet.uBits, pet.eBits, PET_CATEGORY, pet.inDen.x, pet.inDen.y, pet.inDen.flip, pet.createdAt, pet.personality || 0, pet.toy || 0, pet.food || 0, pet.name])); @@ -380,6 +386,10 @@ const handlers = ({others, findOnline}) => { session.sendXt("dss", -1); return; } + // the eco credits earned at the den's rate until now (lib/eco.js) + if (account.eco) { + eco.accrue(account); + } const applied = []; const byInv = new Map(account.denItems.map(candidate => [candidate.inv, candidate])); const mannequins = account.denItems.filter(candidate => candidate.mannequin); diff --git a/lib/eco.js b/lib/eco.js new file mode 100644 index 0000000..c107b75 --- /dev/null +++ b/lib/eco.js @@ -0,0 +1,227 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const config = require("../config.js"); +const defpacks = require("./defpacks.js"); + +// the eco den items: producers (special type 6, the Eco Solar Panel and +// Eco Wind Turbine) and consumers (7, the eco lamps and fan), sold for eco +// credits in the Eco Shop (list 778). client side: gui.EcoScorePopup (a +// producer clicked), gui.EcoPointsPopup (a consumer clicked), +// DenItemHolder.updateConsumers. the official server's rules were never +// recorded; these are this server's: +// +// - a den's generation is the eco power of the producers placed in its +// owner's den in use; consumers switched on take theirs from it, in +// inventory order, and one that no longer fits is "offline" (state 2) +// until there is power for it again. its switch stays on. +// - generation turns into credits, config.ecoCreditsPerPointHour a point +// an hour, waiting to be collected ("Get Your Credits") up to the +// meter's full 240. an account's first look (an eco window, or the +// Eco Shop) gets it config.ecoStartCredits, enough for its first producer. +// - the eco score (generation less use) earns the three eco plaques, one +// at a time, through user var 465 (a bit each). + +const SPECIAL_PRODUCER = "6"; +const SPECIAL_CONSUMER = "7"; +const WIND_TURBINE = 4541; +const SOLAR_PANEL = 4540; +const CURRENCY_ECO = 11; +const ECO_SHOP_LIST = 778; +const MAX_WAITING = 240; // EcoScorePopup.updateCreditProgressMeter: the meter is full at 240 +const USER_VAR_REWARDS = 465; +const REWARDS = [ + {bit: 0, score: 5, def: 4611}, // Wood Eco Plaque + {bit: 1, score: 15, def: 4610}, // Silver Eco Plaque + {bit: 2, score: 30, def: 4609}, // Gold Eco Plaque +]; +const HOUR_MS = 3600000; + +const OFF = 0; +const ON = 1; +const OFFLINE = 2; + +const special = item => { + const def = defpacks.denItemDef(item.def); + return def ? String(def.specialType) : ""; +}; +const power = item => Number((defpacks.denItemDef(item.def) || {}).ecoPower) || 0; +const placedInUse = account => account.denItems.filter(item => item.spots && item.spots[account.activeDen]); + +// the den in use as the eco windows see it: {generation, consumption, +// turbines, panels, consumers: [item], states: Map(inv -> 0 off, 1 on, 2 offline)} +const stateOf = account => { + const placed = placedInUse(account); + const producers = placed.filter(item => special(item) === SPECIAL_PRODUCER); + const consumers = placed.filter(item => special(item) === SPECIAL_CONSUMER).sort((one, other) => one.inv - other.inv); + const generation = producers.reduce((sum, item) => sum + power(item), 0); + let consumption = 0; + const states = new Map(); + for (const item of consumers) { + if (!item.ecoOn) { + states.set(item.inv, OFF); + } + else if (consumption + power(item) <= generation) { + consumption += power(item); + states.set(item.inv, ON); + } + else { + states.set(item.inv, OFFLINE); + } + } + return { + generation, + consumption, + turbines: producers.filter(item => item.def === WIND_TURBINE).length, + panels: producers.filter(item => item.def === SOLAR_PANEL).length, + consumers, + states, + }; +}; + +// a den item's eco field in the den's state (DenStateItem's last): 0 for +// all but consumers +const consumerState = (account, item) => (special(item) === SPECIAL_CONSUMER ? stateOf(account).states.get(item.inv) || OFF : OFF); + +const perHour = generation => generation * (Number(config.ecoCreditsPerPointHour) || 0); + +// brings the waiting credits up to now, at the rate the den has now. the +// caller saves. +const accrue = account => { + const now = Date.now(); + if (!account.eco) { + account.eco = {waiting: 0, at: now}; + const start = Math.max(0, Math.floor(Number(config.ecoStartCredits) || 0)); + account.currency.ecoCredits = (account.currency.ecoCredits || 0) + start; + return; + } + const rate = perHour(stateOf(account).generation); + const hours = Math.max(0, now - account.eco.at) / HOUR_MS; + account.eco.waiting = Math.min(MAX_WAITING, (Number(account.eco.waiting) || 0) + rate * hours); + account.eco.at = now; +}; + +// seconds until one more whole credit waits, 0 when none will +const secondsToNext = account => { + const rate = perHour(stateOf(account).generation); + if (rate <= 0 || account.eco.waiting >= MAX_WAITING) { + return 0; + } + const short = 1 - (account.eco.waiting % 1); + return Math.max(1, Math.ceil(short / rate * 3600)); +}; + +const nextReward = account => { + const bits = Number(account.userVars[USER_VAR_REWARDS]) || 0; + return REWARDS.find(reward => !(bits & (1 << reward.bit))) || null; +}; + +module.exports = ({others, ecards}) => { + const sendCredits = session => session.sendXt("cu", -1, CURRENCY_ECO, session.account.currency.ecoCredits || 0, 0); + + // the consumers' states to the owner and, when they are in it, everyone + // else in the den: DenXtCommManager.denEcoConsumerResponse [consumption, + // generation, count, (invIdx, state)...]. + const sendConsumers = session => { + const {account} = session; + const state = stateOf(account); + const fields = [state.consumption, state.generation, state.consumers.length, + ...state.consumers.flatMap(item => [item.inv, state.states.get(item.inv)])]; + session.sendXt("dEc", -1, ...fields); + if (session.room && session.room.denOwner === account) { + for (const other of others(session)) { + other.sendXt("dEc", -1, ...fields); + } + } + }; + + const handlers = { + // requestDenEcoCreditRefresh -> EcoStateResponse: [turbines, panels, + // consumers, generation, consumption, score required, next reward bit, + // credits waiting, seconds to the next]. + dEf(session) { + const {account} = session; + const firstLook = !account.eco; + accrue(account); + accounts.save(account); + if (firstLook) { + sendCredits(session); + } + const state = stateOf(account); + const reward = nextReward(account); + session.sendXt("dEf", -1, state.turbines, state.panels, state.consumers.length, state.generation, state.consumption, + reward ? reward.score : REWARDS[REWARDS.length - 1].score, reward ? reward.bit : -1, + Math.floor(account.eco.waiting), secondsToNext(account)); + }, + + // requestDenEcoCreditRedeem: the waiting credits collected -> [success, + // seconds to the next]. + dEr(session) { + const {account} = session; + accrue(account); + const credits = Math.floor(account.eco.waiting); + if (credits < 1) { + accounts.save(account); + session.sendXt("dEr", -1, 0, secondsToNext(account)); + return; + } + account.eco.waiting -= credits; + account.currency.ecoCredits = (account.currency.ecoCredits || 0) + credits; + achievements.currencyChanged(account, "ecoCredits", credits); + accounts.save(account); + sendCredits(session); + session.sendXt("dEr", -1, 1, secondsToNext(account)); + }, + + // requestDenEcoConsumer: [invIdx, "1" on | "0" off] + dEc(session, roomId, [invIdx, on]) { + const {account} = session; + const item = account.denItems.find(candidate => candidate.inv === Number(invIdx)); + if (item && special(item) === SPECIAL_CONSUMER) { + accrue(account); + item.ecoOn = on === "1"; + accounts.save(account); + } + sendConsumers(session); + }, + }; + + // user var 465, set by the eco score window's gift: the value is the bit + // of the reward asked for. given when it is the next one and the score is + // there; the plaque comes as a gift from HQ. true when the var was this. + const userVar = (session, id, bit) => { + if (Number(id) !== USER_VAR_REWARDS) { + return false; + } + const {account} = session; + const reward = nextReward(account); + const state = stateOf(account); + if (reward && reward.bit === Number(bit) && state.generation - state.consumption >= reward.score + && !ecards.sendFromHq(account, "Eco Reward", {kind: "den", id: reward.def})) { + account.userVars[USER_VAR_REWARDS] = (Number(account.userVars[USER_VAR_REWARDS]) || 0) | (1 << reward.bit); + accounts.save(account); + } + if (account.userVars[USER_VAR_REWARDS] === undefined) { + account.userVars[USER_VAR_REWARDS] = 0; + } + achievements.sendVar(session, USER_VAR_REWARDS); + return true; + }; + + // the Eco Shop opened: an account that never had eco credits is given + // its first, to buy its first producer with. + const shopOpened = session => { + if (!session.account.eco) { + accrue(session.account); + accounts.save(session.account); + sendCredits(session); + } + }; + + return {handlers, userVar, shopOpened, SHOP_LIST: ECO_SHOP_LIST}; +}; + +module.exports.accrue = accrue; +module.exports.consumerState = consumerState; +module.exports.SPECIAL_TYPES = [SPECIAL_PRODUCER, SPECIAL_CONSUMER]; diff --git a/lib/http.js b/lib/http.js index 1fea8eb..135df79 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1145,7 +1145,15 @@ const handle = async (req, res) => { return session ? limits.key(session.address) : null; }; const picture = masterpieces.mayView(painting[1], from.key, playingFrom) || from.local ? masterpieces.image(painting[1]) : null; - send(res, picture ? 200 : 404, picture || "Not found", picture ? MIME[".jpg"] : "text/plain"); + if (picture) { + send(res, 200, picture, MIME[".jpg"]); + return; + } + // one that cannot be shown (waiting to be looked at, seen from an + // address not its maker's game's, or its file gone) is the Burrow logo: + // given nothing, the game waited for it for good, behind its spinner. + res.setHeader("Cache-Control", "no-store"); + send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "logo-square.png")), MIME[".png"]); return; } diff --git a/lib/items.js b/lib/items.js index f506acd..ded43f1 100644 --- a/lib/items.js +++ b/lib/items.js @@ -20,6 +20,7 @@ const MAX_RECYCLED_AT_ONCE = 500; const MAX_USED_AT_ONCE = 200; // pieces put on or taken off in one message const RECYCLE_FRACTION = 0.3; // matches recyclePercentage sent at login const CURRENCY_GEMS = 0; // ItemXtCommManager.currencyUpdateResponse's currency type +const PHOTO_GEMS = 50; // what the photo booth says a picture costs (string 14789) module.exports = ({others, sendItemList}) => { // ItemXtCommManager.itemBuyResponse: [status, shopId, newAmount, currencyType] @@ -160,6 +161,25 @@ module.exports = ({others, sendItemList}) => { session.sendXt("cd", -1, 1); }, + // the photo booth's picture (gui.PhotoBooth), PHOTO_GEMS gems. "apc" + // asks first: [gems after, or -1 for too few]; "apb", once the player + // keeps the picture, pays: [gem total]. neither was answered, and the + // booth waited behind its spinner for good. + apc(session) { + const gems = session.account.currency.gems || 0; + session.sendXt("apc", -1, gems >= PHOTO_GEMS ? gems - PHOTO_GEMS : -1); + }, + + apb(session) { + const {account} = session; + if ((account.currency.gems || 0) >= PHOTO_GEMS) { + account.currency.gems -= PHOTO_GEMS; + achievements.currencyChanged(account, "gems", -PHOTO_GEMS); + accounts.save(account); + } + session.sendXt("apb", -1, account.currency.gems || 0); + }, + // ItemXtCommManager.requestItemRecycle: [invIdx, ...]. the reply // (itemRecycleResponse) is [count, newGemTotal, ...recycledInvIdx], and // the recycling window then waits, behind its spinner, for the item diff --git a/lib/walls.js b/lib/walls.js index 4f11f14..8ee4c68 100644 --- a/lib/walls.js +++ b/lib/walls.js @@ -77,10 +77,11 @@ const whole = value => (Number.isInteger(Number(value)) ? Number(value) : 0); // the photo booth picture ("pb", PlayerWallGui): one level deeper than the // rest, {avatar: {id, color1.., eyes, pattern}, bgid, pet: {ts, lbits, ..} | // null, items: [{id, color}, ..]}. it was turned away as too deep, and the -// owner's whole change with it: the photo never stayed. +// owner's whole change with it: the photo never stayed. an animal wearing +// nothing has no items list at all (null), which was turned away too. const MAX_PHOTO_ITEMS = 30; const photoParam = value => value === null || (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length <= 6 - && Object.entries(value).every(([key, part]) => (key === "items" ? Array.isArray(part) && part.length <= MAX_PHOTO_ITEMS && part.every(flat) + && Object.entries(value).every(([key, part]) => (key === "items" ? part === null || (Array.isArray(part) && part.length <= MAX_PHOTO_ITEMS && part.every(flat)) : key === "avatar" || key === "pet" ? part === null || flat(part) : scalar(part)))); module.exports = ({blocks, findOnline}) => { diff --git a/lib/world.js b/lib/world.js index ba64c31..660302d 100644 --- a/lib/world.js +++ b/lib/world.js @@ -28,6 +28,7 @@ const buddyModule = require("./buddies.js"); const dens = require("./dens.js"); const disguises = require("./disguises.js"); const ecardModule = require("./ecards.js"); +const ecoModule = require("./eco.js"); const epicDens = require("./epicdens.js"); const itemHandlers = require("./items.js"); const minigameModule = require("./minigames.js"); @@ -51,6 +52,8 @@ const {CURRENCIES, DIAMOND_TYPES, activeAvatar, avatarById, activePet, equippedB const GENERIC_LIST_AVATARS = 64; const GENERIC_LIST_NEWSPAPER = 627; +const GENERIC_LIST_WHATS_NEW = 369; +const WHATS_NEW_PAGES = 6; // the worlds' names (ServerSelector.getShardName): localization ids, the // game's own river names, world N being the Nth. const GENERIC_LIST_WORLD_NAMES = 16; @@ -143,6 +146,8 @@ const SHOP_LIST_TYPES = [DEF_ITEM, DEF_DEN_ITEM, DEF_DEN_ROOM, DEF_COMBINED_LIST // a shop's title when its room gives it none (a shop in a land's main room, // or one opened from elsewhere): what it sells (strings in lib/defpacks.js). // with no title the shop window's banner was blank. +// shops opened from a window rather than a room, by their list: the Eco Shop. +const SHOP_LIST_TITLES = new Map([[778, 35727]]); const SHOP_KIND_TITLES = new Map([[DEF_ITEM, 9000010], [DEF_DEN_ITEM, 9000011], [DEF_DEN_ROOM, 9000012], [DEF_COMBINED_LIST, 9000013], [DEF_CURRENCY_EXCHANGE, 9000014], [DEF_DIAMOND, 9000015]]); // diamond lists the client reads at login to learn which animals and pets @@ -854,6 +859,9 @@ const handlers = { } let entries = []; let count; + if (Number(listId) === eco.SHOP_LIST) { + eco.shopOpened(session); + } if (Number(listId) === GENERIC_LIST_AVATARS) { entries = defpacks.avatarTypes(); } @@ -955,6 +963,13 @@ const handlers = { count = defpacks.petIds().length; entries = defpacks.petIds().flatMap(id => [id, 1]); } + // Jammer Central's "What's New" pictures (gui.BulletinBoard, list 369): + // the newest pages of the Jamaa Journal. empty, the window waited on + // its spinner. + if (Number(listId) === GENERIC_LIST_WHATS_NEW && (count === undefined ? entries.length : count) === 0) { + entries = defpacks.newestJournalPages(WHATS_NEW_PAGES).flatMap(id => [id, 0]); + count = entries.length / 2; + } // what the official server answered, where this one has nothing of its // own (lib/official-lists.json, from recordings of the official game: // the Journey Book's facts and pictures among them) @@ -967,7 +982,8 @@ const handlers = { } // for shops the first unused field is the title's string id; left empty // it keeps the shop window's own title (Shop.gotItemListCallback). - const title = SHOP_LIST_TYPES.includes(type) ? (session.room && roomInfo.shopTitle(session.room.base, listId)) || SHOP_KIND_TITLES.get(type) : 0; + const title = SHOP_LIST_TYPES.includes(type) + ? (session.room && roomInfo.shopTitle(session.room.base, listId)) || SHOP_LIST_TITLES.get(Number(listId)) || SHOP_KIND_TITLES.get(type) : 0; session.sendXt("gl", -1, listId, type, title, 0, 0, 0, count === undefined ? entries.length : count, ...entries); }, @@ -989,6 +1005,10 @@ const handlers = { if (vars[id] === undefined && Object.keys(vars).length >= MAX_USER_VARS) { return; } + // the eco plaques (lib/eco.js) are given, not set + if (eco.userVar(session, id, value)) { + return; + } if (Number(id) === USER_VAR_HIDE_BLOCKED) { setHideBlocked(session, Number(value) === 1); } @@ -1497,6 +1517,7 @@ const pets = petModule(context); const parties = partyModule(context); const ecards = ecardModule(context); const walls = wallModule(context); +const eco = ecoModule({others, ecards}); const commands = commandModule(context); const minigames = minigameModule(context); const adventures = adventureModule(context); @@ -1506,7 +1527,7 @@ const trades = tradeHandlers(context); achievements.setFinder(findOnline); Object.assign(handlers, avatarHandlers(context), itemHandlers(context), pets.handlers, dens.handlers({...context, others}), buddies.handlers, moderation.handlers, trades.handlers, achievements.handlers, adopt.handlers, worldItems.handlers, - parties.handlers, ecards.handlers, walls.handlers, minigames.handlers, adventures.handlers, stubHandlers, + parties.handlers, ecards.handlers, eco.handlers, walls.handlers, minigames.handlers, adventures.handlers, stubHandlers, playerItems.handlers({itemsTaken: (...args) => itemsTaken(...args)})); // a den's owner, wherever they are, is told how many are in it: the HUD's diff --git a/swf-src/AJClient.as b/swf-src/AJClient.as index 8c25908..2f6858a 100644 --- a/swf-src/AJClient.as +++ b/swf-src/AJClient.as @@ -539,7 +539,14 @@ package } else { - _toolsInstance.showItemFinder(true); + // the item giver is the web one now (the account page's + // /account/items, signed in as there), opened in the browser: + // the one in the game is retired. it shared its colour box + // with the Item Maker, whose colours turned up in it. + if(ExternalInterface.available) + { + ExternalInterface.call("ajOpenPage",gMainFrame.clientInfo.websiteURL + "account/items"); + } } } catch(e:Error) @@ -3513,7 +3520,6 @@ package private var _emojiCaret:int = -1; - private var _emojiTimer:Timer; // the characters of code points in hex ("1f468-200d-1f469") public static function charsOfHex(param1:String) : String @@ -3555,7 +3561,8 @@ package // a line about to be sent: each ":name:" of an emoji above becomes it, // but not the game's own emote codes (":happy:", ":joy:"), which the - // bubble shows as the game's. + // bubble shows as the game's, nor one after a "\" ("\:fire:"), which + // the bubble shows as typed (ChatBalloon.inlineEmotes). public static function emojiShortcodes(param1:String) : String { if(param1.indexOf(":") == -1) @@ -3563,13 +3570,13 @@ package return param1; } emojiTable(); - return param1.replace(/:([a-z0-9_]{1,30}):/g,function(param1:String, param2:String, ... rest):String + return param1.replace(/(\\?):([a-z0-9_]{1,30}):/g,function(param1:String, param2:String, param3:String, ... rest):String { - if(EmoticonUtility.doesStringMatchAnEmote(param1) || _emojiByName[param2] == null) + if(param2 != "" || EmoticonUtility.doesStringMatchAnEmote(":" + param3 + ":") || _emojiByName[param3] == null) { return param1; } - return _emojiByName[param2]; + return _emojiByName[param3]; }); } @@ -4115,9 +4122,9 @@ package private function startEmojiButton() : void { - _emojiTimer = new Timer(500); - _emojiTimer.addEventListener("timer",placeEmojiButton); - _emojiTimer.start(); + // every frame: on a timer it went a moment after the HUD did, when + // a window opened over it + gMainFrame.stage.addEventListener("enterFrame",placeEmojiButton,false,0,true); gMainFrame.stage.addEventListener("mouseDown",onEmojiStageDown,false,0,true); } diff --git a/swf-src/BuddyCard.as b/swf-src/BuddyCard.as index c1944cb..109405e 100644 --- a/swf-src/BuddyCard.as +++ b/swf-src/BuddyCard.as @@ -133,6 +133,11 @@ package buddy private var _joinLabel:Sprite; + // the animal's box as the card's art has it, measured before an animal + // is put in it: measured with one in, a tall animal (or the one still + // there from the card's last opening) put the label up on the name + private var _charBoxRect:Rectangle; + private var _badgeRow:Sprite; private var _discordIcon:Sprite; @@ -829,6 +834,7 @@ package buddy _bioMediaHelper = new MediaHelper(); _bioMediaHelper.init(BIO_TAB_MEDIA_ID,onBioTabLoaded); charBox = _buddyCardMC.charBox; + _charBoxRect = charBox.getBounds(_buddyCardMC); userNameTxt = _buddyCardMC.userName_txt; avatarNameTxt = _buddyCardMC.avatarNameTxt; shamanTag = _buddyCardMC.shamanTag; @@ -993,7 +999,7 @@ package buddy } _joinLabel = AJClient.makePill(_loc3_,9067051,6044183,false,11); _joinLabel.mouseEnabled = false; - _loc2_ = charBox.getBounds(_buddyCardMC); + _loc2_ = _charBoxRect != null ? _charBoxRect : charBox.getBounds(_buddyCardMC); _joinLabel.x = int(_loc2_.right - _joinLabel.width - 8); _joinLabel.y = int(_loc2_.top + 8); _buddyCardMC.addChild(_joinLabel); diff --git a/swf-src/ChatBalloon.as b/swf-src/ChatBalloon.as index cae9a95..175a25e 100644 --- a/swf-src/ChatBalloon.as +++ b/swf-src/ChatBalloon.as @@ -73,8 +73,9 @@ package gui private var _emoteBGOffsetFunc:Function; // emotes drawn inside a line of chat, small, where they were typed: an - // emote's code standing as a word of its own ("hi :) there", ":fever:"), - // or anywhere after a "\" ("yay\:)"). and emoji (typed with Windows' + // emote's code standing as a word of its own ("hi :) there", ":fever:"). + // a "\" before one keeps it as typed ("\:)" shows ":)"), as it does a + // ":name:" of an emoji (AJClient.emojiShortcodes). and emoji (typed with Windows' // emoji panel, say), which the game's font has none of: each is drawn // as a picture of it, from the server (/emoji/.png, // Twemoji's). each is {at, clip}: where its gap starts in the text shown. @@ -82,6 +83,11 @@ package gui // artwork to this measured slot with a one-pixel gutter on each side, // so consecutive emoji neither overlap nor touch surrounding text. private static const INLINE_GAP:String = " "; + + // after each gap: a gap ending the text was trailing spaces, which a + // centred line leaves out, so the text sat off centre and its last + // emoji past it. this is no space, and has no width. + private static const INLINE_END:String = "\u200B"; private static const LONGEST_EMOTE_CODE:int = 16; @@ -579,7 +585,7 @@ package gui "at":_loc2_.length, "clip":emojiClip(param1.substr(_loc3_,_loc8_)) }); - _loc2_ += INLINE_GAP; + _loc2_ += INLINE_GAP + INLINE_END; _loc3_ += _loc8_; continue; } @@ -594,14 +600,26 @@ package gui "at":_loc2_.length, "clip":emojiClipNamed(_loc9_[1]) }); - _loc2_ += INLINE_GAP; + _loc2_ += INLINE_GAP + INLINE_END; _loc3_ += String(_loc9_[0]).length; continue; } } if(param1.charAt(_loc3_) == "\\") { + // "\" and an emote's code, or ":name:": that, as typed _loc5_ = emoteCodeAt(param1,_loc3_ + 1,false); + var _loc10_:Array = /^:[a-z0-9_]{1,30}:/.exec(param1.substr(_loc3_ + 1,32)); + if(_loc5_ == null && _loc10_ != null) + { + _loc5_ = _loc10_[0]; + } + if(_loc5_ != null) + { + _loc2_ += _loc5_; + _loc3_ += 1 + _loc5_.length; + continue; + } } else if(_loc3_ == 0 || param1.charAt(_loc3_ - 1) == " ") { @@ -616,8 +634,8 @@ package gui "at":_loc2_.length, "clip":_loc7_ }); - _loc2_ += INLINE_GAP; - _loc3_ += (param1.charAt(_loc3_) == "\\" ? 1 : 0) + _loc5_.length; + _loc2_ += INLINE_GAP + INLINE_END; + _loc3_ += _loc5_.length; } else { diff --git a/swf-src/ChatHistory.as b/swf-src/ChatHistory.as index 5c214a2..a37c354 100644 --- a/swf-src/ChatHistory.as +++ b/swf-src/ChatHistory.as @@ -15,6 +15,7 @@ package gui import flash.text.StyleSheet; import flash.text.TextField; import flash.text.TextFormat; + import flash.utils.getTimer; import flash.ui.Mouse; import gui.itemWindows.ItemWindowTextNode; import localization.LocalizationManager; @@ -50,6 +51,13 @@ package gui private var _chatRepeatArray:Array; + // a repeat list line (emoji as names) -> {line: as it was said, with + // its emoji, at: getTimer() then}. the names were sent instead, and the + // server says nothing to a line said again within REPEAT_MS (lib/chatspam.js) + private var _chatRepeatSaid:Object = {}; + + private static const REPEAT_MS:int = 20000; + private var _hasSetupChatRepeatBtn:Boolean; private var _isOverChatText:Boolean; @@ -288,6 +296,7 @@ package gui public function addMessage(param1:String, param2:String, param3:String, param4:String) : void { + var said:String = param4; // emoji as their names here: this list has no pictures (AJClient.emojiAsNames) param4 = AJClient.emojiAsNames(param4); var _loc5_:Boolean = false; @@ -298,6 +307,10 @@ package gui addLine("" + plain(Utility.isSettingOn(MySettings.SETTINGS_USERNAME_BADGE) ? param3 : param1) + ": " + "",param4,"\n"); if(_chatRepeatWindow && AvatarManager.playerAvatar && param2.toLowerCase() == AvatarManager.playerAvatar.userName.toLowerCase()) { + _chatRepeatSaid[param4] = { + "line":said, + "at":getTimer() + }; _loc7_ = 0; while(_loc7_ < _chatRepeatArray.length) { @@ -991,9 +1004,10 @@ package gui private function onRepeatChatSelected(param1:MouseEvent) : void { - if(!AvatarManager.playerAvatarWorldView.isSameMessage(param1.currentTarget.text)) + var _loc2_:Object = _chatRepeatSaid[param1.currentTarget.text]; + if(!AvatarManager.playerAvatarWorldView.isSameMessage(param1.currentTarget.text) && !(_loc2_ && getTimer() - _loc2_.at < REPEAT_MS)) { - sendMsgCallback(null,param1.currentTarget.text); + sendMsgCallback(null,_loc2_ ? _loc2_.line : param1.currentTarget.text); SBTracker.trackPageview("/game/play/popup/repeatChat/#repeat",-1,1); } else diff --git a/swf-src/DenEditor.as b/swf-src/DenEditor.as index 7ff6688..1866a98 100644 --- a/swf-src/DenEditor.as +++ b/swf-src/DenEditor.as @@ -235,14 +235,8 @@ package gui public function updateSwitchRecycleBtnVisibility() : void { - if(!_denEditor.switchDenBtn.visible) - { - if(gMainFrame.userInfo.numLogins >= 2 || gMainFrame.userInfo.userVarCache.getUserVarValueById(3) > 1) - { - _denEditor.switchDenBtn.visible = true; - _denEditor.recycleBtn.visible = true; - } - } + _denEditor.switchDenBtn.visible = true; + _denEditor.recycleBtn.visible = true; } public function clearItemWindows() : void @@ -433,11 +427,11 @@ package gui { _denEditor.petBtnDn.visible = false; } - if(gMainFrame.userInfo.numLogins < 2 && gMainFrame.userInfo.userVarCache.getUserVarValueById(3) <= 1) - { - _denEditor.switchDenBtn.visible = false; - _denEditor.recycleBtn.visible = false; - } + // the switch den and recycle buttons are not kept from a new + // player any more: the game hid them before a second login (or a + // den tutorial var), and players found them gone + _denEditor.switchDenBtn.visible = true; + _denEditor.recycleBtn.visible = true; _denEditor.denAudioPopup.visible = false; _denEditor.itemBlock.glowCont.glow.visible = false; _denEditor.lockBtn.denLock.initToolTip(_guiLayer,LocalizationManager.translateIdOnly(14639),900 * 0.5,105); @@ -690,7 +684,8 @@ package gui { _denEditor.itemBlock.itemBlock.addChild(_itemWindow); } - if(_numItems <= 10 + 1) + // ten to a page: with eleven the last could not be scrolled to + if(_numItems <= 10) { _denEditor.lArrowBtn.activateGrayState(true); _denEditor.rArrowBtn.activateGrayState(true); diff --git a/swf-src/DenXtCommManager.as b/swf-src/DenXtCommManager.as index a24e8d5..8f3357d 100644 --- a/swf-src/DenXtCommManager.as +++ b/swf-src/DenXtCommManager.as @@ -391,12 +391,19 @@ package den } _loc26_ = int(param1[_loc23_++]); _loc18_.init(_loc28_,_loc31_,_loc32_,_loc24_,0,null,_loc14_,_loc33_,"",_loc17_,_loc30_,_loc4_,_loc26_); - _loc6_.setDenItem(_loc21_,_loc18_); + // pushed, not set at its place: one skipped left a hole, and + // the inventory's windows scrolled over an empty one + _loc6_.pushDenItem(_loc18_); if(_loc18_.minigameDefId > 0 && !MinigameManager.minigameInfoCache.getMinigameInfo(_loc18_.minigameDefId)) { _loc20_.push(_loc18_.minigameDefId); } } + else + { + // its last field (the den shop's), read past as above + _loc23_++; + } _loc21_++; } _loc6_.getCoreArray().sortOn("invIdx",0x10 | 2); @@ -846,6 +853,11 @@ package den _loc19_ = getDenItemDef(_loc27_); if(!_loc19_) { + // the rest of its fields, read past: left there, every item + // after it was read from the wrong place (lib/dens.js + // sendDenState: placed, x, y, version, flip, link, image, + // creator id, creator uuid, eco state) + _loc20_ += 10; _loc9_.setDenStateItem(_loc21_,new DenStateItem(0,_loc38_,0,0,0,0,0,0,0,0,0,0,0,0,0,"",0,"",0,0,"","",-1,"",false,null,0,0,null,null,2)); } else diff --git a/swf-src/MySettings.as b/swf-src/MySettings.as index 9f8f800..66b838c 100644 --- a/swf-src/MySettings.as +++ b/swf-src/MySettings.as @@ -160,9 +160,10 @@ package gui } var _loc4_:Array = [{ "type":TOGGLE_TYPE_JOIN, + // the web item giver (AJClient.openTool), in the browser "frame":"itemFinder", "iconFrame":"redeemCode", - "labelLabel":"Item Giver", + "labelLabel":"Item Giver (web)", "btnLabel":"Open" },{ // a player's own items (AJClient's Item Maker) diff --git a/swf-src/PlayerWallGui.as b/swf-src/PlayerWallGui.as new file mode 100644 index 0000000..f1ed9fd --- /dev/null +++ b/swf-src/PlayerWallGui.as @@ -0,0 +1,3845 @@ +package playerWall +{ + import avatar.Avatar; + import avatar.AvatarDef; + import avatar.AvatarEditorView; + import avatar.AvatarInfo; + import avatar.AvatarManager; + import avatar.AvatarView; + import avatar.UserCommXtCommManager; + import buddy.BuddyManager; + import collection.AccItemCollection; + import collection.DenItemCollection; + import collection.IntItemCollection; + import com.sbi.analytics.SBTracker; + import com.sbi.client.KeepAlive; + import com.sbi.graphics.LayerAnim; + import com.sbi.popup.SBOkCancelPopup; + import com.sbi.popup.SBOkPopup; + import den.DenItem; + import den.DenXtCommManager; + import facilitator.FacilitatorXtCommManager; + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.KeyboardEvent; + import flash.events.MouseEvent; + import flash.geom.Matrix; + import flash.geom.Point; + import flash.text.TextField; + import flash.text.TextFormat; + import flash.utils.ByteArray; + import flash.utils.Dictionary; + import flash.utils.Timer; + import flash.utils.setTimeout; + import game.MinigameManager; + import game.MinigameXtCommManager; + import gui.CursorManager; + import gui.DarkenManager; + import gui.EmoticonManager; + import gui.EmoticonUtility; + import gui.FeedbackManager; + import gui.GuiManager; + import gui.GuiRadioButtonGroup; + import gui.InputPopup; + import gui.LoadingSpiral; + import gui.PredictiveTextManager; + import gui.ReportAPlayer; + import gui.SBScrollbar; + import gui.SafeChatManager; + import gui.WindowAndScrollbarGenerator; + import gui.WindowGenerator; + import gui.itemWindows.ItemWindowMasterpiece; + import gui.itemWindows.ItemWindowNotification; + import gui.itemWindows.ItemWindowPattern; + import gui.itemWindows.ItemWindowPlayerWallDecor; + import gui.itemWindows.ItemWindowPost; + import gui.itemWindows.ItemWindowSticker; + import item.EquippedAvatars; + import item.Item; + import loader.MediaHelper; + import localization.LocalizationManager; + import masterpiece.MasterpieceDisplayItem; + import pet.GuiPet; + import pet.PetManager; + import resourceArray.ResourceArrayXtCommManager; + + public class PlayerWallGui + { + + private static var _scrollYPosition:Number = 0; + + private const PLAYER_WALL_MEDIA_ID:int = 1499; + + private const AVATAR_ICON_LIST_ID:int = 109; + + private const DECOR_ICONS_GENERIC_LIST_ID:int = 313; + + private const DECOR_ITEMS_GENERIC_LIST_ID:int = 314; + + private const STICKER_ICON_LIST_ID:int = 646; + + private const WINDOW_TYPE_WALLPAPER:int = 0; + + private const WINDOW_TYPE_STICKER:int = 1; + + private const WINDOW_TYPE_MASTERPIECE:int = 2; + + private var _guiLayer:DisplayLayer; + + private var _inbox:Vector.; + + private var _closeCallback:Function; + + private var _mediaHelper:MediaHelper; + + private var _playerWall:MovieClip; + + private var _owner:String; + + private var _ownerModeratedUsername:String; + + private var _ownerUUID:String; + + private var _status:String; + + private var _currPatternId:int; + + private var _myCurrColorId:int; + + private var _postWindows:WindowAndScrollbarGenerator; + + private var _predictiveTextManager:PredictiveTextManager; + + private var _predictiveStatusManager:PredictiveTextManager; + + private var _emoteMgr:EmoticonManager; + + private var _reportMsgId:String; + + private var _reportAPlayer:ReportAPlayer; + + private var _isMyWall:Boolean; + + private var _privacyId:int; + + private var _msgCode:String; + + private var _avatarIconWindowLoadingSpiral:LoadingSpiral; + + private var _numAvatarIconsLoaded:int; + + private var _avatarIcons:Array; + + private var _wallSettingsRadioBtns:GuiRadioButtonGroup; + + private var _wallDecorIconIds:Array; + + private var _wallDecorItemIds:Array; + + private var _currDecorIndex:int; + + private var _patternIconIds:Array; + + private var _patternWindows:WindowGenerator; + + private var _patternScrollBar:SBScrollbar; + + private var _messagePatternWindow:ItemWindowPattern; + + private var _wallParameters:Object; + + private var _hasLoadedDecor:Boolean; + + private var _messagePatternLoaded:Boolean; + + private var _updateTimer:Timer; + + private var _canWrite:Boolean; + + private var _currDragMasterpiece:MasterpieceDisplayItem; + + private var _dragStartPoint:Point; + + private var _masterpieceFrameIds:Array; + + private var _masterpieceLaunchObj:Object; + + private var _selectedMasterpieces:Array; + + private var _masterpieceDiCollection:DenItemCollection; + + private var _masterpieceItemsBeingLoaded:Array; + + private var _stickerItemsBeingLoaded:Array; + + private var _wallCustomizeWindows:WindowAndScrollbarGenerator; + + private var _stickerIconIds:Array; + + private var _currDragSticker:MovieClip; + + private var _selectedStickers:Array; + + private var _currWallDecor:MovieClip; + + private var _photoAvatar:Avatar; + + private var _photoAvatarView:AvatarView; + + private var _photoPet:GuiPet; + + private var _photoBackground:MovieClip; + + private var _inputPopup:InputPopup; + + private var _currReplyPost:ItemWindowPost; + + private var _notifications:Vector.; + + private var _notificationWindows:WindowAndScrollbarGenerator; + + private var _isWallActive:Boolean; + + private var _jumpToMessageId:String; + + private var _hasLoadedSafeChat:Boolean; + + private var _customizationLoadingSpiral:LoadingSpiral; + + private var _hasShownDegradationPopup:Boolean; + + public function PlayerWallGui() + { + super(); + } + + public function init(param1:Vector., param2:Vector., param3:String, param4:String, param5:String, param6:String, param7:int, param8:int, param9:String, param10:Function) : void + { + if(MinigameManager.inMinigame()) + { + return; + } + _guiLayer = GuiManager.guiLayer; + _inbox = param1; + _owner = param3; + _ownerModeratedUsername = param4; + _ownerUUID = param5; + _status = param6; + _currPatternId = param7; + _myCurrColorId = param8; + _closeCallback = param10; + _jumpToMessageId = param9; + _isMyWall = param3 == gMainFrame.userInfo.myUserName; + _notifications = param2; + _isWallActive = true; + _updateTimer = new Timer(45000); + _canWrite = _isMyWall ? true : PlayerWallManager.tokenMap[_owner.toLowerCase()].write == "1"; + SBTracker.trackPageview("game/play/playerWall/#" + (_isMyWall ? "openMyWall" : "openStrangersWall")); + _mediaHelper = new MediaHelper(); + _mediaHelper.init(1499,onMediaLoaded); + UserCommXtCommManager.sendPermEmote(4329); + } + + public function destroy() : void + { + KeepAlive.stopKATimer(_playerWall); + if(_postWindows) + { + _postWindows.destroy(); + _postWindows = null; + } + setupAvatarAndPetPhoto(false,true); + setupSafeChat(true); + setupSettingsPopup(true); + setupMessageEntry(true); + setupEmotePopup(true); + setupColors(true); + setupPatterns(true); + setupWallCustomizePopup(true); + setupNotificationsPopup(true); + setupLikes(true); + _mediaHelper = null; + _inbox = null; + _closeCallback = null; + removeEventListeners(); + _updateTimer.stop(); + _updateTimer = null; + for each(var _loc1_:MasterpieceDisplayItem in _masterpieceItemsBeingLoaded) + { + if(_loc1_) + { + _loc1_.destroy(); + _loc1_ = null; + } + } + _masterpieceItemsBeingLoaded = null; + for each(var _loc2_:StickerItem in _stickerItemsBeingLoaded) + { + if(_loc2_) + { + _loc2_.destroy(); + _loc2_ = null; + } + } + _stickerItemsBeingLoaded = null; + if(_customizationLoadingSpiral != null) + { + _customizationLoadingSpiral.destroy(); + _customizationLoadingSpiral = null; + } + DarkenManager.unDarken(_playerWall); + if(_playerWall && _playerWall.parent == _guiLayer) + { + _guiLayer.removeChild(_playerWall); + } + _playerWall = null; + if(_isMyWall || !PlayerWallManager.isMyWallOpen()) + { + UserCommXtCommManager.sendPermEmote(-1); + } + } + + public function reloadMessages(param1:Vector., param2:Vector., param3:int, param4:String = "") : Vector. + { + var _loc10_:PostMessage = null; + var _loc8_:int = 0; + var _loc6_:int = 0; + var _loc9_:Object = PlayerWallManager.myBlockedMessages; + _loc8_ = 0; + while(_loc8_ < param1.length) + { + _loc10_ = param1[_loc8_]; + if(_loc10_.msgId != param4 && _loc10_.msgId == _loc9_[_loc10_.msgId]) + { + param1.splice(_loc8_,1); + _loc8_--; + } + _loc8_++; + } + if(param2 != null) + { + _loc8_ = 0; + while(_loc8_ < param2.length) + { + _loc10_ = param2[_loc8_]; + if(_loc10_.msgId != param4 && _loc10_.msgId == _loc9_[_loc10_.msgId]) + { + param2.splice(_loc8_,1); + _loc8_--; + } + _loc8_++; + } + } + var _loc7_:* = -1; + _loc8_ = 0; + while(_loc8_ < param1.length) + { + if(param1[_loc8_].msgId == param4) + { + _loc7_ = _loc8_; + break; + } + _loc8_++; + } + var _loc5_:* = -1; + if(param2 != null) + { + _loc8_ = 0; + while(_loc8_ < param2.length) + { + if(param2[_loc8_].msgId == param4) + { + _loc5_ = _loc8_; + break; + } + _loc8_++; + } + } + if(param1.length > 0) + { + param1 = reorderListForReplies(param1); + } + if(param1) + { + switch(param3) + { + case 0: + findDifferencesAndUpdatePosts(param1); + if(param2 != null && param2.length > 0) + { + findDifferencesAndUpdateNotifications(param2); + } + break; + case 1: + case 3: + deleteItemByIndexAndChildrenIfNecessary(_loc7_,param1,_postWindows); + if(param2 != null && _notificationWindows) + { + deleteItemByIndexAndChildrenIfNecessary(_loc5_,param2,_postWindows); + } + break; + case 2: + _postWindows.updateItem(_loc7_,param1[_loc7_]); + if(param2 != null && _notificationWindows) + { + _notificationWindows.updateItem(_loc5_,param2[_loc5_]); + } + break; + case 4: + _inbox = param1; + createWallPosts(); + } + _playerWall.noPostCont.visible = param1.length == 0; + _playerWall.cleanUpBtn.activateGrayState(param1.length == 0); + if(param2) + { + _loc8_ = 0; + while(_loc8_ < param2.length) + { + if(!param2[_loc8_].isRead) + { + _loc6_++; + } + _loc8_++; + } + _playerWall.notificationBtn.numIcon.countTxt.text = String(_loc6_); + _playerWall.notificationBtn.numIcon.visible = _loc6_ > 0; + } + } + return param1; + } + + public function reloadMasterpieceItems() : void + { + var _loc2_:MovieClip = _playerWall.frame_0; + var _loc1_:int = 0; + while(_loc2_) + { + while(_loc2_.itemLayer.numChildren > 1) + { + _loc2_.itemLayer.removeChildAt(_loc2_.itemLayer.numChildren - 1); + } + if(_loc2_.loadingSpiral) + { + (_loc2_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc2_.loadingSpiral; + } + _loc1_++; + _loc2_ = _playerWall["frame_" + _loc1_]; + } + setupMasterpieces(); + } + + public function set currWallParameters(param1:Object) : void + { + _wallParameters = param1; + var _loc2_:ByteArray = new ByteArray(); + _loc2_.writeObject(param1); + _loc2_.position = 0; + _wallParameters = _loc2_.readObject(); + if(_wallParameters == null) + { + _wallParameters = {"bg":"19"}; + } + else if(_wallParameters.bg && _wallParameters.bg == -1) + { + _wallParameters.bg = 19; + } + if(_wallParameters.mp != null) + { + _selectedMasterpieces = _wallParameters.mp; + } + if(_wallParameters.stk != null) + { + _selectedStickers = _wallParameters.stk; + } + if(_wallParameters.visits != null) + { + if(_playerWall) + { + LocalizationManager.translateIdAndInsert(_playerWall.viewCount,30488,Utility.convertNumberToString(_wallParameters.visits)); + } + } + _currDecorIndex = int(_wallParameters.bg); + } + + public function set currNotifications(param1:Vector.) : void + { + var _loc2_:int = 0; + var _loc3_:int = 0; + _notifications = param1; + if(_notifications) + { + _loc3_ = 0; + while(_loc3_ < _notifications.length) + { + if(!_notifications[_loc3_].isRead) + { + _loc2_++; + } + _loc3_++; + } + } + _playerWall.notificationBtn.numIcon.countTxt.text = String(_loc2_); + _playerWall.notificationBtn.numIcon.visible = _loc2_ > 0; + } + + public function get myCurrMessageColorId() : int + { + return _myCurrColorId; + } + + public function get currMessagePattern() : int + { + return _currPatternId; + } + + public function get owner() : String + { + return _owner; + } + + public function get status() : String + { + return _playerWall.statusTxt.text; + } + + public function get isCurrentlyActive() : Boolean + { + return _isWallActive; + } + + public function set isCurrentlyActive(param1:Boolean) : void + { + _isWallActive = param1; + } + + private function reorderListForReplies(param1:Vector.) : Vector. + { + var _loc2_:PostMessage = null; + var _loc5_:int = 0; + var _loc3_:* = undefined; + var _loc7_:int = 0; + var _loc4_:Dictionary = new Dictionary(); + _loc5_ = 0; + while(_loc5_ < param1.length) + { + _loc2_ = param1[_loc5_]; + if(_loc2_.parentMessageId != null && _loc2_.parentMessageId.length > 0) + { + if(_loc4_[_loc2_.parentMessageId] == null) + { + _loc4_[_loc2_.parentMessageId] = new Vector.(); + } + _loc4_[_loc2_.parentMessageId].push(_loc2_); + } + _loc5_++; + } + var _loc6_:Vector. = new Vector.(); + for each(var _loc8_:PostMessage in param1) + { + if(_loc8_.parentMessageId == null || _loc8_.parentMessageId.length == 0) + { + _loc6_.push(_loc8_); + } + if(_loc4_[_loc8_.msgId] != null) + { + _loc3_ = _loc4_[_loc8_.msgId]; + _loc7_ = 0; + while(_loc7_ < _loc3_.length) + { + _loc6_.push(_loc3_[_loc7_]); + _loc7_++; + } + } + } + return _loc6_; + } + + private function onMediaLoaded(param1:MovieClip) : void + { + if(param1) + { + _playerWall = MovieClip(param1.getChildAt(0)); + KeepAlive.startKATimer(_playerWall); + _playerWall.x = 900 * 0.5; + _playerWall.y = 550 * 0.5; + _playerWall.patternPopup.visible = false; + _playerWall.colorPopup.visible = false; + _playerWall.emotePopup.visible = false; + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + _playerWall.menuFrame.titleTxt.text = _owner; + _playerWall.frame.titleTxt.text = _owner; + _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha = 0.5; + _playerWall.settingsPopup.visible = false; + _playerWall.predictiveText.visible = false; + _playerWall.messageTxtCont.txtColorCont.messageTxt.selectable = false; + _playerWall.messageTxtCont.txtColorCont.charCounter.visible = false; + _playerWall.messageTxtCont.txtColorCont.messageTxt.text = ""; + _playerWall.wallCustomize.visible = false; + _playerWall.wallNotificationCont.visible = false; + _playerWall.contentLoader.visible = true; + _playerWall.noPostCont.visible = false; + _playerWall.replyToTip.visible = false; + _playerWall.replyBtn.visible = false; + _playerWall.cancelBtn.visible = false; + _playerWall.notificationBtn.numIcon.visible = false; + _playerWall.wallNotificationCont.numIcon.visible = false; + _playerWall.chatTree.visible = false; + LocalizationManager.translateIdAndInsert(_playerWall.viewCount,30488,Utility.convertNumberToString(0)); + if(_isMyWall) + { + _playerWall.settingsBtn.visible = true; + _playerWall.menuBtn.visible = true; + _playerWall.notificationBtn.visible = true; + _playerWall.menuFrame.visible = true; + _playerWall.frame.visible = false; + _privacyId = gMainFrame.userInfo.playerWallSettings; + _playerWall.cleanUpBtn.activateGrayState(true); + } + else + { + _playerWall.settingsBtn.visible = false; + _playerWall.menuBtn.visible = false; + _playerWall.cleanUpBtn.visible = false; + _playerWall.menuFrame.visible = false; + _playerWall.frame.visible = true; + _playerWall.notificationBtn.visible = false; + } + if(PlayerWallManager.isFirstTime || !_isMyWall) + { + PlayerWallXtCommManager.sendGetFromPlayerWall(_isMyWall ? gMainFrame.userInfo.myUserName : _owner,onFirstTimeGet); + } + else + { + setupWallCustomizePopup(); + setupWallDecorItems(); + setupMasterpieces(); + setupStickers(); + setupMessageEntry(); + setupSafeChat(); + setupPatterns(); + setupColors(); + setupEmotePopup(); + setupNotificationsPopup(); + setupLikes(); + setupViews(); + setupSettingsPopup(false,_privacyId); + onSettingsChoose(null); + updatePatternPopupColors(); + createWallPosts(); + PlayerWallManager.startMyWallTimer(); + } + addEventListeners(); + } + } + + private function setupSafeChat(param1:Boolean = false) : void + { + if(_canWrite) + { + if(param1) + { + SafeChatManager.destroy(_playerWall.chatTree); + } + else + { + _playerWall.speedChatBtn.downToUpState(); + } + } + else + { + _playerWall.speedChatBtn.activateGrayState(true); + _playerWall.speedChatBtn.mouseChildren = false; + _playerWall.speedChatBtn.mouseEnabled = false; + _playerWall.chatTree.visible = false; + } + } + + private function setupSettingsPopup(param1:Boolean = false, param2:int = 0) : void + { + if(param1) + { + _playerWall.settingsPopup.removeEventListener("mouseDown",onPopup); + _playerWall.settingsPopup.bx.removeEventListener("mouseDown",onSettingsClose); + if(_wallSettingsRadioBtns) + { + _wallSettingsRadioBtns.currRadioButton.removeEventListener("mouseDown",onSettingsChoose); + _wallSettingsRadioBtns.destroy(); + _wallSettingsRadioBtns = null; + } + } + else + { + _playerWall.settingsPopup.addEventListener("mouseDown",onPopup,false,0,true); + _playerWall.settingsPopup.bx.addEventListener("mouseDown",onSettingsClose,false,0,true); + _wallSettingsRadioBtns = new GuiRadioButtonGroup(_playerWall.settingsPopup.options); + _wallSettingsRadioBtns.currRadioButton.addEventListener("mouseDown",onSettingsChoose,false,0,true); + _wallSettingsRadioBtns.selected = param2; + } + } + + private function setupWallCustomizePopup(param1:Boolean = false) : void + { + if(param1) + { + _playerWall.wallCustomize.removeEventListener("mouseDown",onPopup); + _playerWall.wallCustomize.bx.removeEventListener("mouseDown",onWallMenuClose); + _playerWall.wallCustomize.createMasterpieceBtn.removeEventListener("mouseDown",onCreateAMasterpieceBtn); + _playerWall.wallCustomize.wallpaperBtnDown.removeEventListener("mouseDown",decorStickersAndMasterpieceHandler); + _playerWall.wallCustomize.stickerBtnDown.removeEventListener("mouseDown",decorStickersAndMasterpieceHandler); + _playerWall.wallCustomize.masterpieceBtnDown.removeEventListener("mouseDown",decorStickersAndMasterpieceHandler); + if(_wallCustomizeWindows) + { + _wallCustomizeWindows.destroy(); + _wallCustomizeWindows = null; + } + } + else + { + _playerWall.wallCustomize.addEventListener("mouseDown",onPopup,false,0,true); + _playerWall.wallCustomize.bx.addEventListener("mouseDown",onWallMenuClose,false,0,true); + _playerWall.wallCustomize.createMasterpieceBtn.addEventListener("mouseDown",onCreateAMasterpieceBtn,false,0,true); + _playerWall.wallCustomize.wallpaperBtnDown.addEventListener("mouseDown",decorStickersAndMasterpieceHandler,false,0,true); + _playerWall.wallCustomize.stickerBtnDown.addEventListener("mouseDown",decorStickersAndMasterpieceHandler,false,0,true); + _playerWall.wallCustomize.masterpieceBtnDown.addEventListener("mouseDown",decorStickersAndMasterpieceHandler,false,0,true); + if(_isMyWall) + { + currWallParameters = PlayerWallManager.myWallParameters; + } + } + } + + private function setupCustomizationWindows(param1:int) : void + { + while(_playerWall.wallCustomize.itemWindow.numChildren > 2) + { + _playerWall.wallCustomize.itemWindow.removeChildAt(_playerWall.wallCustomize.itemWindow.numChildren - 1); + } + if(_wallCustomizeWindows) + { + _wallCustomizeWindows.destroy(); + _wallCustomizeWindows = null; + } + if(!_customizationLoadingSpiral) + { + _customizationLoadingSpiral = new LoadingSpiral(_playerWall.wallCustomize.itemWindow,_playerWall.wallCustomize.itemWindow.width * 0.5,_playerWall.wallCustomize.itemWindow.height * 0.5); + } + else + { + _customizationLoadingSpiral.visible = true; + } + if(param1 == 0) + { + if(_wallDecorIconIds == null) + { + GenericListXtCommManager.requestGenericList(313,onDecorIconsLoaded); + } + else + { + _wallCustomizeWindows = new WindowAndScrollbarGenerator(); + _wallCustomizeWindows.init(_playerWall.wallCustomize.itemWindow.width,_playerWall.wallCustomize.itemWindow.height,5,0,3,_wallDecorIconIds.length / 3,0,10,5,5,5,ItemWindowPlayerWallDecor,_wallDecorIconIds,"",_wallDecorIconIds.length,{ + "mouseDown":onDecorMouseDown, + "mouseOver":null, + "mouseOut":null + },null,wallCustomizationLoaded); + } + } + else if(param1 == 1) + { + if(_stickerIconIds == null) + { + GenericListXtCommManager.requestGenericList(646,onStickerIconsLoaded); + } + else + { + _wallCustomizeWindows = new WindowAndScrollbarGenerator(); + _wallCustomizeWindows.init(_playerWall.wallCustomize.itemWindow.width,_playerWall.wallCustomize.itemWindow.height,5,0,2,_stickerIconIds.length / 2,0,2,2,5,2,ItemWindowSticker,_stickerIconIds,"",_stickerIconIds.length,{ + "mouseDown":onStickerMouseDown, + "mouseOver":null, + "mouseOut":null + },_selectedStickers,wallCustomizationLoaded,false,false); + } + } + else if(param1 == 2) + { + _wallCustomizeWindows = new WindowAndScrollbarGenerator(); + _wallCustomizeWindows.init(_playerWall.wallCustomize.itemWindow.width,_playerWall.wallCustomize.itemWindow.height,5,0,2,2,_masterpieceDiCollection.length,2,2,5,2,ItemWindowMasterpiece,_masterpieceDiCollection.getCoreArray(),"icon",0,{ + "mouseDown":onMasterpieceMouseDown, + "mouseOver":null, + "mouseOut":null + },_selectedMasterpieces,wallCustomizationLoaded,true,false,false); + if(_masterpieceDiCollection.length == 0) + { + _playerWall.wallCustomize.noFramePopup.visible = true; + } + else + { + _playerWall.wallCustomize.noFramePopup.visible = false; + } + } + if(_wallCustomizeWindows) + { + _playerWall.wallCustomize.itemWindow.addChild(_wallCustomizeWindows); + } + if(param1 != 2) + { + _playerWall.wallCustomize.noFramePopup.visible = false; + } + _playerWall.wallCustomize.createMasterpieceBtn.visible = param1 == 2; + _playerWall.wallCustomize.wallpaperBtnUp.visible = param1 == 0; + _playerWall.wallCustomize.wallpaperBtnDown.visible = param1 != 0; + _playerWall.wallCustomize.stickerBtnUp.visible = param1 == 1; + _playerWall.wallCustomize.stickerBtnDown.visible = param1 != 1; + _playerWall.wallCustomize.masterpieceBtnUp.visible = param1 == 2; + _playerWall.wallCustomize.masterpieceBtnDown.visible = param1 != 2; + _playerWall.wallCustomize.stickerScrim.visible = param1 == 1; + _playerWall.wallCustomize.masterpieceScrim.visible = param1 == 2; + _playerWall.wallCustomize.wallPaperScrim.visible = param1 == 0; + } + + private function wallCustomizationLoaded() : void + { + _customizationLoadingSpiral.visible = false; + } + + private function setupWallDecorItems() : void + { + if(_wallDecorItemIds == null) + { + GenericListXtCommManager.requestGenericList(314,onDecorItemsLoaded); + } + } + + private function setupMasterpieces() : void + { + var _loc2_:MovieClip = null; + if(_selectedMasterpieces) + { + for each(var _loc1_:Object in _selectedMasterpieces) + { + _loc2_ = _playerWall["frame_" + _loc1_.sid]; + if(_loc2_) + { + while(_loc2_.itemLayer.numChildren > 1) + { + _loc2_.itemLayer.removeChildAt(_loc2_.itemLayer.numChildren - 1); + } + if(_loc2_.loadingSpiral) + { + (_loc2_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc2_.loadingSpiral; + } + _loc2_.loadingSpiral = new LoadingSpiral(_loc2_.itemLayer); + } + } + } + if(!_isMyWall) + { + DenXtCommManager.requestDenMasterpieceItems(_owner,onMasterpieceItemsReceived); + } + else + { + setupMasterpieceCollection(new DenItemCollection(gMainFrame.userInfo.playerUserInfo.denItemsFull.concatCollection(null))); + setupMasterpiecesInFrames(); + } + } + + private function setupStickers() : void + { + var _loc2_:MovieClip = null; + if(_selectedStickers) + { + for each(var _loc1_:Object in _selectedStickers) + { + _loc2_ = _playerWall["sticker_" + _loc1_.pos]; + if(_loc2_) + { + while(_loc2_.itemLayer.numChildren > 1) + { + _loc2_.itemLayer.removeChildAt(_loc2_.itemLayer.numChildren - 1); + } + if(_loc2_.loadingSpiral) + { + (_loc2_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc2_.loadingSpiral; + } + _loc2_.loadingSpiral = new LoadingSpiral(_loc2_.itemLayer); + } + } + } + setupStickersInFrames(); + } + + private function setupMasterpieceCollection(param1:DenItemCollection) : void + { + var _loc2_:int = 0; + _masterpieceDiCollection = new DenItemCollection(); + _loc2_ = 0; + while(_loc2_ < param1.length) + { + if(param1.getDenItem(_loc2_).isCustom) + { + if(!_isMyWall) + { + for each(var _loc3_:Object in _selectedMasterpieces) + { + if(_loc3_.iid == param1.getDenItem(_loc2_).invIdx) + { + _masterpieceDiCollection.pushDenItem(param1.getDenItem(_loc2_)); + break; + } + } + } + else + { + _masterpieceDiCollection.pushDenItem(param1.getDenItem(_loc2_)); + } + } + _loc2_++; + } + } + + private function onMasterpieceItemsReceived(param1:DenItemCollection) : void + { + setupMasterpieceCollection(param1); + setupMasterpiecesInFrames(); + } + + private function setupStickersInFrames() : void + { + var _loc1_:Boolean = false; + var _loc5_:MovieClip = null; + var _loc2_:StickerItem = null; + var _loc3_:IntItemCollection = new IntItemCollection(); + _stickerItemsBeingLoaded = []; + for each(var _loc4_:Object in _selectedStickers) + { + _loc1_ = false; + _loc5_ = _playerWall["sticker_" + _loc4_.pos]; + if(_loc5_) + { + _loc2_ = new StickerItem(_loc4_.id,onStickerSetupInFramesLoaded,_loc5_); + _stickerItemsBeingLoaded[_loc4_.id] = _loc2_; + } + } + } + + private function setupMasterpiecesInFrames() : void + { + var _loc1_:Boolean = false; + var _loc6_:MovieClip = null; + var _loc4_:MasterpieceDisplayItem = null; + var _loc3_:IntItemCollection = new IntItemCollection(); + _masterpieceItemsBeingLoaded = []; + for each(var _loc5_:Object in _selectedMasterpieces) + { + _loc1_ = false; + _loc6_ = _playerWall["frame_" + _loc5_.sid]; + for each(var _loc2_:DenItem in _masterpieceDiCollection.getCoreArray()) + { + if(_loc2_.invIdx == _loc5_.iid) + { + if(_loc6_) + { + _loc4_ = new MasterpieceDisplayItem(); + _loc4_.init(_loc2_,onMasterpieceSetupInFramesLoaded,_loc6_); + _masterpieceItemsBeingLoaded[_loc5_.sid] = _loc4_; + } + _loc1_ = true; + break; + } + } + if(!_loc1_) + { + if(_loc6_ && _loc6_.loadingSpiral) + { + (_loc6_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc6_.loadingSpiral; + } + _loc3_.pushIntItem(_loc5_.iid); + } + } + if(_loc3_.length > 0) + { + PlayerWallXtCommManager.sendRemoveMasterpiece(_loc3_,null); + } + } + + private function onStickerSetupInFramesLoaded(param1:StickerItem, param2:MovieClip) : void + { + if(param2.loadingSpiral) + { + (param2.loadingSpiral as LoadingSpiral).destroy(); + delete param2.loadingSpiral; + } + while(param2.itemLayer.numChildren > 1) + { + param2.itemLayer.removeChildAt(param2.itemLayer.numChildren - 1); + } + var _loc3_:Number = param2.itemLayer.width / Math.max(param1.width,param1.height); + param1.scaleX = param1.scaleY = _loc3_; + param2.itemLayer.addChild(param1); + } + + private function onMasterpieceSetupInFramesLoaded(param1:MasterpieceDisplayItem, param2:MovieClip) : void + { + if(param2.loadingSpiral) + { + (param2.loadingSpiral as LoadingSpiral).destroy(); + delete param2.loadingSpiral; + } + while(param2.itemLayer.numChildren > 1) + { + param2.itemLayer.removeChildAt(param2.itemLayer.numChildren - 1); + } + var _loc3_:Number = param2.itemLayer.width / Math.max(param1.width,param1.height); + param1.scaleX = param1.scaleY = _loc3_; + param2.itemLayer.addChild(param1); + } + + private function setupMessageEntry(param1:Boolean = false) : void + { + if(param1) + { + if(_predictiveTextManager) + { + _predictiveTextManager.destroy(); + } + _playerWall.messageTxtCont.txtColorCont.messageTxt.removeEventListener("keyDown",keyDownListener); + _playerWall.messageTxtCont.txtColorCont.messageTxt.removeEventListener("change",onTextChanged); + _playerWall.messageTxtCont.txtColorCont.messageTxt.removeEventListener("mouseDown",msgTextDownHandler); + _playerWall.messageTxtCont.txtColorCont.messageTxt.removeEventListener("mouseOver",onTextOver); + _playerWall.messageTxtCont.txtColorCont.messageTxt.removeEventListener("mouseOut",onTextOut); + if(_messagePatternWindow) + { + _messagePatternWindow.destroy(); + _messagePatternWindow = null; + } + } + else if(_canWrite) + { + _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars = 70; + _playerWall.messageTxtCont.txtColorCont.charCounter.text = "0/" + _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars; + _playerWall.messageTxtCont.txtColorCont.charCounter.visible = true; + if(gMainFrame.userInfo.sgChatType != 0 && gMainFrame.userInfo.sgChatType != 3) + { + _predictiveTextManager = new PredictiveTextManager(); + _predictiveTextManager.init(_playerWall.messageTxtCont.txtColorCont.messageTxt,2,_playerWall.predictTxtTag,_playerWall.specialCharCont,-262,_playerWall.messageTxtCont,onSendMessage,checkShouldCompleteSuggestion); + } + else + { + _playerWall.predictTxtTag.visible = false; + if(_playerWall.specialCharCont) + { + _playerWall.specialCharCont.visible = false; + } + } + _playerWall.messageTxtCont.txtColorCont.messageTxt.addEventListener("change",onTextChanged,false,0,true); + _playerWall.messageTxtCont.txtColorCont.messageTxt.selectable = true; + _playerWall.messageTxtCont.txtColorCont.messageTxt.text = LocalizationManager.translateIdOnly(23140); + _playerWall.messageTxtCont.txtColorCont.messageTxt.addEventListener("keyDown",keyDownListener,false,0,true); + _playerWall.messageTxtCont.txtColorCont.messageTxt.addEventListener("mouseOver",onTextOver,false,0,true); + _playerWall.messageTxtCont.txtColorCont.messageTxt.addEventListener("mouseOut",onTextOut,false,0,true); + _playerWall.messageTxtCont.txtColorCont.messageTxt.addEventListener("mouseDown",msgTextDownHandler,false,0,true); + _playerWall.messageTxtCont.gotoAndStop(_myCurrColorId); + _messagePatternWindow = new ItemWindowPattern(onMessagePatternLoaded,3983,"",0,null,null,null,null,{ + "type":"post", + "colorIndex":_myCurrColorId, + "patternIndex":_currPatternId + }); + _playerWall.messageEntryHolder.addChild(_messagePatternWindow); + } + else + { + _playerWall.predictTxtTag.visible = _playerWall.specialCharCont.visible = false; + _playerWall.colorBtn.activateGrayState(true); + _playerWall.colorBtn.mouseChildren = false; + _playerWall.colorBtn.mouseEnabled = false; + _playerWall.messageTxtCont.visible = false; + _messagePatternLoaded = true; + if(_hasLoadedDecor) + { + displayLoadedWall(); + } + } + } + + private function setupPatterns(param1:Boolean = false) : void + { + if(_canWrite) + { + if(param1) + { + _patternIconIds = null; + if(_patternWindows) + { + _patternWindows.destroy(); + _patternWindows = null; + } + } + else if(_patternIconIds == null) + { + _mediaHelper = new MediaHelper(); + _mediaHelper.init(3983,onPatternLoaded); + } + else + { + _patternWindows = new WindowGenerator(); + _patternWindows.init(1,_patternIconIds.length,_patternIconIds.length,0,0,0,ItemWindowPattern,_patternIconIds,"",{ + "mouseDown":onSelectPattern, + "mouseOver":null, + "mouseOut":null + },{ + "type":"swatch", + "colorIndex":_myCurrColorId + },onPatternWindowsLoaded,false,false); + _playerWall.patternPopup.itemWindow.addChild(_patternWindows); + } + } + else + { + _playerWall.patternBtn.activateGrayState(true); + _playerWall.patternBtn.mouseChildren = false; + _playerWall.patternBtn.mouseEnabled = false; + } + } + + private function setupColors(param1:Boolean = false) : void + { + var _loc4_:MovieClip = null; + var _loc2_:Boolean = true; + var _loc3_:int = 1; + while(_loc2_) + { + _loc4_ = _playerWall.colorPopup["colorBtn" + _loc3_]; + if(_loc4_) + { + if(param1) + { + _loc4_.removeEventListener("mouseDown",onSelectColor); + } + else + { + _loc4_.addEventListener("mouseDown",onSelectColor,false,0,true); + } + _loc4_.gotoAndStop(_loc3_); + } + if(!_loc4_) + { + _loc2_ = false; + } + _loc3_++; + } + } + + private function updatePatternPopupColors() : void + { + var _loc1_:int = 0; + if(_patternWindows) + { + _loc1_ = 0; + while(_loc1_ < _patternWindows.mediaWindows.length) + { + ItemWindowPattern(_patternWindows.mediaWindows[_loc1_]).setColor(_myCurrColorId); + _loc1_++; + } + } + if(_messagePatternWindow) + { + ItemWindowPattern(_messagePatternWindow).setColor(_myCurrColorId); + } + _playerWall.messageTxtCont.gotoAndStop(_myCurrColorId); + } + + private function setupEmotePopup(param1:Boolean = false) : void + { + if(_canWrite && (gMainFrame.userInfo.sgChatType != 0 && gMainFrame.userInfo.sgChatType != 3)) + { + if(param1) + { + if(_emoteMgr) + { + _emoteMgr.destroy(); + } + } + else + { + _emoteMgr = new EmoticonManager(1,onEmoteDown,_playerWall.emoteBtn,_playerWall.emotePopup,null,null,null,null,false); + } + } + else + { + _playerWall.emoteBtn.activateGrayState(true); + _playerWall.emoteBtn.mouseChildren = false; + _playerWall.emoteBtn.mouseEnabled = false; + } + } + + private function setupNotificationsPopup(param1:Boolean = false) : void + { + var _loc2_:int = 0; + var _loc3_:int = 0; + if(param1) + { + _playerWall.wallNotificationCont.removeEventListener("mouseDown",onPopup); + _playerWall.wallNotificationCont.bx.removeEventListener("mouseDown",onNotificationsBtn); + if(_notificationWindows != null) + { + _notificationWindows.destroy(); + _notificationWindows = null; + } + } + else + { + _playerWall.wallNotificationCont.addEventListener("mouseDown",onPopup,false,0,true); + _playerWall.wallNotificationCont.bx.addEventListener("mouseDown",onNotificationClose,false,0,true); + if(_notifications) + { + _loc3_ = 0; + while(_loc3_ < _notifications.length) + { + if(!_notifications[_loc3_].isRead) + { + _loc2_++; + } + _loc3_++; + } + } + _playerWall.notificationBtn.numIcon.countTxt.text = String(_loc2_); + _playerWall.notificationBtn.numIcon.visible = _loc2_ > 0; + } + } + + private function setupLikes(param1:Boolean = false) : void + { + if(!param1) + { + _playerWall.likeBtn.activateLoadingState(true); + ResourceArrayXtCommManager.sendResourceArrayGetRequest("jammerwall",_ownerUUID,true,onResourceArrayGet); + } + } + + private function setupViews() : void + { + if(!_isMyWall) + { + if(PlayerWallManager.myViewedWalls[_owner] == null) + { + PlayerWallXtCommManager.sendSetWallCounterIncrementRequest(_owner,onCounterIncrement); + } + } + } + + private function createWallPosts() : void + { + var _loc3_:Array = null; + var _loc1_:int = 0; + var _loc2_:Object = null; + var _loc4_:PostMessage = null; + if(_playerWall) + { + if(_postWindows) + { + _scrollYPosition = _postWindows.scrollYValue; + _postWindows.destroy(); + _postWindows = null; + } + else + { + _scrollYPosition = 1.7976931348623157e+308; + } + _loc3_ = []; + _loc2_ = PlayerWallManager.myBlockedMessages; + _loc1_ = 0; + while(_loc1_ < _inbox.length) + { + _loc4_ = _inbox[_loc1_]; + if(_loc4_.msgId == _loc2_[_loc4_.msgId]) + { + _inbox.splice(_loc1_,1); + _loc1_--; + } + else + { + _loc3_.push(_loc4_); + } + _loc1_++; + } + _playerWall.contentLoader.visible = false; + _playerWall.noPostCont.visible = _inbox.length == 0; + _playerWall.cleanUpBtn.activateGrayState(_inbox.length == 0); + _postWindows = new WindowAndScrollbarGenerator(); + _postWindows.init(_playerWall.itemHolder.width,_playerWall.itemHolder.height - 4,0,_scrollYPosition,1,5,0,0,0,6,0,ItemWindowPost,_loc3_,"",100,{ + "mouseDown":null, + "mouseOver":null, + "mouseOut":null + },{ + "reportMsgBtnMouseDown":onReportDown, + "deleteMsgBtnMouseDown":onDeleteDown, + "replyMsgBtnMouseDown":onReplyDown, + "isMyPost":_isMyWall + },null,false,false,false,false,false); + _playerWall.itemHolder.addChild(_postWindows); + if(_jumpToMessageId != null && _jumpToMessageId != "") + { + _postWindows.findAndScrollTo("msgId",_jumpToMessageId,true); + } + } + } + + private function closeAllLowerPopups() : void + { + SafeChatManager.closeSafeChat(_playerWall.chatTree); + _playerWall.speedChatBtn.downToUpState(); + if(_emoteMgr) + { + _emoteMgr.closeEmotes(); + } + if(_playerWall.colorPopup.visible) + { + _playerWall.colorPopup.visible = false; + _playerWall.colorBtn.downToUpState(); + } + if(_playerWall.patternPopup.visible) + { + _playerWall.patternPopup.visible = false; + _playerWall.patternBtn.downToUpState(); + } + } + + private function decorStickersAndMasterpieceHandler(param1:MouseEvent) : void + { + var _loc2_:int = 0; + if(param1.currentTarget == _playerWall.wallCustomize.wallpaperBtnDown) + { + _loc2_ = 0; + } + else if(param1.currentTarget == _playerWall.wallCustomize.stickerBtnDown) + { + _loc2_ = 1; + } + else if(param1.currentTarget == _playerWall.wallCustomize.masterpieceBtnDown) + { + _loc2_ = 2; + } + setupCustomizationWindows(_loc2_); + } + + private function onSelectPattern(param1:MouseEvent) : void + { + param1.stopPropagation(); + _currPatternId = param1.currentTarget.getCurrentPatternIndex(); + ItemWindowPattern(_messagePatternWindow).setPattern(_currPatternId); + GuiManager.setSharedObj("msgPattern",_currPatternId); + _playerWall.patternPopup.visible = false; + _playerWall.patternBtn.downToUpState(); + } + + private function onSelectColor(param1:MouseEvent) : void + { + param1.stopPropagation(); + _myCurrColorId = param1.currentTarget.currentFrame; + GuiManager.setSharedObj("msgColor",_myCurrColorId); + _playerWall.colorPopup.visible = false; + _playerWall.colorBtn.downToUpState(); + updatePatternPopupColors(); + } + + private function onReportDown(param1:MouseEvent) : void + { + param1.stopPropagation(); + var _loc2_:ItemWindowPost = param1.currentTarget.parent.parent.parent; + _reportMsgId = _loc2_.msgId; + _reportAPlayer = new ReportAPlayer(); + _reportAPlayer.init(3,_guiLayer,onPostReport,true,_loc2_.senderUserName,_loc2_.senderModeratedUserName,false,_reportMsgId); + } + + private function onStatusReportDown(param1:MouseEvent) : void + { + param1.stopPropagation(); + _reportAPlayer = new ReportAPlayer(); + _reportAPlayer.init(3,_guiLayer,onPostStatusReport,true,_owner,_ownerModeratedUsername,false); + } + + private function onPostReport(param1:Boolean) : void + { + if(_reportAPlayer) + { + _reportAPlayer.destroy(); + _reportAPlayer = null; + } + if(param1 && _reportMsgId != "") + { + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + KeepAlive.restartTimeLeftTimer(); + PlayerWallXtCommManager.sendSetBlockedMessage(_reportMsgId,null); + _reportMsgId = ""; + } + SafeChatManager.destroy(_playerWall.chatTree); + SafeChatManager.buildSafeChatTree(_playerWall.chatTree,"ECardTextTreeNode",5,onChatTreeClose,null); + SafeChatManager.closeSafeChat(_playerWall.chatTree); + _playerWall.speedChatBtn.downToUpState(); + } + + private function onPostStatusReport(param1:Boolean) : void + { + if(_reportAPlayer) + { + _reportAPlayer.destroy(); + _reportAPlayer = null; + } + SafeChatManager.destroy(_playerWall.chatTree); + SafeChatManager.buildSafeChatTree(_playerWall.chatTree,"ECardTextTreeNode",5,onChatTreeClose,null); + SafeChatManager.closeSafeChat(_playerWall.chatTree); + _playerWall.speedChatBtn.downToUpState(); + } + + private function findDifferencesAndUpdatePosts(param1:Vector.) : void + { + var _loc14_:PostMessage = null; + var _loc2_:PostMessage = null; + var _loc3_:int = 0; + var _loc9_:int = 0; + var _loc10_:int = 0; + var _loc11_:int = 0; + var _loc12_:int = 0; + var _loc7_:Object = {}; + for each(_loc14_ in _inbox) + { + _loc7_[_loc14_.msgId] = _loc14_; + } + var _loc6_:Object = {}; + for each(_loc14_ in param1) + { + _loc6_[_loc14_.msgId] = _loc14_; + } + var _loc15_:Array = []; + var _loc4_:Vector. = new Vector.(); + var _loc5_:Vector. = new Vector.(); + var _loc13_:Object = PlayerWallManager.myBlockedMessages; + var _loc8_:int = Math.max(_inbox.length,param1.length); + _loc9_ = 0; + while(_loc9_ < _loc8_) + { + if(_loc9_ < param1.length) + { + _loc14_ = param1[_loc9_]; + _loc2_ = _loc7_[_loc14_.msgId]; + if(_loc2_ == null) + { + if(_loc14_.msgId != _loc13_[_loc14_.msgId]) + { + _loc15_.push({ + "index":_loc9_, + "msg":_loc14_ + }); + } + } + else if(_loc2_.message != _loc14_.message) + { + _loc4_.push(_loc14_); + } + if(_loc9_ < _inbox.length && _loc6_[_inbox[_loc9_].msgId] == null) + { + if(_loc13_[_inbox[_loc9_].msgId] != null) + { + _loc3_++; + } + else + { + _loc5_.push(_loc9_ - _loc3_); + } + } + } + else if(_loc9_ < _inbox.length) + { + _loc5_.push(_loc9_ - _loc3_); + } + _loc9_++; + } + if(_postWindows && _loc5_.length > 0) + { + _loc10_ = 0; + while(_loc10_ < _loc5_.length) + { + _postWindows.deleteItem(_loc5_[_loc10_] - _loc11_,_inbox,true,false); + _loc11_++; + _loc10_++; + } + } + _inbox = param1; + if(_postWindows) + { + if(_loc15_.length > 0) + { + if(_loc15_.length == 1) + { + _postWindows.insertItemAtSpecificPosition(_loc15_[0].msg,false,_loc15_[0].index); + } + else + { + _loc10_ = 0; + while(_loc10_ < _loc15_.length) + { + _postWindows.insertItemAtSpecificPosition(_loc15_[_loc10_].msg,false,_loc15_[_loc10_].index); + _loc10_++; + } + } + } + if(_loc4_.length > 0) + { + _loc12_ = 0; + while(_loc12_ < _loc4_.length) + { + _postWindows.findItemWithTypeAndUpdate(_loc4_[_loc12_],"msgId"); + _loc12_++; + } + } + } + else + { + createWallPosts(); + } + } + + private function findDifferencesAndUpdateNotifications(param1:Vector.) : void + { + var _loc14_:PostMessage = null; + var _loc2_:PostMessage = null; + var _loc3_:int = 0; + var _loc7_:int = 0; + var _loc8_:int = 0; + var _loc9_:int = 0; + var _loc10_:int = 0; + var _loc5_:Object = {}; + for each(_loc14_ in _notifications) + { + _loc5_[_loc14_.msgId] = _loc14_; + } + var _loc11_:Object = {}; + for each(_loc14_ in param1) + { + _loc11_[_loc14_.msgId] = _loc14_; + } + var _loc15_:Array = []; + var _loc13_:Vector. = new Vector.(); + var _loc4_:Vector. = new Vector.(); + var _loc12_:Object = PlayerWallManager.myBlockedMessages; + var _loc6_:int = Math.max(_notifications.length,param1.length); + _loc7_ = 0; + while(_loc7_ < _loc6_) + { + if(_loc7_ < param1.length) + { + _loc14_ = param1[_loc7_]; + _loc2_ = _loc5_[_loc14_.msgId]; + if(_loc2_ == null) + { + if(_loc14_.msgId != _loc12_[_loc14_.msgId]) + { + _loc15_.push({ + "index":_loc7_, + "msg":_loc14_ + }); + } + } + else if(_loc2_.message != _loc14_.message) + { + _loc13_.push(_loc14_); + } + if(_loc7_ < _notifications.length && _loc11_[_notifications[_loc7_].msgId] == null) + { + if(_loc12_[_notifications[_loc7_].msgId] != null) + { + _loc3_++; + } + else + { + _loc4_.push(_loc7_ - _loc3_); + } + } + } + else if(_loc7_ < _notifications.length) + { + _loc4_.push(_loc7_ - _loc3_); + } + _loc7_++; + } + if(_notificationWindows && _loc4_.length > 0) + { + _loc8_ = 0; + while(_loc8_ < _loc4_.length) + { + _notificationWindows.deleteItem(_loc4_[_loc8_] - _loc9_,_notifications,true,false); + _loc9_++; + _loc8_++; + } + } + _notifications = param1; + if(_notificationWindows) + { + if(_loc15_.length > 0) + { + if(_loc15_.length == 1) + { + _notificationWindows.insertItemAtSpecificPosition(_loc15_[0].msg,false,_loc15_[0].index); + } + else + { + _loc8_ = 0; + while(_loc8_ < _loc15_.length) + { + _notificationWindows.insertItemAtSpecificPosition(_loc15_[_loc8_].msg,false,_loc15_[_loc8_].index); + _loc8_++; + } + } + } + if(_loc13_.length > 0) + { + _loc10_ = 0; + while(_loc10_ < _loc13_.length) + { + _notificationWindows.findItemWithTypeAndUpdate(_loc13_[_loc10_],"msgId"); + _loc10_++; + } + } + } + } + + private function displayLoadedWall() : void + { + DarkenManager.showLoadingSpiral(false); + GuiManager.mainHud.playerWall.activateLoadingState(false); + BuddyManager.setPlayerWallLoading(false); + BuddyManager.destroyBuddyCard(); + _guiLayer.addChild(_playerWall); + DarkenManager.darken(_playerWall); + _updateTimer.start(); + } + + private function setupAvatarAndPetPhoto(param1:Boolean = true, param2:Boolean = false) : void + { + var _loc5_:AvatarDef = null; + var _loc6_:AccItemCollection = null; + var _loc3_:Item = null; + var _loc4_:int = 0; + if(_playerWall && _currWallDecor) + { + while(_currWallDecor.photoCont.itemWindow.bgWindow.numChildren > 1) + { + _currWallDecor.photoCont.itemWindow.bgWindow.removeChildAt(_currWallDecor.photoCont.itemWindow.bgWindow.numChildren - 1); + } + while(_currWallDecor.photoCont.itemWindow.charBox.numChildren > 1) + { + _currWallDecor.photoCont.itemWindow.charBox.removeChildAt(_currWallDecor.photoCont.itemWindow.charBox.numChildren - 1); + } + while(_currWallDecor.photoCont.itemWindow.itemWindowPet2R.numChildren > 1) + { + _currWallDecor.photoCont.itemWindow.itemWindowPet2R.removeChildAt(_currWallDecor.photoCont.itemWindow.itemWindowPet2R.numChildren - 1); + } + while(_currWallDecor.photoCont.itemWindow.itemWindowPet1R.numChildren > 1) + { + _currWallDecor.photoCont.itemWindow.itemWindowPet1R.removeChildAt(_currWallDecor.photoCont.itemWindow.itemWindowPet1R.numChildren - 1); + } + while(_currWallDecor.photoCont.itemWindow.itemWindowPet2L.numChildren > 1) + { + _currWallDecor.photoCont.itemWindow.itemWindowPet2L.removeChildAt(_currWallDecor.photoCont.itemWindow.itemWindowPet2L.numChildren - 1); + } + while(_currWallDecor.photoCont.itemWindow.itemWindowPet1L.numChildren > 1) + { + _currWallDecor.photoCont.itemWindow.itemWindowPet1L.removeChildAt(_currWallDecor.photoCont.itemWindow.itemWindowPet1L.numChildren - 1); + } + } + if(param2) + { + if(_photoAvatar) + { + _photoAvatar.destroy(); + _photoAvatar = null; + } + if(_photoAvatarView) + { + _photoAvatarView.destroy(); + _photoAvatarView = null; + } + } + else if(_wallParameters.pb != null && _wallParameters.pb.avatar != null) + { + if(param1 || _photoAvatarView == null) + { + if(_photoBackground == null) + { + _mediaHelper = new MediaHelper(); + _mediaHelper.init(6275,onBackgroundPhotoLoaded); + return; + } + _loc5_ = gMainFrame.userInfo.getAvatarDefByAvType(_wallParameters.pb.avatar.id,false); + // an animal this game does not know (a disguise, one taken + // away) has no def, and the wall stopped on it for good: the + // photo is left out instead + if(_loc5_ == null) + { + _currWallDecor.photoCont.visible = _isMyWall; + _currWallDecor.photoCont.noPhotoCont.visible = true; + return; + } + _photoAvatar = new Avatar(); + _photoAvatar.init(-1,-1,"",_loc5_.defId,[_wallParameters.pb.avatar.color1,_wallParameters.pb.avatar.color2,_wallParameters.pb.avatar.color3]); + _loc6_ = new AccItemCollection(); + _loc3_ = new Item(); + _loc3_.init(1,0,0,EquippedAvatars.forced()); + _loc6_.pushAccItem(_loc3_); + _loc3_ = new Item(); + _loc3_.init(_wallParameters.pb.avatar.eyes,1,0,EquippedAvatars.forced()); + if(_loc3_.colors && _loc3_.colors.length > 0) + { + _loc3_.color = _loc3_.colors[0]; + } + _loc6_.pushAccItem(_loc3_); + if(_wallParameters.pb.avatar.pattern && _wallParameters.pb.avatar.pattern != 0) + { + _loc3_ = new Item(); + _loc3_.init(_wallParameters.pb.avatar.pattern,2,_photoAvatar.colors[1],EquippedAvatars.forced()); + _loc6_.pushAccItem(_loc3_); + } + if(_wallParameters.pb.items) + { + _loc4_ = 0; + while(_loc4_ < _wallParameters.pb.items.length) + { + _loc3_ = new Item(); + _loc3_.init(_wallParameters.pb.items[_loc4_].id,_loc4_ + 2,_wallParameters.pb.items[_loc4_].color,EquippedAvatars.forced()); + _loc6_.pushAccItem(_loc3_); + _loc4_++; + } + } + _photoAvatar.userName = AvatarManager.playerAvatar.userName; + _photoAvatar.itemResponseIntegrate(_loc6_); + _photoAvatarView = new AvatarEditorView(); + _photoAvatarView.init(_photoAvatar,null,null,true); + _photoAvatarView.playAnim(14,false,0,onAvatarLoaded); + if(_wallParameters.pb.pet) + { + // saved as "ubits" and "ebits" (onPhotoBoothSave), and read + // as "uBits" and "eBits": the pet lost its pattern and eyes + _photoPet = new GuiPet(_wallParameters.pb.pet.ts,0,_wallParameters.pb.pet.lbits,_wallParameters.pb.pet.ubits,_wallParameters.pb.pet.ebits,0,"",0,0,0,onPetLoaded); + } + } + else + { + _currWallDecor.photoCont.itemWindow.charBox.addChild(_photoAvatarView); + } + _currWallDecor.photoCont.visible = true; + _currWallDecor.photoCont.noPhotoCont.visible = false; + // frames count from 1 + if(_wallParameters.pb.bgid == null || _wallParameters.pb.bgid < 1 || _wallParameters.pb.bgid > _photoBackground.framesLoaded) + { + _wallParameters.pb.bgid = 1; + } + _photoBackground.gotoAndStop(_wallParameters.pb.bgid); + _currWallDecor.photoCont.itemWindow.bgWindow.addChild(_photoBackground); + } + else if(!_isMyWall) + { + _currWallDecor.photoCont.visible = false; + } + else + { + _currWallDecor.photoCont.visible = true; + _currWallDecor.photoCont.noPhotoCont.visible = true; + } + } + + private function onDeleteDown(param1:MouseEvent) : void + { + param1.stopPropagation(); + param1.currentTarget.parent.parent.parent.darken(true); + new SBOkCancelPopup(_guiLayer,LocalizationManager.translateIdOnly(23141),true,deleteMessageConfirmCallback,param1.currentTarget.parent.parent.parent); + } + + private function deleteMessageConfirmCallback(param1:Object) : void + { + if(_playerWall && param1.status) + { + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + KeepAlive.restartTimeLeftTimer(); + PlayerWallXtCommManager.sendDeleteFromPlayerWall(_owner,param1.passback.parentOrMyPostMessageId,onDeleteResponse); + } + else + { + param1.passback.darken(false); + } + } + + public function onDeleteResponse(param1:Boolean, param2:String, param3:String = "") : void + { + if(_playerWall) + { + if(_predictiveTextManager && _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha != 0.5 && _playerWall.messageTxtCont.txtColorCont.messageTxt.length > 0) + { + _playerWall.postBtn.activateGrayState(!_predictiveTextManager.isValid()); + _playerWall.replyBtn.activateGrayState(!_predictiveTextManager.isValid()); + } + else + { + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + } + if(param1) + { + deleteItemAndChildrenIfNecessary(param2,_inbox,_postWindows); + _playerWall.noPostCont.visible = _inbox.length == 0; + _playerWall.cleanUpBtn.activateGrayState(_inbox.length == 0); + } + else if(param3) + { + if(param3 == "token") + { + PlayerWallXtCommManager.sendWallTokenRequest(_owner,PlayerWallXtCommManager.ContinueCommandAfterTokenRequest,{ + "cmd":"DEL", + "username":_owner, + "messageuuid":String, + "callback":onDeleteResponse + },true,true); + } + else if(param3 == "unavailable") + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(22625)); + } + } + else + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(22627)); + } + } + } + + private function deleteItemAndChildrenIfNecessary(param1:String, param2:Vector., param3:WindowAndScrollbarGenerator) : void + { + var _loc4_:PostMessage = null; + var _loc5_:int = 0; + _loc5_ = 0; + while(_loc5_ < param2.length) + { + _loc4_ = param2[_loc5_]; + if(_loc4_ != null && _loc4_.msgId == param1) + { + param3.deleteItem(_loc5_,param2,true,false); + if(_loc4_.parentMessageId == null || _loc4_.parentMessageId.length == 0) + { + if(_loc5_ < param2.length) + { + _loc4_ = param2[_loc5_]; + while(_loc4_ != null && _loc5_ < param2.length && (_loc4_.parentMessageId != null && _loc4_.parentMessageId.length > 0)) + { + param3.deleteItem(_loc5_,param2,true,false); + if(_loc5_ < param2.length) + { + _loc4_ = param2[_loc5_]; + } + else + { + _loc4_ = null; + } + } + } + } + break; + } + _loc5_++; + } + } + + private function deleteItemByIndexAndChildrenIfNecessary(param1:int, param2:Vector., param3:WindowAndScrollbarGenerator) : void + { + var _loc4_:PostMessage = param2[param1]; + param3.deleteItem(param1,param2,true,false); + if(_loc4_.parentMessageId == null || _loc4_.parentMessageId.length == 0) + { + if(param1 < param2.length) + { + _loc4_ = param2[param1]; + while(_loc4_ != null && param1 < param2.length && (_loc4_.parentMessageId != null && _loc4_.parentMessageId.length > 0)) + { + param3.deleteItem(param1,param2,true,false); + if(param1 < param2.length) + { + _loc4_ = param2[param1]; + } + else + { + _loc4_ = null; + } + } + } + } + } + + private function onReplyDown(param1:MouseEvent) : void + { + param1.stopPropagation(); + _currReplyPost = param1.currentTarget.parent.parent.parent; + _playerWall.replyToTip.visible = true; + LocalizationManager.translateIdAndInsert(_playerWall.replyToTip.replyToTxt,30491,_currReplyPost.senderModeratedUserName); + _playerWall.replyBtn.visible = true; + _playerWall.cancelBtn.visible = true; + } + + private function onPatternBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!param1.currentTarget.isGray) + { + if(_playerWall.colorPopup.visible) + { + _playerWall.colorPopup.visible = false; + _playerWall.colorBtn.downToUpState(); + } + SafeChatManager.closeSafeChat(_playerWall.chatTree); + _playerWall.speedChatBtn.downToUpState(); + if(_emoteMgr) + { + _emoteMgr.closeEmotes(); + } + if(_playerWall.patternPopup.visible) + { + _playerWall.patternPopup.visible = false; + _playerWall.patternBtn.downToUpState(); + } + else + { + _playerWall.patternPopup.visible = true; + } + } + } + + private function onColorBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!param1.currentTarget.isGray) + { + if(_playerWall.patternPopup.visible) + { + _playerWall.patternPopup.visible = false; + _playerWall.patternBtn.downToUpState(); + } + SafeChatManager.closeSafeChat(_playerWall.chatTree); + _playerWall.speedChatBtn.downToUpState(); + if(_emoteMgr) + { + _emoteMgr.closeEmotes(); + } + if(_playerWall.colorPopup.visible) + { + _playerWall.colorPopup.visible = false; + _playerWall.colorBtn.downToUpState(); + } + else + { + _playerWall.colorPopup.visible = true; + } + } + } + + private function onEmoteBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!param1.currentTarget.isGray) + { + if(gMainFrame.userInfo.sgChatType == 0 || gMainFrame.userInfo.sgChatType == 3) + { + gMainFrame.stage.focus = null; + if(gMainFrame.userInfo.sgChatType != gMainFrame.userInfo.sgChatTypeNonDegraded) + { + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18406),true,openSafeChatAfterOk); + } + return; + } + SafeChatManager.closeSafeChat(_playerWall.chatTree); + _playerWall.speedChatBtn.downToUpState(); + if(_playerWall.patternPopup.visible) + { + _playerWall.patternPopup.visible = false; + _playerWall.patternBtn.downToUpState(); + } + if(_playerWall.colorPopup.visible) + { + _playerWall.colorPopup.visible = false; + _playerWall.colorBtn.downToUpState(); + } + } + } + + private function onSafeChatBtn(param1:MouseEvent) : void + { + if(param1) + { + param1.stopPropagation(); + if(param1.currentTarget.isGray) + { + return; + } + } + if(_emoteMgr) + { + _emoteMgr.closeEmotes(); + } + if(_playerWall.patternPopup.visible) + { + _playerWall.patternPopup.visible = false; + _playerWall.patternBtn.downToUpState(); + } + if(_playerWall.colorPopup.visible) + { + _playerWall.colorPopup.visible = false; + _playerWall.colorBtn.downToUpState(); + } + if(!_playerWall.speedChatBtn.isGray) + { + if(!_hasLoadedSafeChat) + { + SafeChatManager.buildSafeChatTree(_playerWall.chatTree,"ECardTextTreeNode",5,onChatTreeClose,null,onSafeChatLoaded); + _hasLoadedSafeChat = true; + } + else if(!_playerWall.chatTree.visible) + { + SafeChatManager.openSafeChat(false,_playerWall.chatTree); + } + else + { + SafeChatManager.closeSafeChat(_playerWall.chatTree); + } + } + } + + private function onSafeChatLoaded() : void + { + SafeChatManager.openSafeChat(false,_playerWall.chatTree); + } + + private function onEmoteDown(param1:Sprite) : void + { + var _loc2_:String = null; + if(_playerWall.messageTxtCont.txtColorCont.messageTxt.alpha == 0.5) + { + _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha = 1; + if(_predictiveTextManager) + { + _predictiveTextManager.resetTreeSearch(); + } + } + if(_predictiveTextManager) + { + _loc2_ = EmoticonUtility.getEmoteString(param1); + if(_playerWall.messageTxtCont.txtColorCont.messageTxt.text.length + _loc2_.length <= _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars) + { + _predictiveTextManager.addWordToPredictiveText(_loc2_); + setTimeout(updateCharCount,41.666666666666664); + gMainFrame.stage.focus = _playerWall.messageTxtCont.txtColorCont.messageTxt; + _playerWall.speedChatBtn.activateGrayState(true); + } + } + } + + private function onPostBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_predictiveTextManager) + { + _predictiveTextManager.onSendBtnDown(null); + } + else + { + onSendMessage(); + } + } + + private function onSettingsBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + _playerWall.settingsPopup.visible = !_playerWall.settingsPopup.visible; + if(!_playerWall.settingsPopup.visible) + { + _playerWall.settingsBtn[_playerWall.settingsBtn.currentFrameLabel + "Btn"].downToUpState(); + } + closeAllLowerPopups(); + } + + private function onMenuBtn(param1:MouseEvent) : void + { + if(param1) + { + param1.stopPropagation(); + } + closeAllLowerPopups(); + _playerWall.wallCustomize.visible = true; + setupCustomizationWindows(0); + } + + private function onMasterpieceFrameDown(param1:MouseEvent) : void + { + var _loc3_:MasterpieceDisplayItem = null; + param1.stopPropagation(); + var _loc2_:MovieClip = param1.currentTarget as MovieClip; + if(_loc2_ && _loc2_.itemLayer.numChildren > 1) + { + _loc3_ = _loc2_.itemLayer.getChildAt(_loc2_.itemLayer.numChildren - 1) as MasterpieceDisplayItem; + if(_loc3_) + { + GuiManager.openMasterpiecePreview(_loc3_.uniqueImageId,_loc3_.uniqueImageCreator,_loc3_.uniqueImageCreatorDbId,_loc3_.uniqueImageCreatorUUID,_loc3_.versionId,_owner,null); + } + } + } + + private function onMasterpieceOrStickerFrameOver(param1:MouseEvent) : void + { + param1.stopPropagation(); + param1.currentTarget.gotoAndStop("mouse"); + } + + private function onMasterpieceOrStickerFrameOut(param1:MouseEvent) : void + { + param1.stopPropagation(); + param1.currentTarget.gotoAndStop("out"); + param1.currentTarget.glow.visible = false; + } + + private function onStickerFrameDown(param1:MouseEvent) : void + { + var _loc3_:StickerItem = null; + param1.stopPropagation(); + var _loc2_:MovieClip = param1.currentTarget as MovieClip; + if(_loc2_ && _loc2_.itemLayer.numChildren > 1) + { + _loc3_ = _loc2_.itemLayer.getChildAt(_loc2_.itemLayer.numChildren - 1) as StickerItem; + if(!_loc3_) + { + } + } + } + + private function onSuggestWordsBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + FeedbackManager.openFeedbackPopup(18); + } + + private function onCloseBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_closeCallback != null) + { + _closeCallback(); + } + else + { + destroy(); + } + } + + private function onDecorMouseDown(param1:MouseEvent) : void + { + var _loc2_:int = _currDecorIndex; + if(param1) + { + param1.stopPropagation(); + _wallCustomizeWindows.mediaWindows[_loc2_].downToUpState(); + _loc2_ = int(param1.currentTarget.index); + _currDecorIndex = _loc2_; + _wallParameters.bg = _currDecorIndex; + } + _mediaHelper = new MediaHelper(); + _mediaHelper.init(_wallDecorItemIds[_loc2_],onWallDecorItemLoaded); + } + + private function onStickerMouseDown(param1:MouseEvent) : void + { + var _loc4_:MovieClip = null; + var _loc2_:int = 0; + var _loc5_:int = 0; + var _loc3_:StickerItem = null; + param1.stopPropagation(); + if((param1.currentTarget as ItemWindowSticker).inUse) + { + _loc5_ = (param1.currentTarget as ItemWindowSticker).stickerMediaId; + if(_loc5_ > 0) + { + _loc4_ = _playerWall.sticker_0; + _loc2_ = 0; + while(_loc4_ != null) + { + if(_loc4_.itemLayer.numChildren > 1) + { + _loc3_ = _loc4_.itemLayer.getChildAt(_loc4_.itemLayer.numChildren - 1) as StickerItem; + if(_loc3_ && _loc5_ == _loc3_.mediaId) + { + _loc4_.itemLayer.removeChild(_loc3_); + if(_selectedStickers) + { + for(var _loc6_:int in _selectedStickers) + { + if(_selectedStickers[_loc6_].id == _loc5_) + { + _selectedStickers.splice(_loc6_,1); + _wallParameters.stk = _selectedStickers; + break; + } + } + } + break; + } + } + if(_loc4_.loadingSpiral) + { + (_loc4_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc4_.loadingSpiral; + } + _loc2_++; + _loc4_ = _playerWall["sticker_" + _loc2_]; + } + } + (param1.currentTarget as ItemWindowSticker).inUse = false; + } + else + { + _currDragSticker = param1.currentTarget.cloneItem(onStickerDragCloneLoaded); + _dragStartPoint = new Point(param1.stageX,param1.stageY); + _currDragSticker.startDrag(); + _playerWall.addChild(_currDragSticker); + _playerWall.addEventListener("mouseUp",onStickerMouseUp,false,0,true); + _loc4_ = _playerWall.sticker_0; + _loc2_ = 0; + while(_loc4_ != null) + { + _loc4_.gotoAndStop("out"); + _loc4_.glow.visible = true; + _loc4_.mouseEnabled = false; + _loc4_.mouseChildren = false; + _loc2_++; + _loc4_ = _playerWall["sticker_" + _loc2_]; + } + (param1.currentTarget as ItemWindowSticker).inUse = true; + } + } + + private function onMasterpieceMouseDown(param1:MouseEvent) : void + { + var _loc5_:MovieClip = null; + var _loc2_:int = 0; + var _loc7_:DenItem = null; + var _loc3_:MasterpieceDisplayItem = null; + var _loc4_:MasterpieceDisplayItem = null; + param1.stopPropagation(); + if((param1.currentTarget as ItemWindowMasterpiece).inUse) + { + _loc7_ = (param1.currentTarget as ItemWindowMasterpiece).currItem; + if(_loc7_) + { + _loc5_ = _playerWall.frame_0; + _loc2_ = 0; + while(_loc5_ != null) + { + if(_loc5_.itemLayer.numChildren > 1) + { + _loc3_ = _loc5_.itemLayer.getChildAt(_loc5_.itemLayer.numChildren - 1) as MasterpieceDisplayItem; + if(_loc3_ && _loc7_.invIdx == _loc3_.invId) + { + _loc5_.itemLayer.removeChild(_loc3_); + if(_selectedMasterpieces) + { + for(var _loc6_:int in _selectedMasterpieces) + { + if(_selectedMasterpieces[_loc6_].iid == _loc7_.invIdx) + { + _selectedMasterpieces.splice(_loc6_,1); + _wallParameters.mp = _selectedMasterpieces; + break; + } + } + } + break; + } + } + if(_loc5_.loadingSpiral) + { + (_loc5_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc5_.loadingSpiral; + } + _loc2_++; + _loc5_ = _playerWall["frame_" + _loc2_]; + } + } + (param1.currentTarget as ItemWindowMasterpiece).inUse = false; + } + else + { + _currDragMasterpiece = _loc4_ = param1.currentTarget.cloneItem(onDragItemLoaded) as MasterpieceDisplayItem; + _dragStartPoint = new Point(param1.stageX,param1.stageY); + _currDragMasterpiece.startDrag(); + _playerWall.addChild(_currDragMasterpiece); + _playerWall.addEventListener("mouseUp",onMasterpieceMouseUp,false,0,true); + _loc5_ = _playerWall.frame_0; + _loc2_ = 0; + while(_loc5_ != null) + { + _loc5_.gotoAndStop("out"); + _loc5_.glow.visible = true; + _loc5_.mouseEnabled = false; + _loc5_.mouseChildren = false; + _loc2_++; + _loc5_ = _playerWall["frame_" + _loc2_]; + } + (param1.currentTarget as ItemWindowMasterpiece).inUse = true; + } + } + + private function onStickerDragCloneLoaded() : void + { + var _loc1_:Point = null; + var _loc2_:Number = NaN; + if(_currDragSticker) + { + _loc1_ = _playerWall.globalToLocal(_dragStartPoint); + _currDragSticker.x = _loc1_.x; + _currDragSticker.y = _loc1_.y; + _loc2_ = _playerWall.sticker_0.itemLayer.width / Math.max(_currDragSticker.width,_currDragSticker.height); + _currDragSticker.scaleX = _currDragSticker.scaleY = _loc2_; + if(_currDragSticker.parent != _playerWall) + { + _currDragSticker.x = _currDragSticker.y = 0; + _currDragSticker = null; + } + } + } + + private function onDragItemLoaded(param1:MasterpieceDisplayItem, param2:MovieClip) : void + { + var _loc3_:Point = null; + var _loc4_:Number = NaN; + if(_currDragMasterpiece) + { + _loc3_ = _playerWall.globalToLocal(_dragStartPoint); + _currDragMasterpiece.x = _loc3_.x; + _currDragMasterpiece.y = _loc3_.y; + _loc4_ = _playerWall.frame_0.itemLayer.width / Math.max(_currDragMasterpiece.width,_currDragMasterpiece.height); + _currDragMasterpiece.scaleX = _currDragMasterpiece.scaleY = _loc4_; + _currDragMasterpiece.onLoadedCallback = null; + if(_currDragMasterpiece.parent != _playerWall) + { + _currDragMasterpiece.x = _currDragMasterpiece.y = 0; + _currDragMasterpiece = null; + } + } + } + + private function onStickerMouseUp(param1:MouseEvent) : void + { + var _loc3_:MovieClip = null; + var _loc2_:int = 0; + var _loc7_:MovieClip = null; + var _loc8_:Number = NaN; + var _loc4_:Number = NaN; + var _loc9_:Object = null; + param1.stopPropagation(); + if(_currDragSticker != null) + { + _currDragSticker.stopDrag(); + _loc3_ = _playerWall.sticker_0; + _loc2_ = 0; + _loc8_ = 2147483647; + while(_loc3_ != null) + { + _loc4_ = Math.sqrt(Math.pow(_loc3_.x - _currDragSticker.x,2) + Math.pow(_loc3_.y - _currDragSticker.y,2)); + if(_loc4_ < _loc8_) + { + _loc8_ = _loc4_; + _loc7_ = _loc3_; + } + _loc3_.glow.visible = false; + _loc3_.gotoAndStop("out"); + _loc3_.mouseEnabled = true; + _loc3_.mouseChildren = true; + _loc2_++; + _loc3_ = _playerWall["sticker_" + _loc2_]; + } + if(_selectedStickers != null) + { + _selectedStickers.push({ + "id":_currDragSticker.mediaId, + "pos":int(_loc7_.name.split("_")[1]) + }); + } + else + { + _selectedStickers = [{ + "id":_currDragSticker.mediaId, + "pos":int(_loc7_.name.split("_")[1]) + }]; + } + if(_wallParameters) + { + _wallParameters.stk = _selectedStickers; + } + else + { + _wallParameters = {"stk":_selectedStickers}; + } + while(_loc7_.itemLayer.numChildren > 1) + { + _loc9_ = _loc7_.itemLayer.getChildAt(_loc7_.itemLayer.numChildren - 1); + if(_loc9_ is StickerItem) + { + for(var _loc5_:int in _selectedStickers) + { + if(_selectedStickers[_loc5_].id == (_loc9_ as StickerItem).mediaId) + { + for(var _loc6_:int in _wallCustomizeWindows.mediaWindows) + { + if(_wallCustomizeWindows.mediaWindows[_loc6_].stickerMediaId == _selectedStickers[_loc5_].id) + { + _wallCustomizeWindows.callUpdateOnWindowWithInput(_loc6_,false); + break; + } + } + _selectedStickers.splice(_loc5_,1); + break; + } + } + } + _loc7_.itemLayer.removeChildAt(_loc7_.itemLayer.numChildren - 1); + } + if(_loc7_.loadingSpiral) + { + (_loc7_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc7_.loadingSpiral; + } + _loc7_.itemLayer.addChild(_currDragSticker); + _currDragSticker.x = _currDragSticker.y = 0; + _currDragSticker = null; + } + _playerWall.removeEventListener("mouseUp",onStickerMouseUp); + } + + private function onMasterpieceMouseUp(param1:MouseEvent) : void + { + var _loc3_:MovieClip = null; + var _loc2_:int = 0; + var _loc7_:MovieClip = null; + var _loc8_:Number = NaN; + var _loc4_:Number = NaN; + var _loc9_:Object = null; + param1.stopPropagation(); + if(_currDragMasterpiece != null) + { + _currDragMasterpiece.stopDrag(); + _loc3_ = _playerWall.frame_0; + _loc2_ = 0; + _loc8_ = 2147483647; + while(_loc3_ != null) + { + _loc4_ = Math.sqrt(Math.pow(_loc3_.x - _currDragMasterpiece.x,2) + Math.pow(_loc3_.y - _currDragMasterpiece.y,2)); + if(_loc4_ < _loc8_) + { + _loc8_ = _loc4_; + _loc7_ = _loc3_; + } + _loc3_.glow.visible = false; + _loc3_.gotoAndStop("out"); + _loc3_.mouseEnabled = true; + _loc3_.mouseChildren = true; + _loc2_++; + _loc3_ = _playerWall["frame_" + _loc2_]; + } + if(_selectedMasterpieces != null) + { + _selectedMasterpieces.push({ + "iid":_currDragMasterpiece.invId, + "sid":int(_loc7_.name.split("_")[1]) + }); + } + else + { + _selectedMasterpieces = [{ + "iid":_currDragMasterpiece.invId, + "sid":int(_loc7_.name.split("_")[1]) + }]; + } + if(_wallParameters) + { + _wallParameters.mp = _selectedMasterpieces; + } + else + { + _wallParameters = {"mp":_selectedMasterpieces}; + } + while(_loc7_.itemLayer.numChildren > 1) + { + _loc9_ = _loc7_.itemLayer.getChildAt(_loc7_.itemLayer.numChildren - 1); + if(_loc9_ is MasterpieceDisplayItem) + { + for(var _loc5_:int in _selectedMasterpieces) + { + if(_selectedMasterpieces[_loc5_].iid == (_loc9_ as MasterpieceDisplayItem).invId) + { + for(var _loc6_:int in _masterpieceDiCollection.getCoreArray()) + { + if(_masterpieceDiCollection.getDenItem(_loc6_).invIdx == _selectedMasterpieces[_loc5_].iid) + { + _wallCustomizeWindows.callUpdateOnWindowWithInput(_loc6_,false); + break; + } + } + _selectedMasterpieces.splice(_loc5_,1); + break; + } + } + } + _loc7_.itemLayer.removeChildAt(_loc7_.itemLayer.numChildren - 1); + } + if(_loc7_.loadingSpiral) + { + (_loc7_.loadingSpiral as LoadingSpiral).destroy(); + delete _loc7_.loadingSpiral; + } + _loc7_.itemLayer.addChild(_currDragMasterpiece); + _currDragMasterpiece.x = _currDragMasterpiece.y = 0; + if(_currDragMasterpiece.hasLoaded) + { + _currDragMasterpiece = null; + } + } + _playerWall.removeEventListener("mouseUp",onMasterpieceMouseUp); + } + + private function onWallDecorItemLoaded(param1:MovieClip) : void + { + if(_playerWall) + { + if(_currWallDecor != null) + { + if(_isMyWall) + { + _currWallDecor.photoCont.removeEventListener("mouseDown",onPhotoCont); + _currWallDecor.postStatus.removeEventListener("mouseDown",onPostStatus); + } + else + { + _currWallDecor.postStatus.mouse.mouse.reportBtn.removeEventListener("mouseDown",onStatusReportDown); + _currWallDecor.postStatus.removeEventListener("rollOver",onPostStatusOver); + _currWallDecor.postStatus.removeEventListener("rollOut",onPostStatusOut); + } + _playerWall.wallItemWindow.removeChild(_currWallDecor); + } + _currWallDecor = MovieClip(param1.getChildAt(0)); + if(_isMyWall) + { + _currWallDecor.photoCont.addEventListener("mouseDown",onPhotoCont,false,0,true); + _currWallDecor.postStatus.addEventListener("mouseDown",onPostStatus,false,0,true); + } + else + { + _currWallDecor.postStatus.mouse.mouse.reportBtn.addEventListener("mouseDown",onStatusReportDown,false,0,true); + _currWallDecor.postStatus.addEventListener("rollOver",onPostStatusOver,false,0,true); + _currWallDecor.postStatus.addEventListener("rollOut",onPostStatusOut,false,0,true); + } + _currWallDecor.postStatus.mouse.mouse.reportBtn.visible = false; + _playerWall.wallItemWindow.addChild(_currWallDecor); + if(_wallParameters.tag != null && _wallParameters.tag != "" && (_wallParameters.langId == -1 || _wallParameters.langId == LocalizationManager.currentLanguage)) + { + _currWallDecor.postStatus.mouse.mouse.statusTxt.txt.text = _wallParameters.tag; + } + else if(!_isMyWall) + { + _currWallDecor.postStatus.visible = false; + } + _hasLoadedDecor = true; + if(!_guiLayer.contains(_playerWall)) + { + if(_messagePatternLoaded) + { + displayLoadedWall(); + } + setupAvatarAndPetPhoto(true); + } + else + { + setupAvatarAndPetPhoto(false); + } + } + } + + private function onTimerEvent(param1:Event) : void + { + if(_playerWall) + { + if(_postWindows) + { + _postWindows.callUpdateInWindow(); + } + if(_notificationWindows) + { + _notificationWindows.callUpdateInWindow(); + } + _updateTimer.reset(); + _updateTimer.start(); + } + } + + private function onMessageEntry(param1:MouseEvent) : void + { + param1.stopPropagation(); + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(23230)); + } + + private function onPatternWindowsLoaded() : void + { + if(_playerWall) + { + _patternScrollBar = new SBScrollbar(); + _patternScrollBar.init(_patternWindows,_playerWall.patternPopup.itemWindow.width,_patternWindows.boxHeight * 8,3,"scrollbar2",_patternWindows.boxHeight,0); + } + } + + private function onDecorItemsLoaded(param1:int, param2:Array, param3:Array) : void + { + if(_playerWall) + { + _wallDecorItemIds = param2; + onDecorMouseDown(null); + } + } + + private function onMasterpieceFrameItemsLoaded(param1:int, param2:Array, param3:Array) : void + { + if(_playerWall) + { + _masterpieceFrameIds = param2; + } + } + + private function onPatternLoaded(param1:MovieClip) : void + { + var _loc2_:int = 0; + if(_playerWall) + { + param1 = MovieClip(param1.getChildAt(0)).swatchBtn.pattern; + _patternIconIds = new Array(param1.currentLabels.length); + _loc2_ = 0; + while(_loc2_ < param1.currentLabels.length) + { + _patternIconIds[_loc2_] = 3983; + _loc2_++; + } + setupPatterns(); + } + } + + private function onSendMessage() : void + { + var _loc2_:Avatar = null; + var _loc1_:PostMessage = null; + if(!_playerWall.postBtn.isGray && !_playerWall.replyBtn.isGray) + { + KeepAlive.restartTimeLeftTimer(); + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + _playerWall.speedChatBtn.activateGrayState(false); + _playerWall.messageTxtCont.txtColorCont.charCounter.text = "0/" + _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars; + _loc2_ = AvatarManager.playerAvatar; + _loc1_ = new PostMessage("0",_playerWall.messageTxtCont.txtColorCont.messageTxt.text,gMainFrame.clientInfo.dbUserId,gMainFrame.userInfo.myUserName,gMainFrame.userInfo.userNameModerated,_currPatternId,_myCurrColorId,new Date().valueOf(),false,_loc2_.avTypeId,_loc2_.colors,_loc2_.inUseEyeId,_loc2_.inUsePatternId,LocalizationManager.currentLanguage,_loc2_.customAvId,_currReplyPost != null ? _currReplyPost.parentOrMyPostMessageId : "",gMainFrame.userInfo.myUUID,false); + PlayerWallXtCommManager.sendPutToPlayerWall(_owner,_loc1_,_wallParameters,onMessageSent); + } + else if(!_canWrite) + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(23230)); + } + } + + private function onMessageSent(param1:Boolean, param2:PostMessage, param3:int, param4:int, param5:String = "") : void + { + if(_playerWall) + { + if(param1) + { + _playerWall.noPostCont.visible = _inbox.length == 0; + } + else + { + if(param3 > 4 && param3 != 7) + { + FacilitatorXtCommManager.showContextualWarningPopup(param4); + } + else if(param3 == -1) + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(22628)); + } + else if(param5) + { + if(param5 == "token") + { + PlayerWallXtCommManager.sendWallTokenRequest(_owner,PlayerWallXtCommManager.ContinueCommandAfterTokenRequest,{ + "cmd":"PUT", + "username":_owner, + "msgToPost":param2, + "callback":onMessageSent + },true,true); + } + else if(param5 == "unavailable") + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(22625)); + } + } + else + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(22628)); + } + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + } + _currReplyPost = null; + _playerWall.replyBtn.visible = false; + _playerWall.cancelBtn.visible = false; + _playerWall.replyToTip.visible = false; + if(_predictiveTextManager) + { + _predictiveTextManager.resetTreeSearch(); + } + else + { + _playerWall.messageTxtCont.txtColorCont.messageTxt.text = LocalizationManager.translateIdOnly(23140); + } + _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha = 0.5; + } + } + + private function onFirstTimeGet(param1:Boolean) : void + { + if(_playerWall) + { + KeepAlive.restartTimeLeftTimer(); + if(param1) + { + setupWallCustomizePopup(); + setupWallDecorItems(); + setupMasterpieces(); + setupStickers(); + setupMessageEntry(); + setupNotificationsPopup(); + setupLikes(); + setupViews(); + setupSettingsPopup(false,_privacyId); + onSettingsChoose(null); + addEventListeners(); + setupSafeChat(); + setupPatterns(); + setupColors(); + setupEmotePopup(); + } + } + } + + private function onPrivacySetResponse(param1:Boolean, param2:int) : void + { + if(_playerWall) + { + if(param1) + { + _privacyId = param2; + } + else + { + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(14774)); + } + } + } + + private function checkShouldCompleteSuggestion(param1:String, param2:Boolean = false, param3:Boolean = false, param4:Function = null) : void + { + checkShouldCompleteSuggestionWork(param1,param2,param3,param4); + } + + private function checkShouldCompleteSuggestionWork(param1:String, param2:Boolean, param3:Boolean, param4:Function) : void + { + var _loc6_:TextField = null; + var _loc5_:TextFormat = null; + if(_playerWall) + { + if(param2) + { + if(_playerWall.messageTxtCont.txtColorCont.messageTxt.length > 0) + { + _playerWall.postBtn.activateGrayState(!_predictiveTextManager.isValid()); + _playerWall.replyBtn.activateGrayState(!_predictiveTextManager.isValid()); + } + else + { + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + } + return; + } + _loc6_ = new TextField(); + _loc5_ = _playerWall.messageTxtCont.txtColorCont.messageTxt.getTextFormat(); + _loc6_.text = _playerWall.messageTxtCont.txtColorCont.messageTxt.text + param1; + _loc6_.setTextFormat(_loc5_); + if(_loc6_.length > _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars) + { + if(param4 != null) + { + param4(param1,param3,false); + } + } + else if(param4 != null) + { + param4(param1,param3,true); + } + } + } + + private function onDecorIconsLoaded(param1:int, param2:Array, param3:Array) : void + { + if(_playerWall) + { + _wallDecorIconIds = param2; + setupCustomizationWindows(0); + } + } + + private function onMessagePatternLoaded(param1:MovieClip) : void + { + if(_playerWall && _messagePatternWindow) + { + _messagePatternLoaded = true; + if(_hasLoadedDecor) + { + displayLoadedWall(); + } + } + } + + private function onStickerIconsLoaded(param1:int, param2:Array, param3:Array) : void + { + if(_playerWall) + { + _stickerIconIds = param2; + setupCustomizationWindows(1); + } + } + + private function onPhotoSave(param1:Boolean, param2:Object) : void + { + if(param1) + { + setupAvatarAndPetPhoto(true); + } + else + { + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(30733)); + } + } + + private function onSetStatusResponse(param1:Boolean, param2:Object) : void + { + if(param1) + { + _currWallDecor.postStatus.mouse.mouse.statusTxt.txt.text = _wallParameters.tag; + } + else + { + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(30733)); + } + } + + private function onWallMenuParametersSet(param1:Boolean, param2:Object) : void + { + _mediaHelper = new MediaHelper(); + _mediaHelper.init(_wallDecorItemIds[_currDecorIndex],onWallDecorItemLoaded); + if(!param1) + { + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(30733)); + } + } + + private function onResourceArrayGet(param1:Boolean, param2:Boolean, param3:int, param4:Object) : void + { + _playerWall.likeBtn.activateLoadingState(false); + if(param1) + { + _playerWall.likeBtn.setTextInLayer(Utility.convertNumberToString(param3),"numTxt"); + _playerWall.likeCount = param3; + if(param2) + { + _playerWall.likeBtn.upToDownState(); + _playerWall.likeBtn.removeEventListener("mouseDown",onLikeBtn); + _playerWall.likeBtn.mouseChildren = false; + _playerWall.likeBtn.mouseEnabled = false; + } + _playerWall.likeBtn.visible = true; + } + else + { + _playerWall.likeBtn.setTextInLayer(Utility.convertNumberToString(0),"numTxt"); + } + } + + private function onCounterIncrement(param1:Boolean) : void + { + if(param1) + { + if(_playerWall) + { + _wallParameters.visits++; + LocalizationManager.translateIdAndInsert(_playerWall.viewCount,30488,Utility.convertNumberToString(_wallParameters.visits)); + } + } + } + + private function onAvatarLoaded(param1:LayerAnim, param2:int) : void + { + var _loc3_:Matrix = null; + _photoAvatarView.visible = true; + if(_wallParameters.pb.avatar.flip != null && _wallParameters.pb.avatar.flip == 1) + { + _loc3_ = _photoAvatarView.transform.matrix; + _loc3_.scale(-1,1); + _photoAvatarView.transform.matrix = _loc3_; + } + if(Utility.isAir(_photoAvatar.enviroTypeFlag)) + { + if(_photoAvatar.avTypeId == 49) + { + _photoAvatarView.y = -10; + } + else + { + _photoAvatarView.y = -50; + } + } + else + { + _photoAvatarView.y = -60; + } + _photoAvatarView.x = -75; + _currWallDecor.photoCont.itemWindow.charBox.addChild(_photoAvatarView); + } + + private function onPetLoaded(param1:MovieClip, param2:GuiPet) : void + { + var _loc3_:Matrix = null; + _photoPet.scaleX = _photoPet.scaleY = 0.75; + _photoPet.y = 15; + if(_wallParameters.pb.pet.flip == null || _wallParameters.pb.pet.flip == 0 || _wallParameters.pb.pet.flip == 3) + { + _loc3_ = _photoPet.transform.matrix; + _loc3_.scale(-1,1); + _photoPet.transform.matrix = _loc3_; + } + if(_photoPet.isGround()) + { + if(_wallParameters.pb.pet.flip != null && _wallParameters.pb.pet.flip < 2) + { + _currWallDecor.photoCont.itemWindow.itemWindowPet2L.addChild(_photoPet); + } + else + { + _currWallDecor.photoCont.itemWindow.itemWindowPet2R.addChild(_photoPet); + } + } + else if(_wallParameters.pb.pet.flip != null && _wallParameters.pb.pet.flip < 2) + { + _currWallDecor.photoCont.itemWindow.itemWindowPet1L.addChild(_photoPet); + } + else + { + _currWallDecor.photoCont.itemWindow.itemWindowPet1R.addChild(_photoPet); + } + } + + private function onBackgroundPhotoLoaded(param1:MovieClip) : void + { + _photoBackground = MovieClip(param1.getChildAt(0)); + setupAvatarAndPetPhoto(true); + } + + private function onTextChanged(param1:Event) : void + { + if(_playerWall && _predictiveTextManager) + { + _predictiveTextManager.onTextFieldChanged(param1); + } + } + + private function keyDownListener(param1:KeyboardEvent) : void + { + if(_predictiveTextManager) + { + if(_playerWall.messageTxtCont.txtColorCont.messageTxt.alpha != 1) + { + _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha = 1; + _playerWall.messageTxtCont.txtColorCont.messageTxt.text = ""; + } + if(_predictiveTextManager) + { + _predictiveTextManager.onKeyDown(param1); + setTimeout(updateCharCount,41.666666666666664); + } + } + else if(!_playerWall.chatTree.visible) + { + SafeChatManager.openSafeChat(false,_playerWall.chatTree); + new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(14713)); + } + } + + private function updateCharCount() : void + { + if(_playerWall) + { + _playerWall.messageTxtCont.txtColorCont.charCounter.visible = true; + _playerWall.messageTxtCont.txtColorCont.charCounter.text = _playerWall.messageTxtCont.txtColorCont.messageTxt.text.length + "/" + _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars; + if(_playerWall.messageTxtCont.txtColorCont.messageTxt.length > 0) + { + _playerWall.postBtn.activateGrayState(!_predictiveTextManager.isValid()); + _playerWall.replyBtn.activateGrayState(!_predictiveTextManager.isValid()); + } + else + { + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + } + } + } + + private function onSettingsClose(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_wallSettingsRadioBtns.selected != _privacyId) + { + KeepAlive.restartTimeLeftTimer(); + PlayerWallXtCommManager.sendSetWallSettingsRequest(_wallSettingsRadioBtns.selected,onPrivacySetResponse); + } + onSettingsBtn(param1); + } + + private function onSettingsChoose(param1:MouseEvent) : void + { + if(param1) + { + param1.stopPropagation(); + } + _playerWall.settingsBtn.gotoAndStop(_wallSettingsRadioBtns.selected + 1); + if(_playerWall.settingsPopup.visible) + { + _playerWall.settingsBtn[_playerWall.settingsBtn.currentFrameLabel + "Btn"].upToDownState(); + } + } + + private function onWallMenuClose(param1:MouseEvent) : void + { + var _loc2_:Object = null; + if(param1) + { + param1.stopPropagation(); + } + _playerWall.wallCustomize.visible = false; + if(param1) + { + _loc2_ = checkForWallParameterChanges(); + if(_loc2_ != null) + { + PlayerWallXtCommManager.sendSetWallParametersRequest(_wallParameters,_loc2_,onWallMenuParametersSet); + } + } + if(_wallCustomizeWindows) + { + _wallCustomizeWindows.destroy(); + _wallCustomizeWindows = null; + } + } + + private function checkForWallParameterChanges() : Object + { + var _loc17_:Boolean = false; + var _loc7_:Boolean = false; + var _loc13_:Object = null; + var _loc8_:int = 0; + var _loc11_:Object = null; + var _loc16_:Array = null; + var _loc20_:Array = null; + var _loc19_:Object = null; + var _loc3_:Object = null; + var _loc4_:Array = null; + var _loc14_:Array = null; + var _loc9_:int = 0; + var _loc15_:int = 0; + var _loc6_:Object = null; + var _loc5_:Object = null; + var _loc2_:Array = null; + var _loc1_:Array = null; + var _loc10_:Object = {}; + var _loc12_:Object = PlayerWallManager.myWallParameters; + for(var _loc18_:Object in _wallParameters) + { + _loc13_ = _wallParameters[_loc18_]; + _loc7_ = false; + if(_loc12_[_loc18_] != null) + { + _loc11_ = _loc12_[_loc18_]; + switch(_loc18_) + { + case "bg": + if(int(_loc13_) != int(_loc11_)) + { + _loc7_ = true; + _loc10_.bg = _loc13_; + } + break; + case "visits": + if(int(_loc13_) != int(_loc11_)) + { + _loc7_ = true; + _loc10_.visits = _loc13_; + } + break; + case "stk": + _loc16_ = _loc13_ as Array; + _loc20_ = _loc11_ as Array; + if(_loc16_ == null || _loc20_ == null || _loc16_.length != _loc20_.length) + { + _loc7_ = true; + } + else + { + _loc8_ = 0; + while(_loc8_ < _loc16_.length) + { + if(!(_loc16_[_loc8_] != null && _loc20_[_loc8_] != null)) + { + _loc7_ = true; + break; + } + if(_loc16_[_loc8_].id != _loc20_[_loc8_].id || _loc16_[_loc8_].pos != _loc20_[_loc8_].pos) + { + _loc7_ = true; + break; + } + _loc8_++; + } + } + if(_loc7_) + { + _loc10_.stk = _loc16_; + } + break; + case "tag": + if(String(_loc13_) != String(_loc11_)) + { + _loc7_ = true; + _loc10_.tag = _loc13_; + } + break; + case "pb": + _loc19_ = _loc13_.avatar; + _loc3_ = _loc11_.avatar; + _loc4_ = _loc13_.items; + _loc14_ = _loc11_.items; + _loc9_ = int(_loc13_.bgid); + _loc15_ = int(_loc11_.bgid); + _loc6_ = _loc13_.pet; + _loc5_ = _loc11_.pet; + if(_loc19_ != null) + { + if(_loc3_ == null) + { + _loc7_ = true; + } + else if(_loc19_ != null && (_loc19_.color1 != _loc3_.color1 || _loc19_.color2 != _loc3_.color2 || _loc19_.color3 != _loc3_.color3 || _loc19_.eyes != _loc3_.eyes || _loc19_.flip != _loc3_.flip || _loc19_.id != _loc3_.id || _loc19_.pattern != _loc3_.pattern)) + { + _loc7_ = true; + } + else if(_loc9_ != _loc15_) + { + _loc7_ = true; + } + else if(_loc6_ == null && _loc5_ != null || _loc5_ == null && _loc6_ != null) + { + _loc7_ = true; + } + else if(_loc6_ != null && _loc5_ != null && (_loc6_.ebits != _loc5_.ebits || _loc6_.flip != _loc5_.flip || _loc6_.id != _loc5_.id || _loc6_.lbits != _loc5_.lbits || _loc6_.ubits != _loc5_.ubits)) + { + _loc7_ = true; + } + else if(_loc4_ == null && _loc14_ != null || _loc4_ != null && _loc14_ == null) + { + _loc7_ = true; + } + else if(_loc4_ != null && _loc14_ != null) + { + if(_loc4_.length != _loc14_.length) + { + _loc7_ = true; + } + else + { + _loc8_ = 0; + while(_loc8_ < _loc4_.length) + { + if(_loc4_[_loc8_].id != _loc14_[_loc8_].id || _loc4_[_loc8_].color != _loc14_[_loc8_].color) + { + _loc7_ = true; + break; + } + _loc8_++; + } + } + } + } + if(_loc7_) + { + _loc10_.pb = { + "avatar":_loc19_, + "bgid":_loc9_, + "pet":_loc6_, + "items":_loc4_ + }; + } + break; + case "mp": + _loc2_ = _loc13_ as Array; + _loc1_ = _loc11_ as Array; + if(_loc2_ == null || _loc1_ == null) + { + _loc7_ = true; + } + if(!_loc7_) + { + _loc8_ = 0; + while(_loc8_ < _loc2_.length) + { + if(_loc2_[_loc8_] == null || _loc2_[_loc8_].sid > 2) + { + _loc2_.splice(_loc8_,1); + _loc8_--; + } + _loc8_++; + } + if(_loc2_.length != _loc1_.length) + { + _loc7_ = true; + } + else + { + _loc8_ = 0; + while(_loc8_ < _loc2_.length) + { + if(!(_loc2_[_loc8_] != null && _loc1_[_loc8_] != null)) + { + _loc7_ = true; + break; + } + if(_loc2_[_loc8_].iid != _loc1_[_loc8_].iid || _loc2_[_loc8_].sid != _loc1_[_loc8_].sid) + { + _loc7_ = true; + break; + } + _loc8_++; + } + } + } + if(_loc7_) + { + _loc10_.mp = _loc2_; + } + } + } + else + { + _loc7_ = true; + _loc10_[_loc18_] = _loc13_; + } + if(_loc7_ == true) + { + _loc17_ = true; + } + } + return _loc17_ ? _loc10_ : null; + } + + private function onCreateAMasterpieceBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + onWallMenuClose(param1); + _masterpieceLaunchObj = {"typeDefId":51}; + if(!MinigameManager.minigameInfoCache.getMinigameInfo(_masterpieceLaunchObj.typeDefId)) + { + DarkenManager.showLoadingSpiral(true); + MinigameXtCommManager.sendMinigameInfoRequest([_masterpieceLaunchObj.typeDefId],false,onMinigameInfoResponse); + } + else + { + MinigameManager.handleGameClick(_masterpieceLaunchObj,null,true); + } + } + + private function onMinigameInfoResponse() : void + { + DarkenManager.showLoadingSpiral(false); + MinigameManager.handleGameClick(_masterpieceLaunchObj,null,true); + } + + private function onChatTreeClose(param1:String, param2:String) : void + { + if(_predictiveTextManager) + { + _predictiveTextManager.resetTreeSearch(); + } + _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha = 1; + _playerWall.messageTxtCont.txtColorCont.charCounter.visible = false; + _playerWall.messageTxtCont.txtColorCont.charCounter.text = "0/" + _playerWall.messageTxtCont.txtColorCont.messageTxt.maxChars; + _playerWall.messageTxtCont.txtColorCont.messageTxt.text = param1; + _msgCode = param2; + _playerWall.postBtn.activateGrayState(false); + _playerWall.replyBtn.activateGrayState(false); + SafeChatManager.closeSafeChat(_playerWall.chatTree); + onSendMessage(); + _playerWall.speedChatBtn.downToUpState(); + _playerWall.postBtn.activateGrayState(true); + _playerWall.replyBtn.activateGrayState(true); + if(_predictiveTextManager) + { + _predictiveTextManager.resetTreeSearch(); + } + _playerWall.messageTxtCont.txtColorCont.messageTxt.text = ""; + updateCharCount(); + } + + private function msgTextDownHandler(param1:MouseEvent) : void + { + if(param1.currentTarget == _playerWall.statusTxt) + { + _playerWall.statusTxt.setSelection(_playerWall.statusTxt.length,_playerWall.statusTxt.length); + _playerWall.postStatusBtn.visible = true; + } + else + { + closeAllLowerPopups(); + if(!Utility.canChat()) + { + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14713)); + gMainFrame.stage.focus = null; + } + else if(!_playerWall.speedChatBtn.isGray && (gMainFrame.userInfo.sgChatType == 0 || gMainFrame.userInfo.sgChatType == 3)) + { + gMainFrame.stage.focus = null; + if(gMainFrame.userInfo.sgChatType != gMainFrame.userInfo.sgChatTypeNonDegraded && !_hasShownDegradationPopup) + { + new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(18406),true,openSafeChatAfterOk); + } + else + { + onSafeChatBtn(null); + } + } + else if(_playerWall.messageTxtCont.txtColorCont.messageTxt.alpha != 1) + { + _playerWall.messageTxtCont.txtColorCont.messageTxt.alpha = 1; + _predictiveTextManager.resetTreeSearch(); + } + } + } + + private function openSafeChatAfterOk(param1:MouseEvent) : void + { + param1.stopPropagation(); + _hasShownDegradationPopup = true; + SBOkPopup.destroyInParentChain(param1.target.parent); + onSafeChatBtn(null); + } + + private function onTextOver(param1:MouseEvent) : void + { + param1.stopPropagation(); + CursorManager.showICursor(true); + } + + private function onTextOut(param1:MouseEvent) : void + { + param1.stopPropagation(); + CursorManager.showICursor(false); + } + + private function onPopup(param1:MouseEvent) : void + { + param1.stopPropagation(); + } + + private function onMessageTextDown(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_predictiveTextManager) + { + _predictiveTextManager.onTextClick(); + } + } + + private function onClearPostsBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!param1.currentTarget.isGray) + { + new SBOkCancelPopup(_guiLayer,LocalizationManager.translateIdOnly(24689),true,onConfirmClear); + } + } + + private function onConfirmClear(param1:Object) : void + { + if(param1.status) + { + _playerWall.contentLoader.visible = true; + PlayerWallXtCommManager.sendClearAllMessages(null); + } + } + + private function onReplyBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_currReplyPost != null) + { + onSendMessage(); + } + } + + private function onCancelBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + _currReplyPost = null; + _playerWall.replyBtn.visible = false; + _playerWall.cancelBtn.visible = false; + _playerWall.replyToTip.visible = false; + } + + private function onNotificationsBtn(param1:MouseEvent) : void + { + var _loc2_:int = 0; + var _loc3_:Array = null; + var _loc4_:int = 0; + param1.stopPropagation(); + _playerWall.wallNotificationCont.visible = !_playerWall.wallNotificationCont.visible; + if(_playerWall.wallNotificationCont.visible) + { + if(_notificationWindows) + { + _playerWall.wallNotificationCont.itemWindow.removeChild(_notificationWindows); + _notificationWindows.destroy(); + } + _loc3_ = []; + for each(var _loc5_:PostMessage in _notifications) + { + _loc3_.push(_loc5_); + if(!_loc5_.isRead) + { + _loc2_++; + } + } + _playerWall.notificationBtn.numIcon.countTxt.text = String(_loc2_); + _playerWall.notificationBtn.numIcon.visible = _loc2_ > 0; + _notificationWindows = new WindowAndScrollbarGenerator(); + _notificationWindows.init(_playerWall.wallNotificationCont.itemWindow.width,_playerWall.wallNotificationCont.itemWindow.height,0,0,1,6,0,0,2,0,0,ItemWindowNotification,_loc3_,"",0,{ + "mouseDown":onNotificationDown, + "mouseOver":null, + "mouseOut":null + },null,null,true,false,false); + _playerWall.wallNotificationCont.itemWindow.addChild(_notificationWindows); + } + else + { + if(_notificationWindows) + { + _playerWall.wallNotificationCont.itemWindow.removeChild(_notificationWindows); + _notificationWindows.destroy(); + _notificationWindows = null; + } + if(_notifications) + { + _loc4_ = 0; + while(_loc4_ < _notifications.length) + { + if(!_notifications[_loc4_].isRead) + { + _loc2_++; + } + _loc4_++; + } + } + _playerWall.notificationBtn.numIcon.countTxt.text = String(_loc2_); + _playerWall.notificationBtn.numIcon.visible = _loc2_ > 0; + } + } + + private function onNotificationClose(param1:MouseEvent) : void + { + var _loc3_:ItemWindowNotification = null; + var _loc2_:Array = null; + var _loc4_:int = 0; + param1.stopPropagation(); + _playerWall.notificationBtn.downToUpState(); + _playerWall.wallNotificationCont.visible = false; + if(_notificationWindows) + { + _loc2_ = []; + _loc4_ = 0; + while(_loc4_ < _notificationWindows.mediaWindows.length) + { + _loc3_ = _notificationWindows.mediaWindows[_loc4_]; + if(_loc3_ && !_loc3_.isRead) + { + _loc2_.push(_loc3_.parentOrCurrMessageId); + } + _loc4_++; + } + if(_loc2_.length > 0) + { + PlayerWallXtCommManager.sendAcknowledgeNotificationRequest(_loc2_,null); + } + _playerWall.wallNotificationCont.itemWindow.removeChild(_notificationWindows); + _notificationWindows.destroy(); + _notificationWindows = null; + } + } + + private function onPhotoCont(param1:MouseEvent) : void + { + param1.stopPropagation(); + GuiManager.openPhotoBooth(onPhotoBoothSave,true); + } + + private function onPhotoBoothSave(param1:int, param2:int, param3:int) : void + { + var _loc10_:Avatar = null; + var _loc13_:AvatarInfo = null; + var _loc8_:Object = null; + var _loc12_:Array = null; + var _loc14_:Object = null; + var _loc11_:AccItemCollection = null; + var _loc5_:int = 0; + var _loc9_:Object = null; + var _loc4_:Boolean = false; + var _loc6_:int = 0; + var _loc7_:Object = null; + if(param3 != -1) + { + _loc10_ = AvatarManager.playerAvatar; + _loc13_ = gMainFrame.userInfo.playerAvatarInfo; + _loc8_ = { + "color1":_loc13_.colors[0], + "color2":_loc13_.colors[1], + "color3":_loc13_.colors[2], + "pattern":_loc10_.inUsePatternId, + "id":_loc10_.avTypeId, + "eyes":_loc10_.inUseEyeId + }; + _loc12_ = null; + _loc14_ = null; + _loc11_ = _loc10_.accShownItemsWithoutBodMods; + if(_loc11_.length > 0) + { + _loc12_ = []; + _loc5_ = 0; + while(_loc5_ < _loc11_.length) + { + _loc12_.push({ + "id":_loc11_.getAccItem(_loc5_).defId, + "color":_loc11_.getAccItem(_loc5_).color + }); + _loc5_++; + } + } + if(PetManager.myActivePet != null) + { + _loc9_ = PetManager.myActivePet; + _loc14_ = { + "ts":_loc9_.createdTs, + "lbits":_loc9_.lBits, + "ubits":_loc9_.uBits, + "ebits":_loc9_.eBits, + "id":_loc9_.defId, + "flip":param2 + }; + } + _loc4_ = false; + if(_wallParameters.pb) + { + if(_wallParameters.pb.avatar == null) + { + _loc4_ = true; + } + else if(_wallParameters.pb.avatar.flip == null || param1 != _wallParameters.pb.avatar.flip || (_wallParameters.pb.bgid == null || param3 != _wallParameters.pb.bgid)) + { + _loc4_ = true; + } + else if(_loc8_.color1 != _wallParameters.pb.avatar.color1 || _loc8_.color2 != _wallParameters.pb.avatar.color2 || _loc8_.color3 != _wallParameters.pb.avatar.color3 || _loc8_.pattern != _wallParameters.pb.avatar.pattern || _loc8_.id != _wallParameters.pb.avatar.id || _loc8_.eyes != _wallParameters.pb.avatar.eyes) + { + _loc4_ = true; + } + else if(_loc12_ == null && _wallParameters.pb.items != null || _loc12_ != null && _wallParameters.pb.items == null || _loc12_ != null && _wallParameters.pb.items != null && _loc12_.length != _wallParameters.pb.items.length) + { + _loc4_ = true; + } + else if(_loc12_ != null) + { + _loc6_ = 0; + while(_loc6_ < _loc12_.length) + { + if(_loc12_[_loc6_].id != _wallParameters.pb.items[_loc6_].id || _loc12_[_loc6_].color != _wallParameters.pb.items[_loc6_].color) + { + _loc4_ = true; + break; + } + _loc6_++; + } + } + if(_loc4_ == false) + { + if(_loc14_ == null && _wallParameters.pb.pet != null || _loc14_ != null && _wallParameters.pb.pet == null) + { + _loc4_ = true; + } + else if(_loc14_.lbits != _wallParameters.pb.pet.lbits || _loc14_.ubits != _wallParameters.pb.pet.ubits || _loc14_.ebits != _wallParameters.pb.pet.ebits || _loc14_.id != _wallParameters.pb.pet.id || (_wallParameters.pb.pet.flip == null || param2 != _wallParameters.pb.pet.flip)) + { + _loc4_ = true; + } + } + } + else + { + _loc4_ = true; + } + if(_loc4_) + { + _wallParameters.pb = {}; + _wallParameters.pb.avatar = { + "color1":_loc13_.colors[0], + "color2":_loc13_.colors[1], + "color3":_loc13_.colors[2], + "pattern":_loc10_.inUsePatternId, + "id":_loc10_.avTypeId, + "eyes":_loc10_.inUseEyeId, + "flip":param1 + }; + _wallParameters.pb.items = _loc12_; + if(_loc14_ != null) + { + _wallParameters.pb.pet = _loc14_; + } + _wallParameters.pb.bgid = param3; + _loc7_ = checkForWallParameterChanges(); + if(_loc7_ != null) + { + PlayerWallXtCommManager.sendSetWallParametersRequest(_wallParameters,_loc7_,onPhotoSave); + } + } + } + } + + private function onPostStatus(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_inputPopup == null) + { + _inputPopup = new InputPopup(onInputPopupClose); + } + } + + private function onInputPopupClose(param1:String) : void + { + var _loc2_:Object = null; + if(param1 != null && param1.length > 0) + { + if(_wallParameters.tag == null || _wallParameters.tag != param1) + { + _wallParameters.tag = param1; + _wallParameters.langId = LocalizationManager.currentLanguage; + _loc2_ = checkForWallParameterChanges(); + if(_loc2_ != null) + { + PlayerWallXtCommManager.sendSetWallParametersRequest(_wallParameters,_loc2_,onSetStatusResponse); + } + } + } + _inputPopup.destroy(); + _inputPopup = null; + } + + private function onLikeBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!param1.currentTarget.loadingCont.visible) + { + if(param1.currentTarget.down) + { + param1.currentTarget.downToUpState(); + param1.currentTarget.activateLoadingState(true); + ResourceArrayXtCommManager.sendResourceArrayPutRequest("jammerwall",_ownerUUID,"",0,0,"",onResourceArrayPut); + } + } + } + + private function onNotificationDown(param1:MouseEvent) : void + { + var _loc2_:ItemWindowNotification = ItemWindowNotification(param1.currentTarget); + if(_loc2_ != null) + { + _isWallActive = false; + DarkenManager.showLoadingSpiral(true); + PlayerWallManager.openStrangersPlayerWall(_loc2_.senderUserName,_loc2_.moderatedUsername,_loc2_.senderUUID,_loc2_.messageId,true); + } + } + + private function onResourceArrayPut(param1:Boolean, param2:Object) : void + { + _playerWall.likeBtn.activateLoadingState(false); + if(param1) + { + _playerWall.likeBtn.upToDownState(); + _playerWall.likeBtn.removeEventListener("mouseDown",onLikeBtn); + _playerWall.likeBtn.mouseChildren = false; + _playerWall.likeBtn.mouseEnabled = false; + if("likeCount" in _playerWall) + { + _playerWall.likeCount++; + } + else + { + _playerWall.likeCount = 1; + } + _playerWall.likeBtn.setTextInLayer(Utility.convertNumberToString(_playerWall.likeCount),"numTxt"); + } + } + + private function onPostStatusOut(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!_isMyWall && _currWallDecor) + { + _currWallDecor.postStatus.mouse.mouse.reportBtn.visible = false; + } + } + + private function onPostStatusOver(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(!_isMyWall && _currWallDecor) + { + _currWallDecor.postStatus.mouse.mouse.reportBtn.visible = true; + } + } + + private function addEventListeners() : void + { + var _loc2_:MovieClip = null; + var _loc1_:int = 0; + if(_playerWall) + { + _playerWall.addEventListener("mouseDown",onPopup,false,0,true); + _playerWall.bx.addEventListener("mouseDown",onCloseBtn,false,0,true); + _playerWall.patternBtn.addEventListener("mouseDown",onPatternBtn,false,0,true); + _playerWall.colorBtn.addEventListener("mouseDown",onColorBtn,false,0,true); + _playerWall.emoteBtn.addEventListener("mouseDown",onEmoteBtn,false,0,true); + _playerWall.postBtn.addEventListener("mouseDown",onPostBtn,false,0,true); + _playerWall.settingsBtn.addEventListener("mouseDown",onSettingsBtn,false,0,true); + _playerWall.messageTxtCont.txtColorCont.messageTxt.addEventListener("mouseDown",onMessageTextDown,false,0,true); + _playerWall.speedChatBtn.addEventListener("mouseDown",onSafeChatBtn,false,0,true); + _playerWall.menuBtn.addEventListener("mouseDown",onMenuBtn,false,0,true); + _playerWall.ansBtnCont.addEventListener("mouseDown",onSuggestWordsBtn,false,0,true); + _playerWall.cleanUpBtn.addEventListener("mouseDown",onClearPostsBtn,false,0,true); + _playerWall.replyBtn.addEventListener("mouseDown",onReplyBtn,false,0,true); + _playerWall.cancelBtn.addEventListener("mouseDown",onCancelBtn,false,0,true); + _playerWall.notificationBtn.addEventListener("mouseDown",onNotificationsBtn,false,0,true); + _playerWall.likeBtn.addEventListener("mouseDown",onLikeBtn,false,0,true); + _updateTimer.addEventListener("timer",onTimerEvent,false,0,true); + if(!_canWrite) + { + _playerWall.messageEntryHolder.addEventListener("mouseDown",onMessageEntry,false,0,true); + } + _loc2_ = _playerWall.frame_0; + _loc1_ = 0; + while(_loc2_ != null) + { + _loc2_.addEventListener("mouseDown",onMasterpieceFrameDown,false,0,true); + _loc2_.addEventListener("mouseOver",onMasterpieceOrStickerFrameOver,false,0,true); + _loc2_.addEventListener("mouseOut",onMasterpieceOrStickerFrameOut,false,0,true); + _loc2_.glow.visible = false; + _loc1_++; + _loc2_ = _playerWall["frame_" + _loc1_]; + } + _loc2_ = _playerWall.sticker_0; + _loc1_ = 0; + while(_loc2_ != null) + { + _loc2_.addEventListener("mouseDown",onStickerFrameDown,false,0,true); + _loc2_.addEventListener("mouseOver",onMasterpieceOrStickerFrameOver,false,0,true); + _loc2_.addEventListener("mouseOut",onMasterpieceOrStickerFrameOut,false,0,true); + _loc2_.glow.visible = false; + _loc1_++; + _loc2_ = _playerWall["sticker_" + _loc1_]; + } + } + } + + private function removeEventListeners() : void + { + var _loc2_:MovieClip = null; + var _loc1_:int = 0; + if(_playerWall) + { + _playerWall.removeEventListener("mouseDown",onPopup); + _playerWall.bx.removeEventListener("mouseDown",onCloseBtn); + _playerWall.patternBtn.removeEventListener("mouseDown",onPatternBtn); + _playerWall.colorBtn.removeEventListener("mouseDown",onColorBtn); + _playerWall.emoteBtn.removeEventListener("mouseDown",onEmoteBtn); + _playerWall.postBtn.removeEventListener("mouseDown",onPostBtn); + _playerWall.settingsBtn.removeEventListener("mouseDown",onSettingsBtn); + _playerWall.messageTxtCont.txtColorCont.messageTxt.removeEventListener("mouseDown",onMessageTextDown); + _playerWall.speedChatBtn.removeEventListener("mouseDown",onSafeChatBtn); + _playerWall.menuBtn.removeEventListener("mouseDown",onMenuBtn); + _playerWall.ansBtnCont.removeEventListener("mouseDown",onSuggestWordsBtn); + _playerWall.cleanUpBtn.removeEventListener("mouseDown",onClearPostsBtn); + _playerWall.replyBtn.removeEventListener("mouseDown",onReplyBtn); + _playerWall.cancelBtn.removeEventListener("mouseDown",onCancelBtn); + _playerWall.notificationBtn.removeEventListener("mouseDown",onNotificationsBtn); + _playerWall.likeBtn.removeEventListener("mouseDown",onLikeBtn); + _updateTimer.removeEventListener("timer",onTimerEvent); + if(!_canWrite) + { + _playerWall.messageEntryHolder.removeEventListener("mouseDown",onMessageEntry); + } + _loc2_ = _playerWall.frame_0; + _loc1_ = 0; + while(_loc2_ != null) + { + _loc2_.removeEventListener("mouseDown",onStickerFrameDown); + _loc2_.removeEventListener("mouseOver",onMasterpieceOrStickerFrameOver); + _loc2_.removeEventListener("mouseOut",onMasterpieceOrStickerFrameOut); + _loc1_++; + _loc2_ = _playerWall["frame_" + _loc1_]; + } + _loc2_ = _playerWall.sticker_0; + _loc1_ = 0; + while(_loc2_ != null) + { + _loc2_.removeEventListener("mouseDown",onMasterpieceFrameDown); + _loc2_.removeEventListener("mouseOver",onMasterpieceOrStickerFrameOver); + _loc2_.removeEventListener("mouseOut",onMasterpieceOrStickerFrameOut); + _loc1_++; + _loc2_ = _playerWall["sticker_" + _loc1_]; + } + } + } + } +} + diff --git a/swf-src/PlayerWallXtCommManager.as b/swf-src/PlayerWallXtCommManager.as new file mode 100644 index 0000000..4b7b7b1 --- /dev/null +++ b/swf-src/PlayerWallXtCommManager.as @@ -0,0 +1,853 @@ +package playerWall +{ + import buddy.BuddyManager; + import collection.IntItemCollection; + import com.sbi.client.SFEvent; + import com.sbi.debug.DebugUtility; + import flash.events.ErrorEvent; + import flash.events.Event; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.net.URLRequestHeader; + import gui.DarkenManager; + import gui.GuiManager; + import localization.LocalizationManager; + + public class PlayerWallXtCommManager + { + + private static var _requestor:URLLoader; + + private static var _deleteResponseCallback:Function; + + private static var _getResponseCallback:Function; + + private static var _putResponseCallback:Function; + + private static var _setSettingsResponseCallback:Function; + + private static var _getSettingsResponseCallback:Function; + + private static var _setParametersResponseCallback:Function; + + private static var _blockedMessagesCallback:Function; + + private static var _setBlockedMessageCallback:Function; + + private static var _wallTokenCallback:Function; + + private static var _checkResponseCallback:Function; + + private static var _sendClearAllMessagesCallback:Function; + + private static var _sendMasterpieceCallback:Function; + + private static var _setCounterIncrementResponseCallback:Function; + + private static var _sendAcknowledgeNotificationCallback:Function; + + private static var _wallTokenPassback:Object; + + private static var _setSettingsId:int; + + private static var _currentRequestUsername:String; + + private static var _messageToPost:PostMessage; + + private static var _currMessageuuid:String; + + private static var _setWallParameters:Object; + + private static var _messageToBeBlocked:String; + + private static var _wallTokenShouldShowFailure:Boolean; + + private static var _masterpieceInvIdsToRemove:IntItemCollection; + + private static var _setCounterIncrementWallOwner:String; + + private static var _sendAcknowledgeMessages:Array; + + private static var _isProcessingRequest:Boolean; + + private static var _currCommand:String; + + private static var _tokenFailures:int; + + private static var _isFromHudTimer:Boolean; + + // requests made while one was on its way, each with what its reply is + // read with ({request, state}), and that of the one on its way + private static var _waitingRequests:Array = []; + + private static var _sentRequestState:Object; + + public function PlayerWallXtCommManager() + { + super(); + } + + public static function init() : void + { + _requestor = new URLLoader(); + } + + public static function destroy() : void + { + } + + public static function sendWallTokenRequest(param1:String, param2:Function = null, param3:Object = null, param4:Boolean = true, param5:Boolean = false) : void + { + if(_tokenFailures < 2) + { + if(param5) + { + _tokenFailures = _tokenFailures + 1; + } + PlayerWallManager.setForWaitingOnWallResponse(true); + _wallTokenCallback = param2; + _wallTokenPassback = param3; + _wallTokenShouldShowFailure = param4; + gMainFrame.server.setXtObject_Str("wt",[param1]); + } + else + { + PlayerWallManager.closeOpenPlayerWallDueToTokenFailures(); + _tokenFailures = 0; + } + } + + public static function sendSetWallSettingsRequest(param1:int, param2:Function) : void + { + _setSettingsResponseCallback = param2; + _setSettingsId = param1; + gMainFrame.server.setXtObject_Str("wss",[param1]); + } + + public static function sendGetWallSettingsRequest(param1:String, param2:Function) : void + { + _getSettingsResponseCallback = param2; + gMainFrame.server.setXtObject_Str("wsg",[param1]); + } + + public static function sendSetWallParametersRequest(param1:Object, param2:Object, param3:Function) : void + { + _setParametersResponseCallback = param3; + _setWallParameters = param1; + gMainFrame.server.setXtObject_Str("wps",[JSON.stringify(param2)]); + } + + public static function sendSetWallCounterIncrementRequest(param1:String, param2:Function) : void + { + _setCounterIncrementResponseCallback = param2; + _setCounterIncrementWallOwner = param1; + gMainFrame.server.setXtObject_Str("wci",[param1]); + } + + public static function handleXtReply(param1:SFEvent) : void + { + var _loc3_:Array = null; + if(!param1.status) + { + DebugUtility.debugTrace("ERROR: PlayerWallXtCommManager handleXtReply was called with bad evt.status:" + param1.status); + return; + } + var _loc2_:Array = param1.obj; + switch(_loc2_[0]) + { + case "wt": + PlayerWallManager.handleTokenResponse(_loc2_,_wallTokenShouldShowFailure); + if(_wallTokenCallback != null) + { + if(_wallTokenPassback != null) + { + if(_wallTokenPassback.hasOwnProperty("data")) + { + _loc3_ = _wallTokenPassback.data; + switch(int(_loc3_.length) - 1) + { + case 0: + _wallTokenCallback(_loc3_[0],_loc2_[2] == "1"); + break; + case 1: + _wallTokenCallback(_loc3_[0],_loc3_[1],_loc2_[2] == "1"); + break; + case 2: + _wallTokenCallback(_loc3_[0],_loc3_[1],_loc3_[2],_loc2_[2] == "1"); + break; + case 3: + _wallTokenCallback(_loc3_[0],_loc3_[1],_loc3_[2],_loc3_[3],_loc2_[2] == "1"); + break; + case 4: + _wallTokenCallback(_loc3_[0],_loc3_[1],_loc3_[2],_loc3_[3],_loc3_[4],_loc2_[2] == "1"); + } + } + else + { + _wallTokenCallback(_wallTokenPassback,_loc2_[2] == "1"); + } + _wallTokenPassback = null; + } + else + { + _wallTokenCallback(_loc2_[2] == "1"); + } + _wallTokenCallback = null; + } + break; + case "wss": + PlayerWallManager.onPrivacyResponse(_loc2_[2] == "1",_setSettingsId); + if(_setSettingsResponseCallback != null) + { + _setSettingsResponseCallback(_loc2_[2] == "1",_setSettingsId); + _setSettingsResponseCallback = null; + } + break; + case "wsg": + if(_getSettingsResponseCallback != null) + { + _getSettingsResponseCallback(_loc2_[2]); + _getSettingsResponseCallback = null; + } + break; + case "wps": + setParametersResponse(_loc2_); + break; + case "wci": + PlayerWallManager.onWallCountIncrementResponse(_loc2_[2] == "1",_setCounterIncrementWallOwner); + if(_setCounterIncrementResponseCallback != null) + { + _setCounterIncrementResponseCallback(_loc2_[2]); + _setCounterIncrementResponseCallback = null; + } + } + } + + public static function sendCheckPlayerWall(param1:String, param2:Function, param3:Boolean = false, param4:Boolean = true) : void + { + var _loc5_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()]; + var _loc6_:String = null; + if(_loc5_) + { + _loc6_ = _loc5_.token; + } + _currentRequestUsername = param1; + _checkResponseCallback = param2; + _isFromHudTimer = param3; + if(_loc6_) + { + sendServiceRequest({ + "cmd":"CHK", + "t":_loc6_ + }); + } + else + { + sendWallTokenRequest(param1,sendCheckPlayerWall,{"data":[param1,param2,param3]},!param3,!param4); + } + } + + public static function sendPutToPlayerWall(param1:String, param2:PostMessage, param3:Object, param4:Function, param5:Boolean = true) : void + { + var _loc6_:Object = null; + var _loc7_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()]; + var _loc8_:String = null; + if(_loc7_) + { + _loc8_ = _loc7_.token; + } + _messageToPost = param2; + _currentRequestUsername = param1; + _putResponseCallback = param4; + if(_loc8_) + { + _loc6_ = { + "cmd":"PUT", + "t":_loc8_, + "sid":param2.senderDbId, + "s":param2.patternId, + "c":param2.colorId, + "m":param2.message, + "ai":param2.avtDefId, + "ac":param2.avtColors, + "ae":param2.avtEyeDefId, + "ap":param2.avtPatternDefId, + "aci":param2.avtCustomId, + "l":param2.localizationId, + "p":param3 + }; + if(param2.parentMessageId != null && param2.parentMessageId.length > 0) + { + _loc6_.pp = param2.parentMessageId; + } + sendServiceRequest(_loc6_); + } + else + { + sendWallTokenRequest(param1,sendPutToPlayerWall,{"data":[param1,param4,param2,param3]},true,!param5); + } + } + + public static function sendDeleteFromPlayerWall(param1:String, param2:String, param3:Function, param4:Boolean = true) : void + { + var _loc5_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()]; + var _loc6_:String = null; + if(_loc5_) + { + _loc6_ = _loc5_.token; + } + _currentRequestUsername = param1; + _currMessageuuid = param2; + _deleteResponseCallback = param3; + if(_loc6_) + { + sendServiceRequest({ + "cmd":"DEL", + "t":_loc6_, + "x":param2 + }); + } + else + { + sendWallTokenRequest(param1,sendDeleteFromPlayerWall,{"data":[param1,param3,param2]},true,!param4); + } + } + + public static function sendGetFromPlayerWall(param1:String, param2:Function, param3:Boolean = false, param4:Boolean = true) : void + { + var _loc5_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()]; + var _loc6_:String = null; + if(_loc5_) + { + _loc6_ = _loc5_.token; + } + _currentRequestUsername = param1; + _getResponseCallback = param2; + _isFromHudTimer = param3; + if(_loc6_) + { + sendServiceRequest({ + "cmd":"GET", + "t":_loc6_ + }); + } + else + { + sendWallTokenRequest(param1,sendGetFromPlayerWall,{"data":[param1,param2,param3]},true,!param4); + } + } + + public static function sendGetBlockedMessages(param1:Function, param2:Boolean = true) : void + { + _blockedMessagesCallback = param1; + var _loc3_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()]; + var _loc4_:String = null; + if(_loc3_) + { + _loc4_ = _loc3_.token; + } + _currentRequestUsername = gMainFrame.userInfo.myUserName; + if(_loc4_) + { + sendServiceRequest({ + "cmd":"GMB", + "t":_loc4_ + }); + } + else + { + sendWallTokenRequest(_currentRequestUsername,sendGetBlockedMessages,{"callback":param1},true,!param2); + } + } + + public static function sendSetBlockedMessage(param1:String, param2:Function, param3:Boolean = true) : void + { + _setBlockedMessageCallback = param2; + _messageToBeBlocked = param1; + var _loc4_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()]; + var _loc5_:String = null; + if(_loc4_) + { + _loc5_ = _loc4_.token; + } + _currentRequestUsername = gMainFrame.userInfo.myUserName; + if(_loc5_) + { + sendServiceRequest({ + "cmd":"AMB", + "t":_loc5_, + "x":param1 + }); + } + else + { + sendWallTokenRequest(_currentRequestUsername,sendSetBlockedMessage,{"data":[param2,param1]},true,!param3); + } + } + + public static function sendClearAllMessages(param1:Function, param2:Boolean = true) : void + { + _sendClearAllMessagesCallback = param1; + var _loc3_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()]; + var _loc4_:String = null; + if(_loc3_) + { + _loc4_ = _loc3_.token; + } + _currentRequestUsername = gMainFrame.userInfo.myUserName; + if(_loc4_) + { + sendServiceRequest({ + "cmd":"CLW", + "t":_loc4_ + }); + } + else + { + sendWallTokenRequest(_currentRequestUsername,sendClearAllMessages,{"callback":param1},true,!param2); + } + } + + public static function sendRemoveMasterpiece(param1:IntItemCollection, param2:Function, param3:Boolean = true) : void + { + _masterpieceInvIdsToRemove = param1; + _sendMasterpieceCallback = param2; + var _loc4_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()]; + var _loc5_:String = null; + if(_loc4_) + { + _loc5_ = _loc4_.token; + } + _currentRequestUsername = gMainFrame.userInfo.myUserName; + if(_loc5_) + { + sendServiceRequest({ + "cmd":"RMP", + "t":_loc5_, + "mp":param1.getCoreArray() + }); + } + else + { + sendWallTokenRequest(_currentRequestUsername,sendRemoveMasterpiece,{"data":[param2,param1]},true,!param3); + } + } + + public static function sendAcknowledgeNotificationRequest(param1:Array, param2:Function, param3:Boolean = true) : void + { + var _loc4_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()]; + var _loc5_:String = null; + if(_loc4_) + { + _loc5_ = _loc4_.token; + } + _sendAcknowledgeNotificationCallback = param2; + _currentRequestUsername = gMainFrame.userInfo.myUserName; + _sendAcknowledgeMessages = param1; + if(_loc5_) + { + sendServiceRequest({ + "cmd":"ACK", + "t":_loc5_, + "x":param1 + }); + } + else + { + sendWallTokenRequest(_currentRequestUsername,sendAcknowledgeNotificationRequest,{"data":[param2,param1]},true,!param3); + } + } + + public static function ContinueCommandAfterTokenRequest(param1:Object, param2:Boolean) : void + { + var _loc3_:String = null; + var _loc4_:String = null; + if(param1 && param2) + { + _loc3_ = param1.cmd; + _loc4_ = param1.username; + switch(_loc3_) + { + case "CHK": + sendCheckPlayerWall(_loc4_,param1.callback,param1.isFromHudTimer,param2); + break; + case "PUT": + sendPutToPlayerWall(_loc4_,param1.msgToPost,param1.wallParameters,param1.callback,param2); + break; + case "DEL": + sendDeleteFromPlayerWall(_loc4_,param1.messageuuid,param1.callback,param2); + break; + case "GET": + sendGetFromPlayerWall(_loc4_,param1.callback,param1.isFromHudTimer,param2); + break; + case "GMP": + sendGetBlockedMessages(param1.callback,param2); + break; + case "AMB": + sendSetBlockedMessage(param1.messageToBeBlocked,param1.callback,param2); + break; + case "CLW": + sendClearAllMessages(param1.callback,param2); + break; + case "RMP": + sendRemoveMasterpiece(param1.invIdToRemove,param1.callback,param2); + break; + case "ACK": + sendAcknowledgeNotificationRequest(param1.messageId,param1.callback,param2); + } + } + else + { + PlayerWallManager.closeOpenPlayerWallDueToTokenFailures(); + } + } + + private static function checkResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onCheckResponse(_loc2_,param1,_currentRequestUsername,_isFromHudTimer); + if(_checkResponseCallback != null) + { + _checkResponseCallback(_loc2_,param1); + } + } + + private static function deleteResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + if(_deleteResponseCallback != null) + { + _deleteResponseCallback(_loc2_,_currMessageuuid,param1.e); + _deleteResponseCallback = null; + } + } + + private static function addResponse(param1:Object) : void + { + var _loc4_:Boolean = param1 != null ? Boolean(param1.PUT.s) : false; + var _loc2_:int = int(param1.PUT.cs != null ? param1.PUT.cs : 0); + var _loc3_:int = int(param1.PUT.tag != null ? param1.PUT.tag : 0); + if(_loc4_) + { + _messageToPost.msgId = param1.x; + _messageToPost.postTime = param1.t; + getResponse(param1.GET); + } + if(_putResponseCallback != null) + { + _putResponseCallback(_loc4_,_messageToPost,_loc2_,_loc3_,param1.PUT.e); + _putResponseCallback = null; + } + } + + public static function getResponse(param1:Object) : void + { + var _loc11_:Object = null; + var _loc5_:int = 0; + var _loc4_:int = 0; + var _loc12_:String = null; + var _loc10_:Boolean = false; + var _loc2_:Array = null; + var _loc6_:int = 0; + var _loc13_:Array = null; + var _loc8_:Object = null; + var _loc7_:int = 0; + var _loc3_:Vector. = new Vector.(); + var _loc9_:Vector. = new Vector.(); + var _loc14_:Boolean = param1 != null ? Boolean(param1.s) : false; + if(_loc14_) + { + _loc2_ = param1.r; + _loc6_ = 0; + while(_loc6_ < _loc2_.length) + { + _loc11_ = _loc2_[_loc6_]; + if(_loc11_) + { + _loc12_ = _loc11_.um == 1 ? _loc11_.un : LocalizationManager.translateIdOnly(11098); + _loc10_ = _loc11_.u == gMainFrame.userInfo.myUUID ? true : BuddyManager.isBuddy(_loc11_.un); + _loc3_.push(new PostMessage(_loc11_.x,_loc11_.m,_loc11_.uid,_loc11_.un,_loc12_,_loc11_.s,_loc11_.c,_loc11_.t,_loc10_,_loc11_.ai,_loc11_.ac,_loc11_.ae,_loc11_.ap,_loc11_.l,_loc11_.aci,_loc11_.pp,"",false)); + } + else + { + _loc4_++; + } + _loc6_++; + } + _loc13_ = param1.n; + if(_loc13_ != null && _loc13_.length > 0) + { + _loc7_ = 0; + while(_loc7_ < _loc13_.length) + { + _loc8_ = _loc13_[_loc7_]; + if(_loc8_ != null) + { + _loc12_ = _loc8_.um == 1 ? _loc8_.un : LocalizationManager.translateIdOnly(11098); + _loc10_ = _loc8_.un == gMainFrame.userInfo.myUserName ? true : BuddyManager.isBuddy(_loc8_.un); + _loc9_.push(new PostMessage(_loc8_.x,_loc8_.m,0,_loc8_.un,_loc12_,0,_loc8_.c,_loc8_.t,_loc10_,_loc8_.ai,_loc8_.ac,_loc8_.ae,_loc8_.ap,_loc8_.l,_loc8_.aci,_loc8_.pp,_loc8_.u,_loc8_.read)); + } + _loc7_++; + } + _loc9_.sort(orderTimestamp); + } + PlayerWallManager.updateTimestamp(_currentRequestUsername,param1.t); + _loc3_.sort(orderTimestamp); + } + PlayerWallManager.onGetResponse(_loc14_,_loc3_,_loc9_,param1.p,_isFromHudTimer,_currentRequestUsername,param1.e,_getResponseCallback); + if(_getResponseCallback != null) + { + _getResponseCallback(_loc14_); + _getResponseCallback = null; + } + } + + private static function setSettingsResponse(param1:Array) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onPrivacyResponse(_loc2_,_setSettingsId); + if(_setSettingsResponseCallback != null) + { + _setSettingsResponseCallback(_loc2_,_setSettingsId); + _setSettingsResponseCallback = null; + } + } + + private static function setParametersResponse(param1:Array) : void + { + var _loc2_:Boolean = param1[2] == "1"; + PlayerWallManager.onParametersResponse(_loc2_,_setWallParameters); + if(_setParametersResponseCallback != null) + { + _setParametersResponseCallback(_loc2_,_setWallParameters); + _setParametersResponseCallback = null; + } + } + + private static function getBlockedMessagesResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onBlockedMessagesResponse(_loc2_,param1); + if(_blockedMessagesCallback != null) + { + _blockedMessagesCallback(_loc2_,param1); + _blockedMessagesCallback = null; + } + } + + private static function setBlockedMessageResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onSetBlockedMessageResponse(_loc2_,_messageToBeBlocked); + if(_setBlockedMessageCallback != null) + { + _setBlockedMessageCallback(_loc2_,_messageToBeBlocked); + _setBlockedMessageCallback = null; + } + } + + private static function sendClearAllMessagesResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onSendClearAllMessagesResponse(_loc2_); + if(_sendClearAllMessagesCallback != null) + { + _sendClearAllMessagesCallback(_loc2_); + _sendClearAllMessagesCallback = null; + } + } + + private static function sendRemoveMasterpieceResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onSendRemoveMasterpieceResponse(_loc2_,_masterpieceInvIdsToRemove); + if(_sendMasterpieceCallback != null) + { + _sendMasterpieceCallback(_loc2_,_masterpieceInvIdsToRemove); + _sendMasterpieceCallback = null; + } + } + + private static function sendAcknowledgeNotificationResponse(param1:Object) : void + { + var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false; + PlayerWallManager.onSendAcknowledgeNotificationResponse(_loc2_,_sendAcknowledgeMessages); + if(_sendAcknowledgeNotificationCallback != null) + { + _sendAcknowledgeNotificationCallback(_loc2_,_sendAcknowledgeMessages,param1.e); + _sendAcknowledgeNotificationCallback = null; + } + } + + // what a reply is read with: its caller sets these before asking + private static function requestState() : Object + { + return { + "del":_deleteResponseCallback, + "get":_getResponseCallback, + "put":_putResponseCallback, + "blocked":_blockedMessagesCallback, + "block":_setBlockedMessageCallback, + "check":_checkResponseCallback, + "clear":_sendClearAllMessagesCallback, + "masterpiece":_sendMasterpieceCallback, + "ack":_sendAcknowledgeNotificationCallback, + "username":_currentRequestUsername, + "message":_messageToPost, + "uuid":_currMessageuuid, + "toBlock":_messageToBeBlocked, + "masterpieces":_masterpieceInvIdsToRemove, + "ackMessages":_sendAcknowledgeMessages, + "hud":_isFromHudTimer + }; + } + + private static function setRequestState(param1:Object) : void + { + _deleteResponseCallback = param1.del; + _getResponseCallback = param1.get; + _putResponseCallback = param1.put; + _blockedMessagesCallback = param1.blocked; + _setBlockedMessageCallback = param1.block; + _checkResponseCallback = param1.check; + _sendClearAllMessagesCallback = param1.clear; + _sendMasterpieceCallback = param1.masterpiece; + _sendAcknowledgeNotificationCallback = param1.ack; + _currentRequestUsername = param1.username; + _messageToPost = param1.message; + _currMessageuuid = param1.uuid; + _messageToBeBlocked = param1.toBlock; + _masterpieceInvIdsToRemove = param1.masterpieces; + _sendAcknowledgeMessages = param1.ackMessages; + _isFromHudTimer = param1.hud; + } + + // the next request that waited, once none is on its way (a reply's + // handler may have sent one of its own) + private static function sendWaitingRequest() : void + { + var _loc1_:Object = null; + if(!_isProcessingRequest && _waitingRequests.length > 0) + { + _loc1_ = _waitingRequests.shift(); + setRequestState(_loc1_.state); + sendServiceRequest(_loc1_.request); + } + } + + public static function sendServiceRequest(... rest) : void + { + var _loc3_:URLRequestHeader = null; + var _loc4_:String = null; + var _loc2_:URLRequest = null; + // one made while another was on its way was dropped: a wall + // opened while the HUD's timer was checking the player's own did + // not open. it waits for its turn now, and the one on its way gets + // back what its reply is read with. + if(_isProcessingRequest) + { + _waitingRequests.push({ + "request":rest[0], + "state":requestState() + }); + if(_sentRequestState) + { + setRequestState(_sentRequestState); + } + } + else + { + _isProcessingRequest = true; + _sentRequestState = requestState(); + _currCommand = rest[0].cmd; + _loc3_ = new URLRequestHeader("Content-type","application/json"); + _loc4_ = JSON.stringify(rest[0]); + _loc2_ = new URLRequest(gMainFrame.clientInfo.playerWallHost); + _loc2_.method = "POST"; + _loc2_.requestHeaders.push(_loc3_); + _loc2_.data = _loc4_; + _requestor = new URLLoader(); + _requestor.addEventListener("complete",httpRequestComplete); + _requestor.addEventListener("ioError",httpRequestError); + _requestor.addEventListener("securityError",httpRequestError); + _requestor.load(_loc2_); + } + } + + private static function httpRequestComplete(param1:Event) : void + { + _isProcessingRequest = false; + var _loc2_:Object = param1.target.data != "" ? JSON.parse(param1.target.data) : null; + if(_loc2_ != null) + { + if("s" in _loc2_) + { + if(_loc2_.s == true) + { + _tokenFailures = 0; + } + } + } + switch(_currCommand) + { + case "CHK": + checkResponse(_loc2_); + break; + case "PUT": + addResponse(_loc2_); + if(_loc2_.PUT.s == true) + { + _tokenFailures = 0; + } + break; + case "DEL": + deleteResponse(_loc2_); + break; + case "GET": + getResponse(_loc2_); + break; + case "GMB": + getBlockedMessagesResponse(_loc2_); + break; + case "AMB": + setBlockedMessageResponse(_loc2_); + break; + case "CLW": + sendClearAllMessagesResponse(_loc2_); + break; + case "RMP": + sendRemoveMasterpieceResponse(_loc2_); + break; + case "ACK": + sendAcknowledgeNotificationResponse(_loc2_); + } + sendWaitingRequest(); + } + + private static function httpRequestError(param1:ErrorEvent) : void + { + _isProcessingRequest = false; + if(GuiManager.mainHud.playerWall) + { + GuiManager.mainHud.playerWall.activateLoadingState(false); + } + BuddyManager.setPlayerWallLoading(false); + DarkenManager.showLoadingSpiral(false); + sendWaitingRequest(); + } + + private static function orderTimestamp(param1:PostMessage, param2:PostMessage) : int + { + if(param1.postTime < param2.postTime) + { + return -1; + } + if(param1.postTime > param2.postTime) + { + return 1; + } + return 0; + } + } +} + diff --git a/swf/ajclient.swf b/swf/ajclient.swf index 27677e7..e2c9bb8 100644 Binary files a/swf/ajclient.swf and b/swf/ajclient.swf differ diff --git a/tools/build-client.sh b/tools/build-client.sh index 6c4789a..943ad36 100755 --- a/tools/build-client.sh +++ b/tools/build-client.sh @@ -99,6 +99,8 @@ set -- \ game.MinigameManager MinigameManager.as \ gui.FeedbackManager FeedbackManager.as \ gameRedemption.CodeRedemptionPopup CodeRedemptionPopup.as \ + playerWall.PlayerWallXtCommManager PlayerWallXtCommManager.as \ + playerWall.PlayerWallGui PlayerWallGui.as \ game.microSmoothie.MicroSmoothie MicroSmoothie.as \ room.DenItemHolder ../tools/decompiled/room/DenItemHolder.as # not in the game: added before the replace (game.ArtStudioKit is Strawberry diff --git a/tools/decompiled/room/DenItemHolder.as b/tools/decompiled/room/DenItemHolder.as index 6a0b647..ede4a05 100644 --- a/tools/decompiled/room/DenItemHolder.as +++ b/tools/decompiled/room/DenItemHolder.as @@ -1,1855 +1,1860 @@ -package room -{ - import Party.PartyXtCommManager; - import avatar.AvatarManager; - import buddy.BuddyList; - import collection.DenItemCollection; - import collection.DenStateItemCollection; - import com.sbi.bit.BitUtility; - import com.sbi.graphics.SortLayer; - import den.DenItem; - import den.DenStateItem; - import den.DenXtCommManager; - import flash.display.BitmapData; - import flash.display.DisplayObject; - import flash.display.Loader; - import flash.display.MovieClip; - import flash.display.Sprite; - import flash.events.Event; - import flash.events.EventDispatcher; - import flash.events.MouseEvent; - import flash.filters.GlowFilter; - import flash.geom.Matrix; - import flash.geom.Point; - import flash.geom.Rectangle; - import flash.text.TextField; - import flash.text.TextFormat; - import flash.utils.Dictionary; - import game.MinigameManager; - import gui.AvatarEditor; - import gui.EcoPointsPopup; - import gui.EcoScorePopup; - import gui.GenericListGuiManager; - import gui.GuiManager; - import loader.DenItemHelper; - import localization.LocalizationManager; - import quest.QuestManager; - import shop.ShopManager; - - public class DenItemHolder extends EventDispatcher - { - - private const MOUSE_DOWN_TYPE:int = 0; - - private const MOUSE_OVER_TYPE:int = 1; - - private const MOUSE_OUT_TYPE:int = 2; - - private var _currItems:DenStateItemCollection; - - private var _itemsInit:DenStateItemCollection; - - private var _savedDenItemHelpers:Array; - - private var _layerManager:LayerManager; - - private var _dragItem:DenStateItem; - - private var _itemFilter:DenStateItem; - - private var _dragPoint:Point; - - private var _closeBtn:MovieClip; - - private var _flipBtn:MovieClip; - - private var _flipBtnVer:MovieClip; - - private var _linkBtn:MovieClip; - - // These are deliberately part of the selected item's action cluster, - // not the den editor chrome. That keeps them out of the way of the - // inventory and makes their scope obvious, as in the original editor. - private var _sendBehindBtn:Sprite; - - private var _bringToFrontBtn:Sprite; - - private var _naturalDepthBtn:Sprite; - - private var _themePos:Point; - - private var _isWaitingToSetItemsForFirstTime:Boolean; - - private var _roomMode:int; - - private var _lastItemInvId:int; - - private var _itemToEnterInvId:int; - - private var _itemRadiusBmpData:BitmapData; - - private var _lastSelectedItem:DenStateItem; - - private var _mannaquinAvEditor:AvatarEditor; - - private var _mannaquinDenItemHelper:DenItemHelper; - - private var _ecoScorePopup:EcoScorePopup; - - private var _ecoPointsPopup:EcoPointsPopup; - - public function DenItemHolder(param1:LayerManager) - { - super(); - _themePos = new Point(); - _dragPoint = new Point(); - _layerManager = param1; - _closeBtn = GETDEFINITIONBYNAME("closeBtn"); - _closeBtn.addEventListener("mouseDown",onCloseBtn,false,0,true); - _flipBtn = GETDEFINITIONBYNAME("itemRotateBtnCont"); - _flipBtn.addEventListener("mouseDown",onFlipBtn,false,0,true); - _flipBtnVer = GETDEFINITIONBYNAME("itemRotateBtnCont"); - _flipBtnVer.rotation = 90; - _flipBtnVer.addEventListener("mouseDown",onFlipBtn,false,0,true); - _linkBtn = GETDEFINITIONBYNAME("portalLinkBtnCont"); - _linkBtn.addEventListener("mouseDown",onLinkBtn,false,0,true); - _sendBehindBtn = makeLayerButton("Back",onSendBehindBtn); - _bringToFrontBtn = makeLayerButton("Front",onBringToFrontBtn); - _naturalDepthBtn = makeLayerButton("Auto",onNaturalDepthBtn); - release(); - _lastItemInvId = -1; - } - - public function release() : void - { - _isWaitingToSetItemsForFirstTime = true; - if(_currItems) - { - for each(var _loc1_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc1_.denItemHelper) - { - _loc1_.denItemHelper.destroy(); - } - } - } - _currItems = new DenStateItemCollection(); - _itemsInit = new DenStateItemCollection(); - _savedDenItemHelpers = []; - _lastSelectedItem = null; - _dragItem = null; - updateCloseBtn(); - } - - public function clearDen() : void - { - release(); - var _loc1_:DenStateItem = new DenStateItem(617,-1,40435715,0,0,0,50,0,0,3,0,4,0,0,0,"MusDenDef",0,"",0,0,"","",-1,"",false,null,0,0,null,null,2); - setItem(_loc1_); - } - - public function get numberOfInitItems() : int - { - return _itemsInit.length; - } - - public function get numberOfInUseItems() : int - { - return _currItems.length; - } - - public function get isDragging() : Boolean - { - return _dragItem != null; - } - - // The original editor only sorted furniture from its y position. Bits - // 2-3 of `flipped` are unused by the game's flip code, so they safely - // persist a selected item's deliberate stacking choice. - public function sendSelectedBehind() : Boolean - { - return setSelectedStacking(1); - } - - public function bringSelectedToFront() : Boolean - { - return setSelectedStacking(2); - } - - public function resetSelectedStacking() : Boolean - { - return setSelectedStacking(0); - } - - private function setSelectedStacking(param1:int) : Boolean - { - if(!canSetSelectedStacking()) - { - return false; - } - _dragItem.flipped = _dragItem.flipped & -13 | param1 << 2; - if(_dragItem.denItemHelper && _dragItem.denItemHelper.displayObject) - { - _dragItem.denItemHelper.displayObject.name = String(_dragItem.denItemHelper.sortOffset); - // SortLayer will settle on the saved offset at its next heartbeat; - // set the visible order now so the control feels immediate. - if(param1 == 1) - { - _dragItem.denItemHelper.displayObject.parent.setChildIndex(_dragItem.denItemHelper.displayObject,0); - } - else if(param1 == 2) - { - _dragItem.denItemHelper.displayObject.parent.setChildIndex(_dragItem.denItemHelper.displayObject,_dragItem.denItemHelper.displayObject.parent.numChildren - 1); - } - } - saveState(_dragItem.invIdx); - return true; - } - - private function canSetSelectedStacking() : Boolean - { - return _roomMode == 1 && _dragItem != null && _dragItem.layerId != 1 && !isTheme(_dragItem.sortCatId) && _dragItem.sortCatId != 4; - } - - private function makeLayerButton(param1:String, param2:Function) : Sprite - { - var _loc3_:Sprite = new Sprite(); - var _loc4_:TextField = new TextField(); - _loc3_.buttonMode = true; - _loc3_.mouseChildren = false; - _loc3_.graphics.beginFill(2398294,0.96); - _loc3_.graphics.drawRoundRect(0,0,42,24,8,8); - _loc3_.graphics.endFill(); - _loc3_.graphics.lineStyle(1,16774041,0.9); - _loc3_.graphics.drawRoundRect(0,0,42,24,8,8); - _loc4_.width = 42; - _loc4_.height = 20; - _loc4_.y = 3; - _loc4_.selectable = false; - _loc4_.mouseEnabled = false; - _loc4_.defaultTextFormat = new TextFormat("Arial",9,16777215,true,null,null,null,null,"center"); - _loc4_.text = param1; - _loc3_.addChild(_loc4_); - _loc3_.addEventListener("mouseDown",param2,false,0,true); - return _loc3_; - } - - private function onSendBehindBtn(param1:MouseEvent) : void - { - param1.stopImmediatePropagation(); - sendSelectedBehind(); - } - - private function onBringToFrontBtn(param1:MouseEvent) : void - { - param1.stopImmediatePropagation(); - bringSelectedToFront(); - } - - private function onNaturalDepthBtn(param1:MouseEvent) : void - { - param1.stopImmediatePropagation(); - resetSelectedStacking(); - } - - public function get lastSelectedItem() : DenStateItem - { - return _lastSelectedItem; - } - - public function reloadItems() : void - { - var _loc1_:int = 0; - if(_savedDenItemHelpers) - { - _loc1_ = 0; - while(_loc1_ < _savedDenItemHelpers.length) - { - itemLoaded(_savedDenItemHelpers[_loc1_],true); - _loc1_++; - } - } - } - - public function updateConsumers(param1:Dictionary) : void - { - var _loc2_:int = 0; - var _loc3_:int = 0; - for each(var _loc4_:DenStateItem in _currItems.getCoreArray()) - { - for(_loc2_ in param1) - { - if(_loc4_.invIdx == _loc2_) - { - if(!(_loc4_.ecoConsumerStateId == 0 && param1[_loc2_] == 2)) - { - if(!(_loc4_.ecoConsumerStateId == 2 && param1[_loc2_] == 0)) - { - if(_loc4_.ecoConsumerStateId != 2) - { - sendMouseEventToItem(_loc4_.denItemHelper.content as MovieClip); - } - else if(param1[_loc2_] != 2) - { - sendMouseEventToItem(_loc4_.denItemHelper.content as MovieClip); - } - } - } - _loc4_.ecoConsumerStateId = param1[_loc2_]; - } - } - } - var _loc5_:DenItemCollection = gMainFrame.userInfo.playerUserInfo.denItemsPartial; - _loc3_ = 0; - while(_loc3_ < _loc5_.length) - { - for(_loc2_ in param1) - { - if(_loc5_.getDenItem(_loc3_).invIdx == _loc2_) - { - _loc5_.getDenItem(_loc3_).ecoConsumerStateId = param1[_loc2_]; - break; - } - } - _loc3_++; - } - AvatarManager.playerAvatar.inventoryDenPartial.denItemCollection = _loc5_; - _loc5_ = AvatarManager.playerAvatar.inventoryDenFull.denItemCollection; - _loc3_ = 0; - while(_loc3_ < _loc5_.length) - { - for(_loc2_ in param1) - { - if(_loc5_.getDenItem(_loc3_).invIdx == _loc2_) - { - _loc5_.getDenItem(_loc3_).ecoConsumerStateId = param1[_loc2_]; - break; - } - } - _loc3_++; - } - gMainFrame.userInfo.playerUserInfo.denItemsFull = _loc5_; - } - - public function setItems(param1:DenStateItemCollection, param2:Boolean = false) : void - { - var _loc8_:DenStateItem = null; - var _loc4_:* = null; - var _loc3_:Boolean = false; - var _loc7_:int = 0; - var _loc5_:Number = NaN; - var _loc6_:Number = NaN; - var _loc10_:DenStateItem = null; - var _loc9_:Boolean = false; - if(_isWaitingToSetItemsForFirstTime && param2) - { - _isWaitingToSetItemsForFirstTime = false; - } - _loc7_ = 0; - while(_loc7_ < param1.length) - { - _loc8_ = param1.getDenStateItem(_loc7_); - if(_loc8_) - { - if(_loc8_.catId > 0) - { - _loc3_ = false; - for each(_loc4_ in _currItems.getCoreArray()) - { - if(_loc8_.refId == _loc4_.refId && _loc8_.invIdx == _loc4_.invIdx) - { - _loc4_.flipped = _loc8_.flipped; - _loc5_ = _loc8_.x + _loc4_.offsetX; - _loc6_ = _loc8_.y + _loc4_.offsetY; - setItemMatrix(_loc4_,_loc5_,_loc6_,_loc4_.flipped); - if(_loc4_.sortCatId == 99 && _loc4_.denItemHelper) - { - _loc4_.denItemHelper.setVersion(_loc8_.version,_loc8_.version2,_loc8_.version3); - } - if(_loc4_.specialType == 1) - { - _loc4_.userNameLink = _loc8_.userNameLink; - if(_loc4_.denItemHelper && _loc4_.denItemHelper.content && _loc4_.denItemHelper.content.hasOwnProperty("active")) - { - if(_loc4_.userNameLink != "") - { - Object(_loc4_.denItemHelper.content).active(true); - } - else - { - Object(_loc4_.denItemHelper.content).active(false); - } - } - BuddyList.destroyInWorldBuddyList(); - } - if(_loc4_.uniqueImageId != _loc8_.uniqueImageId) - { - _loc4_.uniqueImageId = _loc8_.uniqueImageId; - _loc4_.uniqueImageCreator = _loc8_.uniqueImageCreator; - if(_loc4_.denItemHelper) - { - (_loc4_.denItemHelper as DenItemHelper).uniqueImageId = _loc4_.uniqueImageId; - (_loc4_.denItemHelper as DenItemHelper).uniqueImageCreator = _loc4_.uniqueImageCreator; - (_loc4_.denItemHelper as DenItemHelper).loadUniqueImage(); - } - } - if(_loc4_.specialType == 4) - { - if(!_loc4_.mannequinData.compare(_loc8_.mannequinData,true)) - { - _loc4_.mannequinData.copyFromOther(_loc8_.mannequinData); - } - } - _loc4_.ecoConsumerStateId = _loc8_.ecoConsumerStateId; - _loc3_ = true; - break; - } - } - if(!_loc3_) - { - _loc10_ = _loc8_.clone(); - _loc10_.userAction = param2; - setItem(_loc10_); - } - } - else - { - for each(_loc4_ in _currItems.getCoreArray()) - { - if(_loc8_.refId == _loc4_.refId && _loc8_.invIdx == _loc4_.invIdx) - { - releaseItem(_loc4_,param2); - if(_loc4_.specialType == 5) - { - ShopManager.ifShopToSellOpenCloseIt(); - } - break; - } - } - } - } - _loc7_++; - } - for each(_loc4_ in _currItems.getCoreArray()) - { - if(_loc4_.sortCatId == 4) - { - _loc9_ = true; - break; - } - } - if(!_loc9_) - { - _loc8_ = new DenStateItem(0,-1,40435715,0,0,0,50,0,0,3,0,4,0,0,0,"MusDenDef",0,"",0,0,"","",-1,"",param2,null,0,0,null,null,2); - setItem(_loc8_); - } - if(!param2) - { - updateInitialState(); - } - if(_isWaitingToSetItemsForFirstTime) - { - _isWaitingToSetItemsForFirstTime = false; - } - } - - public function rebuildMannequins() : void - { - var _loc1_:* = null; - for each(_loc1_ in _currItems.getCoreArray()) - { - if(_loc1_.mannequinData != null) - { - _loc1_.mannequinData.refreshAvatarItems(); - } - } - } - - public function removeAccessoryAndRebuildMannequin(param1:DenItem, param2:int, param3:int) : void - { - var _loc6_:DenStateItem = null; - var _loc5_:int = 0; - var _loc4_:Boolean = false; - for each(_loc6_ in _currItems.getCoreArray()) - { - if(_loc6_.mannequinData != null && _loc6_.invIdx == param2) - { - _loc6_.mannequinData.hasThisInvIdOnAndRemove(param3); - _loc6_.mannequinData.refreshAvatarItems(); - _loc4_ = true; - break; - } - } - if(!_loc4_) - { - _loc6_ = new DenStateItem(param1.defId,param1.invIdx,param1.defId << 16 | param1.categoryId,0,0,param1.version,param1.version2,param1.version3,0,param1.categoryId,param1.refId,param1.sortId,param1.minigameDefId,param1.layerId,param1.enviroType,param1.strmName,0,"",param1.specialType,param1.listId,param1.uniqueImageId,param1.uniqueImageCreator,param1.uniqueImageCreatorDbId,param1.uniqueImageCreatorUUID,false,null,0,0,param1.petItem,param1.mannequinData,param1.ecoConsumerStateId); - _loc5_ = 0; - while(_loc5_ < _itemsInit.length) - { - if(_itemsInit.getDenStateItem(_loc5_).mannequinData != null && _itemsInit.getDenStateItem(_loc5_).mannequinData.invIdx == param2) - { - _loc4_ = true; - _itemsInit.setDenStateItem(_loc5_,_loc6_.clone()); - break; - } - _loc5_++; - } - if(!_loc4_) - { - _itemsInit.pushDenStateItem(_loc6_.clone()); - } - } - } - - public function removeItem(param1:int, param2:int) : void - { - for each(var _loc3_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc3_.refId == param2 && _loc3_.invIdx == param1) - { - releaseItem(_loc3_); - break; - } - } - } - - public function saveState(param1:int = -1) : void - { - var _loc2_:* = null; - var _loc13_:* = null; - var _loc7_:Boolean = false; - var _loc12_:Boolean = false; - var _loc4_:Object = null; - var _loc9_:* = null; - var _loc8_:int = 0; - var _loc5_:DenItemHolderEvent = null; - var _loc3_:Array = null; - var _loc10_:int = 0; - var _loc11_:int = 0; - var _loc6_:Array = []; - for each(_loc2_ in _itemsInit.getCoreArray()) - { - _loc7_ = false; - for each(_loc13_ in _currItems.getCoreArray()) - { - if(_loc13_.refId == _loc2_.refId && _loc13_.invIdx == _loc2_.invIdx) - { - _loc7_ = true; - if(_loc13_.sortCatId != 4 && (_loc13_.x != _loc2_.x || _loc13_.y != _loc2_.y || _loc13_.flipped != _loc2_.flipped || _loc13_.userNameLink != _loc2_.userNameLink || _loc13_.uniqueImageId != _loc2_.uniqueImageId || _loc13_.uniqueImageCreator != _loc2_.uniqueImageCreator || _loc13_.mannequinData == null && _loc2_.mannequinData != null || _loc13_.mannequinData != null && !_loc13_.mannequinData.compare(_loc2_.mannequinData,true))) - { - if(_loc13_.mannequinData == null && _loc2_.mannequinData != null || _loc13_.mannequinData != null && !_loc13_.mannequinData.compare(_loc2_.mannequinData,true)) - { - _loc12_ = true; - } - _loc6_.push({ - "di":_loc13_.denItemHelper, - "f":_loc13_.flipped, - "i":_loc13_.invIdx, - "x":_loc13_.x, - "s":_loc13_.sortCatId, - "y":_loc13_.y, - "offX":_loc13_.offsetX, - "offY":_loc13_.offsetY, - "r":_loc13_.refId, - "userNameLink":_loc13_.userNameLink, - "uniqueImageId":_loc13_.uniqueImageId, - "uniqueImageCreator":_loc13_.uniqueImageCreator, - "mannequinData":_loc13_.mannequinData - }); - } - break; - } - } - if(!_loc7_) - { - _loc6_.push({ - "f":0, - "i":_loc2_.invIdx, - "s":_loc2_.sortCatId, - "x":0, - "y":0, - "d":0, - "r":_loc2_.refId, - "userNameLink":"", - "uniqueImageId":"", - "uniqueImageCreator":"", - "mannequinData":_loc2_.mannequinData - }); - } - } - for each(_loc13_ in _currItems.getCoreArray()) - { - _loc7_ = false; - for each(_loc2_ in _itemsInit.getCoreArray()) - { - if(_loc2_.refId == _loc13_.refId && _loc2_.invIdx == _loc13_.invIdx) - { - _loc7_ = true; - break; - } - } - if(!_loc7_) - { - _loc6_.push({ - "f":_loc13_.flipped, - "di":_loc13_.defId, - "i":_loc13_.invIdx, - "s":_loc13_.sortCatId, - "x":_loc13_.x, - "y":_loc13_.y, - "offX":_loc13_.offsetX, - "offY":_loc13_.offsetY, - "r":_loc13_.refId, - "userNameLink":_loc13_.userNameLink, - "uniqueImageId":_loc13_.uniqueImageId, - "uniqueImageCreator":_loc13_.uniqueImageCreator, - "mannequinData":_loc13_.mannequinData - }); - } - } - if(_loc6_.length > 0) - { - updateInitialState(); - if(param1 != -1) - { - _loc8_ = 0; - while(_loc8_ < _loc6_.length) - { - if(_loc6_[_loc8_].i == param1) - { - _loc6_.push(_loc6_[_loc8_]); - _loc6_.splice(_loc8_,1); - break; - } - _loc8_++; - } - } - _loc5_ = new DenItemHolderEvent("OnSaveState"); - _loc3_ = []; - for each(_loc9_ in _loc6_) - { - if(_loc9_.i != -1) - { - if(_loc9_.di) - { - _loc10_ = _loc9_.x - _loc9_.offX; - _loc11_ = _loc9_.y - _loc9_.offY; - _loc4_ = { - "i":_loc9_.i, - "s":_loc9_.s, - "d":1, - "x":_loc10_, - "y":_loc11_, - "f":_loc9_.f, - "r":_loc9_.r, - "userNameLink":_loc9_.userNameLink, - "uniqueImageId":_loc9_.uniqueImageId, - "uniqueImageCreator":_loc9_.uniqueImageCreator, - "mannequinData":_loc9_.mannequinData - }; - } - else - { - _loc4_ = { - "i":_loc9_.i, - "s":_loc9_.s, - "d":0, - "x":0, - "y":0, - "f":0, - "r":_loc9_.r, - "userNameLink":_loc9_.userNameLink, - "uniqueImageId":_loc9_.uniqueImageId, - "uniqueImageCreator":_loc9_.uniqueImageCreator, - "mannequinData":_loc9_.mannequinData - }; - } - _loc3_.push(_loc4_); - } - } - _loc5_.array = _loc3_; - _loc5_.hasUpdates = _loc12_; - dispatchEvent(_loc5_); - } - } - - public function removeHighlightState() : void - { - if(_closeBtn.parent) - { - _closeBtn.parent.removeChild(_closeBtn); - } - if(_flipBtn.parent) - { - _flipBtn.parent.removeChild(_flipBtn); - } - if(_linkBtn.parent) - { - _linkBtn.parent.removeChild(_linkBtn); - } - removeLayerButtons(); - if(_itemFilter) - { - if(_itemFilter.denItemHelper.displayObject) - { - _itemFilter.denItemHelper.displayObject.filters = []; - } - _itemFilter = null; - } - } - - private function updateInitialState() : void - { - _itemsInit = new DenStateItemCollection(); - for each(var _loc1_:DenStateItem in _currItems.getCoreArray()) - { - _itemsInit.pushDenStateItem(_loc1_.clone()); - } - } - - public function handleMouse(param1:Number, param2:Number, param3:Boolean) : void - { - var _loc5_:Number = NaN; - var _loc4_:Number = NaN; - var _loc6_:DenStateItem = null; - if(param3) - { - if(_dragItem) - { - if(_dragItem.specialType == 1) - { - if(BuddyList.isOverWorldBuddyList(param1,param2)) - { - RoomManagerWorld.instance.forceMouseUp(); - return; - } - } - _loc5_ = _dragItem.x + param1 - _dragPoint.x; - _loc4_ = _dragItem.y + param2 - _dragPoint.y; - setItemMatrix(_dragItem,_loc5_,_loc4_,_dragItem.flipped); - setBtnPos(_loc5_ + _dragItem.denItemHelper.contentWidth - 30,_loc4_); - _dragPoint.x = param1; - _dragPoint.y = param2; - } - } - else - { - // The room treats a mouse-up over empty space as a deselect. The - // selected item's action cluster lives in that empty space, so - // keep the selection while the pointer crosses into its buttons. - if(_dragItem && isOverLayerActionArea(param1,param2)) - { - return; - } - if(_dragItem && _dragItem.specialType == 1) - { - _loc6_ = hitTest(param1,param2); - if(BuddyList.isOverWorldBuddyList(param1,param2)) - { - return; - } - if(_loc6_ != _dragItem) - { - BuddyList.closeWorldBuddyList(); - _dragItem = _loc6_; - } - } - else - { - _dragItem = hitTest(param1,param2); - } - if(_dragItem) - { - _dragPoint.x = param1; - _dragPoint.y = param2; - } - updateCloseBtn(); - } - } - - public function setThemePosition(param1:int, param2:int) : void - { - _themePos = new Point(param1,param2); - } - - public function setRoomMode(param1:int) : void - { - _roomMode = param1; - stopListenersOnPets(_roomMode == 1); - stopMouseOnNonMouseItems(_roomMode == 1); - } - - public function stopListenersOnPets(param1:Boolean) : void - { - for each(var _loc2_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc2_.denItemHelper && _loc2_.denItemHelper.content && _loc2_.denItemHelper.content.hasOwnProperty("listenToMouse")) - { - if(_loc2_.specialType != 7) - { - Object(_loc2_.denItemHelper.content).listenToMouse = !param1; - } - } - } - } - - public function stopMouseOnNonMouseItems(param1:Boolean) : void - { - for each(var _loc2_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc2_.denItemHelper && _loc2_.denItemHelper.content && _loc2_.denItemHelper.content.hasOwnProperty("ignoreMouseCompletely") && _loc2_.denItemHelper.displayObject) - { - Sprite(_loc2_.denItemHelper.displayObject).mouseEnabled = !param1; - Sprite(_loc2_.denItemHelper.displayObject).mouseChildren = !param1; - } - } - } - - public function shouldStopMovement(param1:Point) : Boolean - { - var _loc5_:DenStateItem = null; - var _loc3_:MovieClip = null; - var _loc4_:int = 0; - var _loc2_:int = int(_currItems.length); - if(_loc2_ > 0) - { - _loc4_ = 0; - while(_loc4_ < _loc2_) - { - _loc5_ = _currItems.getDenStateItem(_loc4_); - if(!isTheme(_loc5_.sortCatId) && _loc5_.sortCatId != 4) - { - if(_loc5_.denItemHelper.displayObject.numChildren > 0) - { - _loc3_ = Loader(_loc5_.denItemHelper.displayObject.getChildAt(0)).content as MovieClip; - if(_loc3_.parent.name == "moveToDisabled") - { - if(_loc3_.hitTestPoint(param1.x,param1.y,true)) - { - return true; - } - } - } - } - _loc4_++; - } - } - return false; - } - - public function portalItemTest(param1:Boolean, param2:Point) : void - { - var _loc4_:int = 0; - var _loc7_:DenStateItem = null; - var _loc6_:int = 0; - var _loc3_:Sprite = null; - var _loc5_:Object = null; - if(!RoomXtCommManager.isSwitching) - { - _loc4_ = int(_currItems.length); - if(_loc4_ > 0) - { - _loc6_ = 0; - while(_loc6_ < _loc4_) - { - _loc7_ = _currItems.getDenStateItem(_loc6_); - if(_loc7_.specialType == 1 && _loc7_.userNameLink != "" || _loc7_.specialType == 3) - { - if(_loc7_.denItemHelper.content) - { - if(param1) - { - if(Object(_loc7_.denItemHelper.displayObject.getChildAt(0)).content.clickObject.hitTestPoint(param2.x,param2.y,true)) - { - _loc3_ = Sprite(Object(_loc7_.denItemHelper.displayObject.getChildAt(0)).content.radiusObject); - _itemToEnterInvId = _loc7_.invIdx; - _itemRadiusBmpData = new BitmapData(_loc3_.width,_loc3_.height); - _itemRadiusBmpData.draw(_loc3_); - } - else - { - _itemToEnterInvId = -1; - if(_itemRadiusBmpData) - { - _itemRadiusBmpData.dispose(); - _itemRadiusBmpData = null; - } - } - _lastItemInvId = -1; - } - if(_itemToEnterInvId == _loc7_.invIdx) - { - _loc5_ = Object(_loc7_.denItemHelper.content).getRadiusObject(); - if(!AvatarManager.playerAvatarWorldView.bmpDataHitTest(_itemRadiusBmpData,new Point(_loc7_.x + _loc5_.x,_loc7_.y + _loc5_.y))) - { - return; - } - if(_lastItemInvId == _loc7_.invIdx) - { - return; - } - if(_lastItemInvId == -1) - { - if(_loc7_.specialType == 3) - { - DenXtCommManager.requestDenPhantom(AvatarManager.playerAvatarWorldView.isPhantom ? 0 : 1); - } - else - { - RoomXtCommManager.sendRoomJoinRequest("den" + _loc7_.userNameLink,_loc7_.invIdx); - } - _lastItemInvId = _loc7_.invIdx; - return; - } - } - } - } - _loc6_++; - } - } - } - _lastItemInvId = -1; - } - - private function isTheme(param1:int) : Boolean - { - return param1 > 1 && param1 < 4; - } - - private function setItem(param1:DenStateItem) : void - { - var _loc4_:DenItemHolderEvent = null; - var _loc2_:DenItemHolderEvent = null; - var _loc3_:DenItemHelper = new DenItemHelper(); - if(isTheme(param1.sortCatId)) - { - for each(var _loc5_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc5_.sortCatId == param1.sortCatId) - { - releaseItem(_loc5_); - _loc4_ = new DenItemHolderEvent("OnItemRemoved"); - _loc4_.id = _loc5_.invIdx; - _loc4_.refId = _loc5_.refId; - _loc4_.array = [_loc5_]; - dispatchEvent(_loc4_); - break; - } - } - } - else if(param1.sortCatId == 4) - { - for each(var _loc6_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc6_.sortCatId == param1.sortCatId) - { - releaseItem(_loc6_); - _loc2_ = new DenItemHolderEvent("OnItemRemoved"); - _loc2_.id = _loc6_.invIdx; - _loc2_.refId = _loc6_.refId; - _loc2_.array = [_loc6_]; - dispatchEvent(_loc2_); - break; - } - } - RoomManagerWorld.instance.playMusic(param1.strmName + ".mp3",param1.version2 / 100); - } - param1.denItemHelper = _loc3_; - _currItems.pushDenStateItem(param1); - _loc3_.initDS(param1,itemLoaded); - if(_roomMode == 1) - { - if(param1.denItemHelper && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("listenToMouse")) - { - Object(param1.denItemHelper.content).listenToMouse = false; - } - } - else if(param1.denItemHelper && param1.denItemHelper.displayObject && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("ignoreMouseCompletely")) - { - Sprite(param1.denItemHelper.displayObject).mouseEnabled = false; - Sprite(param1.denItemHelper.displayObject).mouseChildren = false; - } - if(param1.denItemHelper && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("active")) - { - if(param1.userNameLink != "") - { - Object(param1.denItemHelper.content).active(true); - } - else - { - Object(param1.denItemHelper.content).active(false); - } - } - if(param1.minigameDefId > 0 || param1.listLauncherId > 0 || _loc3_.isUniqueImageItem) - { - addListenersToItem(_loc3_,param1); - } - else if(param1.specialType == 1) - { - addPortalListenersToItem(_loc3_,param1); - } - else if(param1.specialType == 2) - { - _loc3_.setupItemWithEmotes(param1); - } - else if(param1.defId == 3192 || param1.defId == 3193 || param1.defId == 3250 || param1.defId == 3585) - { - addListenersToItem(_loc3_,param1); - } - else if(param1.defId >= 3312 && param1.defId <= 3319) - { - addListenersToItem(_loc3_,param1); - } - else if(param1.specialType == 5) - { - addListenersToItem(_loc3_,param1); - } - else if(RoomManagerWorld.instance.isMyDen) - { - if(param1.defId == 3216) - { - addListenersToItem(_loc3_,param1); - } - else if(param1.specialType == 4) - { - addListenersToItem(_loc3_,param1); - } - else if(param1.specialType == 6) - { - addListenersToItem(_loc3_,param1); - } - else if(param1.specialType == 7) - { - if(param1.denItemHelper && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("listenToMouse")) - { - Object(param1.denItemHelper.content).listenToMouse = false; - } - addListenersToItem(_loc3_,param1); - } - } - if(_isWaitingToSetItemsForFirstTime || !param1.userAction) - { - _itemsInit.pushDenStateItem(param1.clone()); - } - } - - private function updateCloseBtn() : void - { - if(_dragItem) - { - if(_closeBtn.parent != _dragItem.denItemHelper.displayObject) - { - setBtnPos(_dragItem.x + _dragItem.denItemHelper.contentWidth - 30,_dragItem.y); - _layerManager.room_chat.addChild(_closeBtn); - _layerManager.room_chat.addChild(_flipBtn); - _layerManager.room_chat.addChild(_flipBtnVer); - if(_dragItem.specialType == 1) - { - _layerManager.room_chat.addChild(_linkBtn); - } - else if(_linkBtn.parent) - { - _linkBtn.parent.removeChild(_linkBtn); - BuddyList.closeWorldBuddyList(); - } - } - updateLayerButtons(); - if(_itemFilter != _dragItem) - { - if(_itemFilter) - { - _itemFilter.denItemHelper.displayObject.filters = []; - } - _itemFilter = _dragItem; - _itemFilter.denItemHelper.displayObject.filters = [new GlowFilter(16777215,1,8,8,8)]; - } - } - else - { - if(_closeBtn.parent) - { - _closeBtn.parent.removeChild(_closeBtn); - } - if(_flipBtn.parent) - { - _flipBtn.parent.removeChild(_flipBtn); - } - if(_flipBtnVer.parent) - { - _flipBtnVer.parent.removeChild(_flipBtnVer); - } - if(_linkBtn.parent) - { - _linkBtn.parent.removeChild(_linkBtn); - BuddyList.closeWorldBuddyList(); - } - removeLayerButtons(); - if(_itemFilter) - { - if(_itemFilter.denItemHelper.displayObject) - { - _itemFilter.denItemHelper.displayObject.filters = []; - } - _itemFilter = null; - } - } - } - - private function setBtnPos(param1:Number, param2:Number) : void - { - _closeBtn.x = param1; - _closeBtn.y = param2; - _flipBtn.x = param1 + 15; - _flipBtn.y = param2 + 55; - _flipBtnVer.x = param1 + 15; - _flipBtnVer.y = param2 + 90; - _linkBtn.x = param1 + 15; - _linkBtn.y = param2 + 125; - _sendBehindBtn.x = param1 + 42; - _sendBehindBtn.y = param2; - _bringToFrontBtn.x = param1 + 42; - _bringToFrontBtn.y = param2 + 27; - _naturalDepthBtn.x = param1 + 42; - _naturalDepthBtn.y = param2 + 54; - BuddyList.updateWorldBuddyListPosition(_linkBtn); - } - - private function updateLayerButtons() : void - { - if(!canSetSelectedStacking()) - { - removeLayerButtons(); - return; - } - if(_sendBehindBtn.parent != _layerManager.room_chat) - { - _layerManager.room_chat.addChild(_sendBehindBtn); - _layerManager.room_chat.addChild(_bringToFrontBtn); - _layerManager.room_chat.addChild(_naturalDepthBtn); - } - } - - private function removeLayerButtons() : void - { - if(_sendBehindBtn.parent) - { - _sendBehindBtn.parent.removeChild(_sendBehindBtn); - } - if(_bringToFrontBtn.parent) - { - _bringToFrontBtn.parent.removeChild(_bringToFrontBtn); - } - if(_naturalDepthBtn.parent) - { - _naturalDepthBtn.parent.removeChild(_naturalDepthBtn); - } - } - - private function isOverLayerActionArea(param1:Number, param2:Number) : Boolean - { - var _loc3_:Rectangle = null; - if(_sendBehindBtn.parent == null) - { - return false; - } - // Treat the item and its controls as one continuous selection area. - // This bridges any empty pixels between a large item and its buttons. - _loc3_ = _dragItem.denItemHelper.displayObject.getBounds(_layerManager.room_avatars); - return param1 >= Math.min(_loc3_.left,_sendBehindBtn.x) - 12 && param1 <= Math.max(_loc3_.right,_sendBehindBtn.x + _sendBehindBtn.width) + 12 && param2 >= Math.min(_loc3_.top,_sendBehindBtn.y) - 12 && param2 <= Math.max(_loc3_.bottom,_naturalDepthBtn.y + _naturalDepthBtn.height) + 12; - } - - private function onCloseBtn(param1:Event) : void - { - var _loc2_:DenItemHolderEvent = null; - param1.stopPropagation(); - if(_dragItem) - { - _loc2_ = new DenItemHolderEvent("OnItemRemoved"); - _loc2_.id = _dragItem.invIdx; - _loc2_.refId = _dragItem.refId; - _loc2_.array = [_dragItem]; - releaseItem(_dragItem); - _dragItem = null; - updateCloseBtn(); - dispatchEvent(_loc2_); - } - } - - private function onFlipBtn(param1:Event) : void - { - param1.stopPropagation(); - if(_dragItem) - { - if(param1.currentTarget == _flipBtn) - { - _dragItem.flipped = !BitUtility.isBitSetForNumber(0,_dragItem.flipped) ? _dragItem.flipped ^ 1 : _dragItem.flipped ^ 1; - setItemMatrix(_dragItem,_dragItem.x,_dragItem.y,_dragItem.flipped); - } - else if(param1.currentTarget == _flipBtnVer) - { - if(!BitUtility.isBitSetForNumber(1,_dragItem.flipped)) - { - _dragItem.flipped |= 2; - } - else - { - _dragItem.flipped = !BitUtility.isBitSetForNumber(1,_dragItem.flipped) ? _dragItem.flipped | 2 : _dragItem.flipped ^ 2; - } - setItemMatrix(_dragItem,_dragItem.x,_dragItem.y,_dragItem.flipped); - } - } - } - - private function onLinkBtn(param1:MouseEvent) : void - { - param1.stopPropagation(); - if(_dragItem) - { - BuddyList.buildInWorldBuddyList(_linkBtn,_dragItem,onSelectUserToLink,_dragItem.userNameLink); - } - } - - private function onSelectUserToLink(param1:String) : void - { - if(_dragItem) - { - _dragItem.userNameLink = param1; - if(_dragItem.denItemHelper && _dragItem.denItemHelper.content && _dragItem.denItemHelper.content.hasOwnProperty("active")) - { - if(param1 != "") - { - Object(_dragItem.denItemHelper.content).active(true); - } - else - { - Object(_dragItem.denItemHelper.content).active(false); - } - } - } - } - - private function isInInitList(param1:int, param2:int) : Boolean - { - var _loc3_:int = 0; - _loc3_ = 0; - while(_loc3_ < _itemsInit.length) - { - if(_itemsInit.getDenStateItem(_loc3_).refId == param2 && _itemsInit.getDenStateItem(_loc3_).invIdx == param1) - { - return true; - } - _loc3_++; - } - return false; - } - - private function releaseItem(param1:DenStateItem, param2:Boolean = true) : void - { - var _loc3_:int = _currItems.getCoreArray().indexOf(param1); - if(_loc3_ >= 0) - { - _currItems.getCoreArray().splice(_loc3_,1); - if(param1.defId) - { - if(param1.denItemHelper.displayObject.parent) - { - param1.denItemHelper.displayObject.parent.removeChild(param1.denItemHelper.displayObject); - } - if(param1.denItemHelper.minigameDefId > 0 || param1.denItemHelper.listLauncherId > 0 || param1.denItemHelper.uniqueImageId != "") - { - removeListenersFromItem(param1.denItemHelper); - } - else if(param1.specialType == 1) - { - removePortalListenersFromItem(param1.denItemHelper); - } - else if(param1.defId == 3192 || param1.defId == 3193 || param1.defId == 3250 || param1.defId == 3585) - { - removeListenersFromItem(param1.denItemHelper); - } - else if(param1.defId >= 3312 && param1.defId <= 3319) - { - removeListenersFromItem(param1.denItemHelper); - } - else if(RoomManagerWorld.instance.isMyDen) - { - if(param1.defId == 3216) - { - removeListenersFromItem(param1.denItemHelper); - } - else if(param1.specialType == 4) - { - removeListenersFromItem(param1.denItemHelper); - if(param1.mannequinData && !param2) - { - param1.mannequinData.removeItems(); - } - } - } - else if(param1.specialType == 5) - { - removeListenersFromItem(param1.denItemHelper); - } - if(param1.specialType == 1) - { - removePortalListenersFromItem(param1.denItemHelper); - _lastItemInvId = -1; - _itemToEnterInvId = -1; - } - if(_itemRadiusBmpData) - { - _itemRadiusBmpData.dispose(); - _itemRadiusBmpData = null; - } - } - } - if(!param2) - { - _loc3_ = 0; - while(_loc3_ < _itemsInit.length) - { - if(_itemsInit.getDenStateItem(_loc3_).invIdx == param1.invIdx) - { - _itemsInit.getCoreArray().splice(_loc3_,1); - break; - } - _loc3_++; - } - } - _lastSelectedItem = null; - } - - private function setItemMatrix(param1:DenStateItem, param2:Number, param3:Number, param4:int) : void - { - var _loc14_:Sprite = null; - var _loc10_:Loader = null; - var _loc13_:MovieClip = null; - var _loc11_:Matrix = null; - var _loc12_:Number = NaN; - var _loc8_:Number = NaN; - var _loc5_:DisplayObject = param1.denItemHelper.displayObject; - param1.x = param2; - param1.y = param3; - var _loc9_:Matrix = _loc5_.transform.matrix; - _loc9_.identity(); - var _loc6_:Number = param2; - var _loc7_:Number = param3; - if(param1.denItemHelper.bFlipLabel) - { - _loc14_ = _loc5_ as Sprite; - _loc10_ = _loc14_.getChildAt(0) as Loader; - _loc13_ = _loc10_.content as MovieClip; - _loc13_.gotoAndStop(BitUtility.isBitSetForNumber(0,param4) ? "flip" : 1); - if(BitUtility.isBitSetForNumber(1,param4)) - { - _loc7_ += _loc5_.height; - _loc6_ += _loc5_.width; - } - } - else if(param4 > 0) - { - if(BitUtility.isBitSetForNumber(0,param4)) - { - _loc6_ += _loc5_.width; - } - if(BitUtility.isBitSetForNumber(1,param4)) - { - if(param1.denItemHelper.isUniqueImageItem) - { - _loc7_ += _loc5_.height * 0.8; - if(!BitUtility.isBitSetForNumber(0,param4)) - { - _loc6_ += _loc5_.width; - } - else - { - _loc6_ -= _loc5_.width; - } - } - else - { - _loc7_ += _loc5_.height; - if(!BitUtility.isBitSetForNumber(0,param4)) - { - _loc6_ += _loc5_.width; - } - else - { - _loc6_ -= _loc5_.width; - } - } - } - _loc9_.scale(BitUtility.isBitSetForNumber(0,param4) ? -1 : 1,1); - } - if(param1.denItemHelper.isUniqueImageItem) - { - _loc11_ = Object(param1.denItemHelper.content).item1.imageCont.transform.matrix; - _loc12_ = Math.abs(_loc11_.b); - _loc8_ = Math.abs(_loc11_.a); - _loc11_.a = 1; - _loc11_.b = 1; - _loc11_.a = BitUtility.isBitSetForNumber(0,param4) ? -1 : 1; - _loc11_.b = BitUtility.isBitSetForNumber(0,param4) ? -1 : 1; - _loc11_.a *= _loc8_; - _loc11_.b *= _loc12_; - Object(param1.denItemHelper.content).item1.imageCont.transform.matrix = _loc11_; - } - _loc9_.translate(_loc6_,_loc7_); - _loc5_.transform.matrix = _loc9_; - if(BitUtility.isBitSetForNumber(1,param4)) - { - _loc5_.rotation = 180; - } - else - { - _loc5_.rotation = 0; - } - } - - private function hitTest(param1:int, param2:int) : DenStateItem - { - var _loc3_:DenStateItem = null; - var _loc7_:int = 0; - var _loc9_:DenStateItem = null; - var _loc6_:DisplayObject = null; - var _loc4_:Rectangle = null; - var _loc10_:Number = NaN; - var _loc8_:Number = -999999999; - var _loc11_:int = 99999999; - var _loc5_:int = int(_currItems.length); - while(_loc7_ < _loc5_) - { - _loc9_ = _currItems.getDenStateItem(_loc7_); - if(!isTheme(_loc9_.sortCatId)) - { - _loc6_ = _loc9_.denItemHelper.displayObject; - _loc4_ = _loc6_.getBounds(_layerManager.room_avatars); - _loc4_.height = Math.max(105,_loc4_.height); - _loc10_ = _loc4_.bottom - Number(_loc6_.name); - if(param1 > _loc4_.left && param1 < _loc4_.right && param2 > _loc4_.top && param2 < _loc4_.bottom) - { - if(_loc9_.layerId <= _loc11_) - { - if(_loc9_.layerId == 1 || _loc10_ > _loc8_) - { - _loc11_ = _loc9_.layerId; - _loc8_ = _loc10_; - _loc3_ = _loc9_; - if(_loc11_ == 1) - { - _loc8_ = -999999999; - } - } - } - } - } - _loc7_++; - } - return _loc3_; - } - - private function itemLoaded(param1:DenItemHelper, param2:Boolean = false) : void - { - var _loc8_:DenStateItem = null; - var _loc3_:Sprite = null; - var _loc5_:Number = NaN; - var _loc7_:Number = NaN; - var _loc4_:Boolean = false; - var _loc11_:int = 0; - var _loc10_:int = 0; - var _loc12_:SortLayer = null; - if(!param2) - { - _savedDenItemHelpers.push(param1); - } - for each(var _loc9_:DenStateItem in _currItems.getCoreArray()) - { - if(_loc9_.denItemHelper == param1) - { - _loc8_ = _loc9_; - break; - } - } - if(_loc8_ && _loc8_.sortCatId != 4) - { - _loc3_ = param1.displayObject; - _loc8_.offsetX = -(param1.contentWidth * 0.5); - _loc8_.offsetY = -param1.contentHeight; - if(param2) - { - _loc8_.x -= _loc8_.offsetX; - _loc8_.y -= _loc8_.offsetY; - } - _loc5_ = _loc8_.x + _loc8_.offsetX; - _loc7_ = _loc8_.y + _loc8_.offsetY; - _loc4_ = _loc8_.newPlaced; - if(_loc8_.newPlaced) - { - _loc7_ += param1.contentHeight * 0.5; - _loc8_.newPlaced = false; - } - if(_roomMode == 1 || _loc8_.specialType == 7) - { - if(_loc8_.denItemHelper && _loc8_.denItemHelper.content && _loc8_.denItemHelper.content.hasOwnProperty("listenToMouse")) - { - Object(_loc8_.denItemHelper.content).listenToMouse = false; - } - } - else if(_loc3_ && _loc8_.denItemHelper && _loc8_.denItemHelper.content && _loc8_.denItemHelper.content.hasOwnProperty("ignoreMouseCompletely")) - { - Sprite(_loc3_).mouseEnabled = false; - Sprite(_loc3_).mouseChildren = false; - } - if(_loc8_.denItemHelper && _loc8_.denItemHelper.content && _loc8_.denItemHelper.content.hasOwnProperty("active")) - { - if(_loc8_.userNameLink != "") - { - Object(_loc8_.denItemHelper.content).active(true); - } - else - { - Object(_loc8_.denItemHelper.content).active(false); - } - } - if(_loc8_.denItemHelper) - { - if(_loc8_.denItemHelper.isUniqueImageItem) - { - addListenersToItem(_loc8_.denItemHelper,_loc8_); - } - } - if(_loc8_.specialType == 7 && _loc8_.ecoConsumerStateId == 1) - { - sendMouseEventToItem(_loc8_.denItemHelper.content as MovieClip); - } - _loc10_ = _loc8_.layerId; - setItemMatrix(_loc8_,_loc5_,_loc7_,_loc8_.flipped); - if(isTheme(_loc8_.sortCatId)) - { - _loc10_ = 100; - _loc3_.x = 0; - _loc3_.y = 0; - setItemMatrix(_loc8_,0,0,0); - } - if(!_loc4_) - { - for each(var _loc6_:DenStateItem in _itemsInit.getCoreArray()) - { - if(_loc8_.refId == _loc6_.refId && _loc8_.invIdx == _loc6_.invIdx) - { - if(_loc8_.x != _loc6_.x || _loc8_.y != _loc6_.y) - { - _loc6_.x = _loc8_.x; - _loc6_.y = _loc8_.y; - _loc6_.offsetX = _loc8_.offsetX; - _loc6_.offsetY = _loc8_.offsetY; - break; - } - } - } - } - switch(_loc10_) - { - case 1: - _layerManager.room_bkg_main.addChild(_loc3_); - break; - case 100: - _layerManager.room_bkg_main.addChildAt(_loc3_,0); - break; - default: - _loc11_ = param1.sortOffset; - _loc12_ = RoomManagerWorld.instance.inPreviewMode ? _layerManager.preview_room_avatar : _layerManager.room_avatars; - if(_loc11_) - { - _loc3_.name = String(_loc11_); - } - _loc12_.addChild(_loc3_); - } - } - } - - private function addListenersToItem(param1:DenItemHelper, param2:DenStateItem) : void - { - param1.addMouseListeners(param2,onItemDown,onItemOver,onItemOut); - } - - private function addPortalListenersToItem(param1:DenItemHelper, param2:DenStateItem) : void - { - param1.addPortalListeners(param2,onPortalItemDown,onPortalItemOver,onPortalItemOut); - } - - private function removeListenersFromItem(param1:DenItemHelper) : void - { - param1.removeMouseListeners(); - } - - private function removePortalListenersFromItem(param1:DenItemHelper) : void - { - param1.removePortalListeners(); - } - - private function onItemDown(param1:MouseEvent, param2:DenItemHelper) : void - { - var _loc3_:Object = null; - if(_roomMode != 0) - { - return; - } - param1.stopPropagation(); - sendMouseEvent(param1); - _lastSelectedItem = param2.denStateItem as DenStateItem; - if(param2.minigameDefId > 0) - { - _loc3_ = { - "typeDefId":param2.minigameDefId, - "fromMyDenItem":RoomManagerWorld.instance.isMyDen - }; - MinigameManager.handleGameClick(_loc3_,null); - } - else if(param2.listLauncherId > 0) - { - GuiManager.openPageFlipBook(param2.listLauncherId,true,1); - } - else if(param2.isUniqueImageItem) - { - GuiManager.openMasterpiecePreview(param2.uniqueImageId,param2.uniqueImageCreator,param2.uniqueImageCreatorDbId,param2.uniqueImageCreatorUUID,param2.version,RoomManagerWorld.instance.denOwnerName,param2.currDenItem); - } - else if(param2.defId == 3192 || param2.defId == 3193 || param2.defId == 3250 || param2.defId == 3585) - { - QuestManager.showTalkingDialog(GuiManager.guiLayer,LocalizationManager.translateIdOnly(30423).split("|"),0,-1,true,PartyXtCommManager.sendJoinPartyRequest,48); - } - else if(param2.defId >= 3312 && param2.defId <= 3319) - { - switch(param2.defId - 3312) - { - case 0: - RoomXtCommManager.sendRoomJoinRequest("jamaa_township.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 1: - RoomXtCommManager.sendRoomJoinRequest("crystal_sands.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 2: - RoomXtCommManager.sendRoomJoinRequest("appondale.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 3: - RoomXtCommManager.sendRoomJoinRequest("sarepia.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 4: - RoomXtCommManager.sendRoomJoinRequest("mountains_of_shivveer.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 5: - RoomXtCommManager.sendRoomJoinRequest("lost_temple_of_zios.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 6: - RoomXtCommManager.sendRoomJoinRequest("aussie.room_main#" + RoomManagerWorld.instance.shardId); - break; - case 7: - RoomXtCommManager.sendRoomJoinRequest("coral_canyons.room_main#" + RoomManagerWorld.instance.shardId); - } - } - else if(param2.defId == 3216) - { - GenericListGuiManager.genericListVolumeClicked(669); - } - else if(param2.isMannequin) - { - _mannaquinDenItemHelper = param2; - _mannaquinAvEditor = new AvatarEditor(); - _mannaquinAvEditor.init(_mannaquinDenItemHelper.mannequin.mannequinAvatarView.avatarData,GuiManager.guiLayer,onMannequinAvEditorClose,false,false,_mannaquinDenItemHelper); - } - else if(param2.isDenStore) - { - ShopManager.launchDenShopStore(_lastSelectedItem.invIdx); - } - else if(param2.denStateItem.specialType == 6) - { - _ecoScorePopup = new EcoScorePopup(onEcoPopupClose); - } - else if(param2.denStateItem.specialType == 7 && (param2.content as MovieClip).clickFromCode == null || (param2.content as MovieClip).clickFromCode == false) - { - _ecoPointsPopup = new EcoPointsPopup(param2.denStateItem,onEcoPointsPopupClose); - } - } - - private function onPortalItemDown(param1:MouseEvent, param2:DenItemHelper) : void - { - } - - private function onItemOver(param1:MouseEvent, param2:DenItemHelper) : void - { - if(_roomMode != 0) - { - return; - } - if(param2.isMannequin) - { - return; - } - param1.stopPropagation(); - sendMouseEvent(param1); - var _loc3_:Sprite = Sprite(param1.currentTarget); - GuiManager.toolTip.init(_layerManager.room_orbs,param2.minigameDefId > 0 ? MinigameManager.getGameName(param2.minigameDefId) : LocalizationManager.translateIdOnly(param2.denStateItem.denItemHelper.nameStrId),param2.denStateItem.x + _loc3_.width * 0.5,param2.denStateItem.y + _loc3_.height - 75); - GuiManager.toolTip.startTimer(param1); - } - - private function onPortalItemOver(param1:MouseEvent, param2:DenItemHelper) : void - { - if(_roomMode != 0) - { - return; - } - param1.stopPropagation(); - if(param2.denStateItem.userNameLink != "") - { - sendMouseEvent(param1,true); - } - } - - private function onItemOut(param1:MouseEvent) : void - { - if(_roomMode != 0) - { - return; - } - param1.stopPropagation(); - sendMouseEvent(param1); - GuiManager.toolTip.resetTimerAndSetVisibility(); - } - - private function onPortalItemOut(param1:MouseEvent) : void - { - if(_roomMode != 0) - { - return; - } - param1.stopPropagation(); - sendMouseEvent(param1,true); - } - - private function sendMouseEvent(param1:MouseEvent, param2:Boolean = false) : void - { - var _loc6_:Sprite = null; - var _loc5_:Loader = null; - var _loc3_:MovieClip = null; - var _loc4_:int = -1; - switch(param1.type) - { - case "mouseDown": - _loc4_ = 0; - break; - case "mouseOver": - _loc4_ = 1; - break; - case "mouseOut": - _loc4_ = 2; - } - if(_loc4_ >= 0) - { - if(param2) - { - _loc6_ = Sprite(param1.currentTarget.parent); - } - else - { - _loc6_ = Sprite(param1.currentTarget); - } - if(_loc6_.parent) - { - _loc5_ = Loader(_loc6_.getChildAt(0)); - if(_loc5_) - { - _loc3_ = MovieClip(_loc5_.content); - if(_loc3_) - { - if(_loc3_.hasOwnProperty("handleMouse")) - { - _loc3_.handleMouse(_loc4_); - } - } - } - } - } - } - - private function sendMouseEventToItem(param1:MovieClip) : void - { - var _loc2_:Boolean = false; - if(param1) - { - if(param1.hasOwnProperty("handleMouse")) - { - param1.handleMouse("mouseDown"); - } - else - { - _loc2_ = Boolean(param1.listenToMouse); - param1.listenToMouse = true; - param1.clickFromCode = true; - MovieClip(param1.item1).dispatchEvent(new MouseEvent("mouseDown")); - param1.listenToMouse = _loc2_; - param1.clickFromCode = false; - } - } - } - - private function onMannequinAvEditorClose(param1:Boolean) : void - { - var _loc2_:int = 0; - var _loc3_:DenItemCollection = null; - var _loc4_:int = 0; - _mannaquinAvEditor.destroy(); - _mannaquinAvEditor = null; - if(param1) - { - _loc3_ = gMainFrame.userInfo.playerUserInfo.denItemsPartial; - _loc4_ = _mannaquinDenItemHelper.denStateItem.invIdx; - _loc2_ = 0; - while(_loc2_ < _loc3_.length) - { - if(_loc3_.getDenItem(_loc2_).invIdx == _loc4_) - { - _loc3_.getDenItem(_loc2_).mannequinData = _mannaquinDenItemHelper.mannequin.clone(); - break; - } - _loc2_++; - } - AvatarManager.playerAvatar.inventoryDenPartial.denItemCollection = _loc3_; - _loc3_ = AvatarManager.playerAvatar.inventoryDenFull.denItemCollection; - _loc2_ = 0; - while(_loc2_ < _loc3_.length) - { - if(_loc3_.getDenItem(_loc2_).invIdx == _loc4_) - { - _loc3_.getDenItem(_loc2_).mannequinData = _mannaquinDenItemHelper.mannequin.clone(); - break; - } - _loc2_++; - } - gMainFrame.userInfo.playerUserInfo.denItemsFull = _loc3_; - saveState(_loc4_); - } - _mannaquinDenItemHelper = null; - } - - private function onEcoPopupClose() : void - { - _ecoScorePopup.destroy(); - _ecoScorePopup = null; - if(GuiManager.denEditor) - { - GuiManager.denEditor.reloadDenItems(); - } - } - - private function onEcoPointsPopupClose() : void - { - _ecoPointsPopup.destroy(); - _ecoPointsPopup = null; - if(GuiManager.denEditor) - { - GuiManager.denEditor.reloadDenItems(); - } - } - } -} - +package room +{ + import Party.PartyXtCommManager; + import avatar.AvatarManager; + import buddy.BuddyList; + import collection.DenItemCollection; + import collection.DenStateItemCollection; + import com.sbi.bit.BitUtility; + import com.sbi.graphics.SortLayer; + import den.DenItem; + import den.DenStateItem; + import den.DenXtCommManager; + import flash.display.BitmapData; + import flash.display.DisplayObject; + import flash.display.Loader; + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.EventDispatcher; + import flash.events.MouseEvent; + import flash.filters.GlowFilter; + import flash.geom.Matrix; + import flash.geom.Point; + import flash.geom.Rectangle; + import flash.text.TextField; + import flash.text.TextFormat; + import flash.utils.Dictionary; + import game.MinigameManager; + import gui.AvatarEditor; + import gui.EcoPointsPopup; + import gui.EcoScorePopup; + import gui.GenericListGuiManager; + import gui.GuiManager; + import loader.DenItemHelper; + import localization.LocalizationManager; + import quest.QuestManager; + import shop.ShopManager; + + public class DenItemHolder extends EventDispatcher + { + + private const MOUSE_DOWN_TYPE:int = 0; + + private const MOUSE_OVER_TYPE:int = 1; + + private const MOUSE_OUT_TYPE:int = 2; + + private var _currItems:DenStateItemCollection; + + private var _itemsInit:DenStateItemCollection; + + private var _savedDenItemHelpers:Array; + + private var _layerManager:LayerManager; + + private var _dragItem:DenStateItem; + + private var _itemFilter:DenStateItem; + + private var _dragPoint:Point; + + private var _closeBtn:MovieClip; + + private var _flipBtn:MovieClip; + + private var _flipBtnVer:MovieClip; + + private var _linkBtn:MovieClip; + + // These are deliberately part of the selected item's action cluster, + // not the den editor chrome. That keeps them out of the way of the + // inventory and makes their scope obvious, as in the original editor. + private var _sendBehindBtn:Sprite; + + private var _bringToFrontBtn:Sprite; + + private var _naturalDepthBtn:Sprite; + + private var _themePos:Point; + + private var _isWaitingToSetItemsForFirstTime:Boolean; + + private var _roomMode:int; + + private var _lastItemInvId:int; + + private var _itemToEnterInvId:int; + + private var _itemRadiusBmpData:BitmapData; + + private var _lastSelectedItem:DenStateItem; + + private var _mannaquinAvEditor:AvatarEditor; + + private var _mannaquinDenItemHelper:DenItemHelper; + + private var _ecoScorePopup:EcoScorePopup; + + private var _ecoPointsPopup:EcoPointsPopup; + + public function DenItemHolder(param1:LayerManager) + { + super(); + _themePos = new Point(); + _dragPoint = new Point(); + _layerManager = param1; + _closeBtn = GETDEFINITIONBYNAME("closeBtn"); + _closeBtn.addEventListener("mouseDown",onCloseBtn,false,0,true); + _flipBtn = GETDEFINITIONBYNAME("itemRotateBtnCont"); + _flipBtn.addEventListener("mouseDown",onFlipBtn,false,0,true); + _flipBtnVer = GETDEFINITIONBYNAME("itemRotateBtnCont"); + _flipBtnVer.rotation = 90; + _flipBtnVer.addEventListener("mouseDown",onFlipBtn,false,0,true); + _linkBtn = GETDEFINITIONBYNAME("portalLinkBtnCont"); + _linkBtn.addEventListener("mouseDown",onLinkBtn,false,0,true); + _sendBehindBtn = makeLayerButton("Back",onSendBehindBtn); + _bringToFrontBtn = makeLayerButton("Front",onBringToFrontBtn); + _naturalDepthBtn = makeLayerButton("Auto",onNaturalDepthBtn); + release(); + _lastItemInvId = -1; + } + + public function release() : void + { + _isWaitingToSetItemsForFirstTime = true; + if(_currItems) + { + for each(var _loc1_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc1_.denItemHelper) + { + _loc1_.denItemHelper.destroy(); + } + } + } + _currItems = new DenStateItemCollection(); + _itemsInit = new DenStateItemCollection(); + _savedDenItemHelpers = []; + _lastSelectedItem = null; + _dragItem = null; + updateCloseBtn(); + } + + public function clearDen() : void + { + release(); + var _loc1_:DenStateItem = new DenStateItem(617,-1,40435715,0,0,0,50,0,0,3,0,4,0,0,0,"MusDenDef",0,"",0,0,"","",-1,"",false,null,0,0,null,null,2); + setItem(_loc1_); + } + + public function get numberOfInitItems() : int + { + return _itemsInit.length; + } + + public function get numberOfInUseItems() : int + { + return _currItems.length; + } + + public function get isDragging() : Boolean + { + return _dragItem != null; + } + + // The original editor only sorted furniture from its y position. Bits + // 2-3 of `flipped` are unused by the game's flip code, so they safely + // persist a selected item's deliberate stacking choice. + public function sendSelectedBehind() : Boolean + { + return setSelectedStacking(1); + } + + public function bringSelectedToFront() : Boolean + { + return setSelectedStacking(2); + } + + public function resetSelectedStacking() : Boolean + { + return setSelectedStacking(0); + } + + private function setSelectedStacking(param1:int) : Boolean + { + if(!canSetSelectedStacking()) + { + return false; + } + _dragItem.flipped = _dragItem.flipped & -13 | param1 << 2; + if(_dragItem.denItemHelper && _dragItem.denItemHelper.displayObject) + { + _dragItem.denItemHelper.displayObject.name = String(_dragItem.denItemHelper.sortOffset); + // SortLayer will settle on the saved offset at its next heartbeat; + // set the visible order now so the control feels immediate. + if(param1 == 1) + { + _dragItem.denItemHelper.displayObject.parent.setChildIndex(_dragItem.denItemHelper.displayObject,0); + } + else if(param1 == 2) + { + _dragItem.denItemHelper.displayObject.parent.setChildIndex(_dragItem.denItemHelper.displayObject,_dragItem.denItemHelper.displayObject.parent.numChildren - 1); + } + } + saveState(_dragItem.invIdx); + return true; + } + + private function canSetSelectedStacking() : Boolean + { + return _roomMode == 1 && _dragItem != null && _dragItem.layerId != 1 && !isTheme(_dragItem.sortCatId) && _dragItem.sortCatId != 4; + } + + private function makeLayerButton(param1:String, param2:Function) : Sprite + { + var _loc3_:Sprite = new Sprite(); + var _loc4_:TextField = new TextField(); + _loc3_.buttonMode = true; + _loc3_.mouseChildren = false; + _loc3_.graphics.beginFill(2398294,0.96); + _loc3_.graphics.drawRoundRect(0,0,42,24,8,8); + _loc3_.graphics.endFill(); + _loc3_.graphics.lineStyle(1,16774041,0.9); + _loc3_.graphics.drawRoundRect(0,0,42,24,8,8); + _loc4_.width = 42; + _loc4_.height = 20; + _loc4_.y = 3; + _loc4_.selectable = false; + _loc4_.mouseEnabled = false; + _loc4_.defaultTextFormat = new TextFormat("Arial",9,16777215,true,null,null,null,null,"center"); + _loc4_.text = param1; + _loc3_.addChild(_loc4_); + _loc3_.addEventListener("mouseDown",param2,false,0,true); + return _loc3_; + } + + private function onSendBehindBtn(param1:MouseEvent) : void + { + param1.stopImmediatePropagation(); + sendSelectedBehind(); + } + + private function onBringToFrontBtn(param1:MouseEvent) : void + { + param1.stopImmediatePropagation(); + bringSelectedToFront(); + } + + private function onNaturalDepthBtn(param1:MouseEvent) : void + { + param1.stopImmediatePropagation(); + resetSelectedStacking(); + } + + public function get lastSelectedItem() : DenStateItem + { + return _lastSelectedItem; + } + + public function reloadItems() : void + { + var _loc1_:int = 0; + if(_savedDenItemHelpers) + { + _loc1_ = 0; + while(_loc1_ < _savedDenItemHelpers.length) + { + itemLoaded(_savedDenItemHelpers[_loc1_],true); + _loc1_++; + } + } + } + + public function updateConsumers(param1:Dictionary) : void + { + var _loc2_:int = 0; + var _loc3_:int = 0; + for each(var _loc4_:DenStateItem in _currItems.getCoreArray()) + { + for(_loc2_ in param1) + { + if(_loc4_.invIdx == _loc2_) + { + if(!(_loc4_.ecoConsumerStateId == 0 && param1[_loc2_] == 2)) + { + if(!(_loc4_.ecoConsumerStateId == 2 && param1[_loc2_] == 0)) + { + if(_loc4_.ecoConsumerStateId != 2) + { + sendMouseEventToItem(_loc4_.denItemHelper.content as MovieClip); + } + else if(param1[_loc2_] != 2) + { + sendMouseEventToItem(_loc4_.denItemHelper.content as MovieClip); + } + } + } + _loc4_.ecoConsumerStateId = param1[_loc2_]; + } + } + } + var _loc5_:DenItemCollection = gMainFrame.userInfo.playerUserInfo.denItemsPartial; + _loc3_ = 0; + while(_loc3_ < _loc5_.length) + { + for(_loc2_ in param1) + { + if(_loc5_.getDenItem(_loc3_).invIdx == _loc2_) + { + _loc5_.getDenItem(_loc3_).ecoConsumerStateId = param1[_loc2_]; + break; + } + } + _loc3_++; + } + AvatarManager.playerAvatar.inventoryDenPartial.denItemCollection = _loc5_; + _loc5_ = AvatarManager.playerAvatar.inventoryDenFull.denItemCollection; + _loc3_ = 0; + while(_loc3_ < _loc5_.length) + { + for(_loc2_ in param1) + { + if(_loc5_.getDenItem(_loc3_).invIdx == _loc2_) + { + _loc5_.getDenItem(_loc3_).ecoConsumerStateId = param1[_loc2_]; + break; + } + } + _loc3_++; + } + gMainFrame.userInfo.playerUserInfo.denItemsFull = _loc5_; + } + + public function setItems(param1:DenStateItemCollection, param2:Boolean = false) : void + { + var _loc8_:DenStateItem = null; + var _loc4_:* = null; + var _loc3_:Boolean = false; + var _loc7_:int = 0; + var _loc5_:Number = NaN; + var _loc6_:Number = NaN; + var _loc10_:DenStateItem = null; + var _loc9_:Boolean = false; + if(_isWaitingToSetItemsForFirstTime && param2) + { + _isWaitingToSetItemsForFirstTime = false; + } + _loc7_ = 0; + while(_loc7_ < param1.length) + { + _loc8_ = param1.getDenStateItem(_loc7_); + if(_loc8_) + { + if(_loc8_.catId > 0) + { + _loc3_ = false; + for each(_loc4_ in _currItems.getCoreArray()) + { + if(_loc8_.refId == _loc4_.refId && _loc8_.invIdx == _loc4_.invIdx) + { + _loc4_.flipped = _loc8_.flipped; + _loc5_ = _loc8_.x + _loc4_.offsetX; + _loc6_ = _loc8_.y + _loc4_.offsetY; + setItemMatrix(_loc4_,_loc5_,_loc6_,_loc4_.flipped); + if(_loc4_.sortCatId == 99 && _loc4_.denItemHelper) + { + _loc4_.denItemHelper.setVersion(_loc8_.version,_loc8_.version2,_loc8_.version3); + } + if(_loc4_.specialType == 1) + { + _loc4_.userNameLink = _loc8_.userNameLink; + if(_loc4_.denItemHelper && _loc4_.denItemHelper.content && _loc4_.denItemHelper.content.hasOwnProperty("active")) + { + if(_loc4_.userNameLink != "") + { + Object(_loc4_.denItemHelper.content).active(true); + } + else + { + Object(_loc4_.denItemHelper.content).active(false); + } + } + BuddyList.destroyInWorldBuddyList(); + } + if(_loc4_.uniqueImageId != _loc8_.uniqueImageId) + { + _loc4_.uniqueImageId = _loc8_.uniqueImageId; + _loc4_.uniqueImageCreator = _loc8_.uniqueImageCreator; + if(_loc4_.denItemHelper) + { + (_loc4_.denItemHelper as DenItemHelper).uniqueImageId = _loc4_.uniqueImageId; + (_loc4_.denItemHelper as DenItemHelper).uniqueImageCreator = _loc4_.uniqueImageCreator; + (_loc4_.denItemHelper as DenItemHelper).loadUniqueImage(); + } + } + if(_loc4_.specialType == 4) + { + if(!_loc4_.mannequinData.compare(_loc8_.mannequinData,true)) + { + _loc4_.mannequinData.copyFromOther(_loc8_.mannequinData); + } + } + _loc4_.ecoConsumerStateId = _loc8_.ecoConsumerStateId; + _loc3_ = true; + break; + } + } + if(!_loc3_) + { + _loc10_ = _loc8_.clone(); + _loc10_.userAction = param2; + setItem(_loc10_); + } + } + else + { + for each(_loc4_ in _currItems.getCoreArray()) + { + if(_loc8_.refId == _loc4_.refId && _loc8_.invIdx == _loc4_.invIdx) + { + releaseItem(_loc4_,param2); + if(_loc4_.specialType == 5) + { + ShopManager.ifShopToSellOpenCloseIt(); + } + break; + } + } + } + } + _loc7_++; + } + for each(_loc4_ in _currItems.getCoreArray()) + { + if(_loc4_.sortCatId == 4) + { + _loc9_ = true; + break; + } + } + if(!_loc9_) + { + _loc8_ = new DenStateItem(0,-1,40435715,0,0,0,50,0,0,3,0,4,0,0,0,"MusDenDef",0,"",0,0,"","",-1,"",param2,null,0,0,null,null,2); + setItem(_loc8_); + } + if(!param2) + { + updateInitialState(); + } + if(_isWaitingToSetItemsForFirstTime) + { + _isWaitingToSetItemsForFirstTime = false; + } + } + + public function rebuildMannequins() : void + { + var _loc1_:* = null; + for each(_loc1_ in _currItems.getCoreArray()) + { + if(_loc1_.mannequinData != null) + { + _loc1_.mannequinData.refreshAvatarItems(); + } + } + } + + public function removeAccessoryAndRebuildMannequin(param1:DenItem, param2:int, param3:int) : void + { + var _loc6_:DenStateItem = null; + var _loc5_:int = 0; + var _loc4_:Boolean = false; + for each(_loc6_ in _currItems.getCoreArray()) + { + if(_loc6_.mannequinData != null && _loc6_.invIdx == param2) + { + _loc6_.mannequinData.hasThisInvIdOnAndRemove(param3); + _loc6_.mannequinData.refreshAvatarItems(); + _loc4_ = true; + break; + } + } + if(!_loc4_) + { + _loc6_ = new DenStateItem(param1.defId,param1.invIdx,param1.defId << 16 | param1.categoryId,0,0,param1.version,param1.version2,param1.version3,0,param1.categoryId,param1.refId,param1.sortId,param1.minigameDefId,param1.layerId,param1.enviroType,param1.strmName,0,"",param1.specialType,param1.listId,param1.uniqueImageId,param1.uniqueImageCreator,param1.uniqueImageCreatorDbId,param1.uniqueImageCreatorUUID,false,null,0,0,param1.petItem,param1.mannequinData,param1.ecoConsumerStateId); + _loc5_ = 0; + while(_loc5_ < _itemsInit.length) + { + if(_itemsInit.getDenStateItem(_loc5_).mannequinData != null && _itemsInit.getDenStateItem(_loc5_).mannequinData.invIdx == param2) + { + _loc4_ = true; + _itemsInit.setDenStateItem(_loc5_,_loc6_.clone()); + break; + } + _loc5_++; + } + if(!_loc4_) + { + _itemsInit.pushDenStateItem(_loc6_.clone()); + } + } + } + + public function removeItem(param1:int, param2:int) : void + { + for each(var _loc3_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc3_.refId == param2 && _loc3_.invIdx == param1) + { + releaseItem(_loc3_); + break; + } + } + } + + public function saveState(param1:int = -1) : void + { + var _loc2_:* = null; + var _loc13_:* = null; + var _loc7_:Boolean = false; + var _loc12_:Boolean = false; + var _loc4_:Object = null; + var _loc9_:* = null; + var _loc8_:int = 0; + var _loc5_:DenItemHolderEvent = null; + var _loc3_:Array = null; + var _loc10_:int = 0; + var _loc11_:int = 0; + var _loc6_:Array = []; + for each(_loc2_ in _itemsInit.getCoreArray()) + { + _loc7_ = false; + for each(_loc13_ in _currItems.getCoreArray()) + { + if(_loc13_.refId == _loc2_.refId && _loc13_.invIdx == _loc2_.invIdx) + { + _loc7_ = true; + if(_loc13_.sortCatId != 4 && (_loc13_.x != _loc2_.x || _loc13_.y != _loc2_.y || _loc13_.flipped != _loc2_.flipped || _loc13_.userNameLink != _loc2_.userNameLink || _loc13_.uniqueImageId != _loc2_.uniqueImageId || _loc13_.uniqueImageCreator != _loc2_.uniqueImageCreator || _loc13_.mannequinData == null && _loc2_.mannequinData != null || _loc13_.mannequinData != null && !_loc13_.mannequinData.compare(_loc2_.mannequinData,true))) + { + if(_loc13_.mannequinData == null && _loc2_.mannequinData != null || _loc13_.mannequinData != null && !_loc13_.mannequinData.compare(_loc2_.mannequinData,true)) + { + _loc12_ = true; + } + _loc6_.push({ + "di":_loc13_.denItemHelper, + "f":_loc13_.flipped, + "i":_loc13_.invIdx, + "x":_loc13_.x, + "s":_loc13_.sortCatId, + "y":_loc13_.y, + "offX":_loc13_.offsetX, + "offY":_loc13_.offsetY, + "r":_loc13_.refId, + "userNameLink":_loc13_.userNameLink, + "uniqueImageId":_loc13_.uniqueImageId, + "uniqueImageCreator":_loc13_.uniqueImageCreator, + "mannequinData":_loc13_.mannequinData + }); + } + break; + } + } + if(!_loc7_) + { + _loc6_.push({ + "f":0, + "i":_loc2_.invIdx, + "s":_loc2_.sortCatId, + "x":0, + "y":0, + "d":0, + "r":_loc2_.refId, + "userNameLink":"", + "uniqueImageId":"", + "uniqueImageCreator":"", + "mannequinData":_loc2_.mannequinData + }); + } + } + for each(_loc13_ in _currItems.getCoreArray()) + { + _loc7_ = false; + for each(_loc2_ in _itemsInit.getCoreArray()) + { + if(_loc2_.refId == _loc13_.refId && _loc2_.invIdx == _loc13_.invIdx) + { + _loc7_ = true; + break; + } + } + if(!_loc7_) + { + _loc6_.push({ + "f":_loc13_.flipped, + "di":_loc13_.defId, + "i":_loc13_.invIdx, + "s":_loc13_.sortCatId, + "x":_loc13_.x, + "y":_loc13_.y, + "offX":_loc13_.offsetX, + "offY":_loc13_.offsetY, + "r":_loc13_.refId, + "userNameLink":_loc13_.userNameLink, + "uniqueImageId":_loc13_.uniqueImageId, + "uniqueImageCreator":_loc13_.uniqueImageCreator, + "mannequinData":_loc13_.mannequinData + }); + } + } + if(_loc6_.length > 0) + { + updateInitialState(); + if(param1 != -1) + { + _loc8_ = 0; + while(_loc8_ < _loc6_.length) + { + if(_loc6_[_loc8_].i == param1) + { + _loc6_.push(_loc6_[_loc8_]); + _loc6_.splice(_loc8_,1); + break; + } + _loc8_++; + } + } + _loc5_ = new DenItemHolderEvent("OnSaveState"); + _loc3_ = []; + for each(_loc9_ in _loc6_) + { + if(_loc9_.i != -1) + { + if(_loc9_.di) + { + _loc10_ = _loc9_.x - _loc9_.offX; + _loc11_ = _loc9_.y - _loc9_.offY; + _loc4_ = { + "i":_loc9_.i, + "s":_loc9_.s, + "d":1, + "x":_loc10_, + "y":_loc11_, + "f":_loc9_.f, + "r":_loc9_.r, + "userNameLink":_loc9_.userNameLink, + "uniqueImageId":_loc9_.uniqueImageId, + "uniqueImageCreator":_loc9_.uniqueImageCreator, + "mannequinData":_loc9_.mannequinData + }; + } + else + { + _loc4_ = { + "i":_loc9_.i, + "s":_loc9_.s, + "d":0, + "x":0, + "y":0, + "f":0, + "r":_loc9_.r, + "userNameLink":_loc9_.userNameLink, + "uniqueImageId":_loc9_.uniqueImageId, + "uniqueImageCreator":_loc9_.uniqueImageCreator, + "mannequinData":_loc9_.mannequinData + }; + } + _loc3_.push(_loc4_); + } + } + _loc5_.array = _loc3_; + _loc5_.hasUpdates = _loc12_; + dispatchEvent(_loc5_); + } + } + + public function removeHighlightState() : void + { + if(_closeBtn.parent) + { + _closeBtn.parent.removeChild(_closeBtn); + } + if(_flipBtn.parent) + { + _flipBtn.parent.removeChild(_flipBtn); + } + if(_linkBtn.parent) + { + _linkBtn.parent.removeChild(_linkBtn); + } + removeLayerButtons(); + if(_itemFilter) + { + if(_itemFilter.denItemHelper.displayObject) + { + _itemFilter.denItemHelper.displayObject.filters = []; + } + _itemFilter = null; + } + } + + private function updateInitialState() : void + { + _itemsInit = new DenStateItemCollection(); + for each(var _loc1_:DenStateItem in _currItems.getCoreArray()) + { + _itemsInit.pushDenStateItem(_loc1_.clone()); + } + } + + public function handleMouse(param1:Number, param2:Number, param3:Boolean) : void + { + var _loc5_:Number = NaN; + var _loc4_:Number = NaN; + var _loc6_:DenStateItem = null; + if(param3) + { + if(_dragItem) + { + if(_dragItem.specialType == 1) + { + if(BuddyList.isOverWorldBuddyList(param1,param2)) + { + RoomManagerWorld.instance.forceMouseUp(); + return; + } + } + _loc5_ = _dragItem.x + param1 - _dragPoint.x; + _loc4_ = _dragItem.y + param2 - _dragPoint.y; + setItemMatrix(_dragItem,_loc5_,_loc4_,_dragItem.flipped); + setBtnPos(_loc5_ + _dragItem.denItemHelper.contentWidth - 30,_loc4_); + _dragPoint.x = param1; + _dragPoint.y = param2; + } + } + else + { + // The room treats a mouse-up over empty space as a deselect. The + // selected item's action cluster lives in that empty space, so + // keep the selection while the pointer crosses into its buttons. + if(_dragItem && isOverLayerActionArea(param1,param2)) + { + return; + } + if(_dragItem && _dragItem.specialType == 1) + { + _loc6_ = hitTest(param1,param2); + if(BuddyList.isOverWorldBuddyList(param1,param2)) + { + return; + } + if(_loc6_ != _dragItem) + { + BuddyList.closeWorldBuddyList(); + _dragItem = _loc6_; + } + } + else + { + _dragItem = hitTest(param1,param2); + } + if(_dragItem) + { + _dragPoint.x = param1; + _dragPoint.y = param2; + } + updateCloseBtn(); + } + } + + public function setThemePosition(param1:int, param2:int) : void + { + _themePos = new Point(param1,param2); + } + + public function setRoomMode(param1:int) : void + { + _roomMode = param1; + stopListenersOnPets(_roomMode == 1); + stopMouseOnNonMouseItems(_roomMode == 1); + } + + public function stopListenersOnPets(param1:Boolean) : void + { + for each(var _loc2_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc2_.denItemHelper && _loc2_.denItemHelper.content && _loc2_.denItemHelper.content.hasOwnProperty("listenToMouse")) + { + if(_loc2_.specialType != 7) + { + Object(_loc2_.denItemHelper.content).listenToMouse = !param1; + } + } + } + } + + public function stopMouseOnNonMouseItems(param1:Boolean) : void + { + for each(var _loc2_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc2_.denItemHelper && _loc2_.denItemHelper.content && _loc2_.denItemHelper.content.hasOwnProperty("ignoreMouseCompletely") && _loc2_.denItemHelper.displayObject) + { + Sprite(_loc2_.denItemHelper.displayObject).mouseEnabled = !param1; + Sprite(_loc2_.denItemHelper.displayObject).mouseChildren = !param1; + } + } + } + + public function shouldStopMovement(param1:Point) : Boolean + { + var _loc6_:Loader = null; + var _loc5_:DenStateItem = null; + var _loc3_:MovieClip = null; + var _loc4_:int = 0; + var _loc2_:int = int(_currItems.length); + if(_loc2_ > 0) + { + _loc4_ = 0; + while(_loc4_ < _loc2_) + { + _loc5_ = _currItems.getDenStateItem(_loc4_); + if(!isTheme(_loc5_.sortCatId) && _loc5_.sortCatId != 4) + { + // a custom den item's own picture is a Bitmap here, no + // Loader: the cast threw at every click in the den, and + // nobody there could walk + _loc6_ = _loc5_.denItemHelper && _loc5_.denItemHelper.displayObject.numChildren > 0 ? _loc5_.denItemHelper.displayObject.getChildAt(0) as Loader : null; + _loc3_ = _loc6_ != null ? _loc6_.content as MovieClip : null; + if(_loc3_ != null) + { + if(_loc3_.parent.name == "moveToDisabled") + { + if(_loc3_.hitTestPoint(param1.x,param1.y,true)) + { + return true; + } + } + } + } + _loc4_++; + } + } + return false; + } + + public function portalItemTest(param1:Boolean, param2:Point) : void + { + var _loc4_:int = 0; + var _loc7_:DenStateItem = null; + var _loc6_:int = 0; + var _loc3_:Sprite = null; + var _loc5_:Object = null; + if(!RoomXtCommManager.isSwitching) + { + _loc4_ = int(_currItems.length); + if(_loc4_ > 0) + { + _loc6_ = 0; + while(_loc6_ < _loc4_) + { + _loc7_ = _currItems.getDenStateItem(_loc6_); + if(_loc7_.specialType == 1 && _loc7_.userNameLink != "" || _loc7_.specialType == 3) + { + if(_loc7_.denItemHelper.content) + { + if(param1) + { + if(Object(_loc7_.denItemHelper.displayObject.getChildAt(0)).content.clickObject.hitTestPoint(param2.x,param2.y,true)) + { + _loc3_ = Sprite(Object(_loc7_.denItemHelper.displayObject.getChildAt(0)).content.radiusObject); + _itemToEnterInvId = _loc7_.invIdx; + _itemRadiusBmpData = new BitmapData(_loc3_.width,_loc3_.height); + _itemRadiusBmpData.draw(_loc3_); + } + else + { + _itemToEnterInvId = -1; + if(_itemRadiusBmpData) + { + _itemRadiusBmpData.dispose(); + _itemRadiusBmpData = null; + } + } + _lastItemInvId = -1; + } + if(_itemToEnterInvId == _loc7_.invIdx) + { + _loc5_ = Object(_loc7_.denItemHelper.content).getRadiusObject(); + if(!AvatarManager.playerAvatarWorldView.bmpDataHitTest(_itemRadiusBmpData,new Point(_loc7_.x + _loc5_.x,_loc7_.y + _loc5_.y))) + { + return; + } + if(_lastItemInvId == _loc7_.invIdx) + { + return; + } + if(_lastItemInvId == -1) + { + if(_loc7_.specialType == 3) + { + DenXtCommManager.requestDenPhantom(AvatarManager.playerAvatarWorldView.isPhantom ? 0 : 1); + } + else + { + RoomXtCommManager.sendRoomJoinRequest("den" + _loc7_.userNameLink,_loc7_.invIdx); + } + _lastItemInvId = _loc7_.invIdx; + return; + } + } + } + } + _loc6_++; + } + } + } + _lastItemInvId = -1; + } + + private function isTheme(param1:int) : Boolean + { + return param1 > 1 && param1 < 4; + } + + private function setItem(param1:DenStateItem) : void + { + var _loc4_:DenItemHolderEvent = null; + var _loc2_:DenItemHolderEvent = null; + var _loc3_:DenItemHelper = new DenItemHelper(); + if(isTheme(param1.sortCatId)) + { + for each(var _loc5_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc5_.sortCatId == param1.sortCatId) + { + releaseItem(_loc5_); + _loc4_ = new DenItemHolderEvent("OnItemRemoved"); + _loc4_.id = _loc5_.invIdx; + _loc4_.refId = _loc5_.refId; + _loc4_.array = [_loc5_]; + dispatchEvent(_loc4_); + break; + } + } + } + else if(param1.sortCatId == 4) + { + for each(var _loc6_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc6_.sortCatId == param1.sortCatId) + { + releaseItem(_loc6_); + _loc2_ = new DenItemHolderEvent("OnItemRemoved"); + _loc2_.id = _loc6_.invIdx; + _loc2_.refId = _loc6_.refId; + _loc2_.array = [_loc6_]; + dispatchEvent(_loc2_); + break; + } + } + RoomManagerWorld.instance.playMusic(param1.strmName + ".mp3",param1.version2 / 100); + } + param1.denItemHelper = _loc3_; + _currItems.pushDenStateItem(param1); + _loc3_.initDS(param1,itemLoaded); + if(_roomMode == 1) + { + if(param1.denItemHelper && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("listenToMouse")) + { + Object(param1.denItemHelper.content).listenToMouse = false; + } + } + else if(param1.denItemHelper && param1.denItemHelper.displayObject && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("ignoreMouseCompletely")) + { + Sprite(param1.denItemHelper.displayObject).mouseEnabled = false; + Sprite(param1.denItemHelper.displayObject).mouseChildren = false; + } + if(param1.denItemHelper && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("active")) + { + if(param1.userNameLink != "") + { + Object(param1.denItemHelper.content).active(true); + } + else + { + Object(param1.denItemHelper.content).active(false); + } + } + if(param1.minigameDefId > 0 || param1.listLauncherId > 0 || _loc3_.isUniqueImageItem) + { + addListenersToItem(_loc3_,param1); + } + else if(param1.specialType == 1) + { + addPortalListenersToItem(_loc3_,param1); + } + else if(param1.specialType == 2) + { + _loc3_.setupItemWithEmotes(param1); + } + else if(param1.defId == 3192 || param1.defId == 3193 || param1.defId == 3250 || param1.defId == 3585) + { + addListenersToItem(_loc3_,param1); + } + else if(param1.defId >= 3312 && param1.defId <= 3319) + { + addListenersToItem(_loc3_,param1); + } + else if(param1.specialType == 5) + { + addListenersToItem(_loc3_,param1); + } + else if(RoomManagerWorld.instance.isMyDen) + { + if(param1.defId == 3216) + { + addListenersToItem(_loc3_,param1); + } + else if(param1.specialType == 4) + { + addListenersToItem(_loc3_,param1); + } + else if(param1.specialType == 6) + { + addListenersToItem(_loc3_,param1); + } + else if(param1.specialType == 7) + { + if(param1.denItemHelper && param1.denItemHelper.content && param1.denItemHelper.content.hasOwnProperty("listenToMouse")) + { + Object(param1.denItemHelper.content).listenToMouse = false; + } + addListenersToItem(_loc3_,param1); + } + } + if(_isWaitingToSetItemsForFirstTime || !param1.userAction) + { + _itemsInit.pushDenStateItem(param1.clone()); + } + } + + private function updateCloseBtn() : void + { + if(_dragItem) + { + if(_closeBtn.parent != _dragItem.denItemHelper.displayObject) + { + setBtnPos(_dragItem.x + _dragItem.denItemHelper.contentWidth - 30,_dragItem.y); + _layerManager.room_chat.addChild(_closeBtn); + _layerManager.room_chat.addChild(_flipBtn); + _layerManager.room_chat.addChild(_flipBtnVer); + if(_dragItem.specialType == 1) + { + _layerManager.room_chat.addChild(_linkBtn); + } + else if(_linkBtn.parent) + { + _linkBtn.parent.removeChild(_linkBtn); + BuddyList.closeWorldBuddyList(); + } + } + updateLayerButtons(); + if(_itemFilter != _dragItem) + { + if(_itemFilter) + { + _itemFilter.denItemHelper.displayObject.filters = []; + } + _itemFilter = _dragItem; + _itemFilter.denItemHelper.displayObject.filters = [new GlowFilter(16777215,1,8,8,8)]; + } + } + else + { + if(_closeBtn.parent) + { + _closeBtn.parent.removeChild(_closeBtn); + } + if(_flipBtn.parent) + { + _flipBtn.parent.removeChild(_flipBtn); + } + if(_flipBtnVer.parent) + { + _flipBtnVer.parent.removeChild(_flipBtnVer); + } + if(_linkBtn.parent) + { + _linkBtn.parent.removeChild(_linkBtn); + BuddyList.closeWorldBuddyList(); + } + removeLayerButtons(); + if(_itemFilter) + { + if(_itemFilter.denItemHelper.displayObject) + { + _itemFilter.denItemHelper.displayObject.filters = []; + } + _itemFilter = null; + } + } + } + + private function setBtnPos(param1:Number, param2:Number) : void + { + _closeBtn.x = param1; + _closeBtn.y = param2; + _flipBtn.x = param1 + 15; + _flipBtn.y = param2 + 55; + _flipBtnVer.x = param1 + 15; + _flipBtnVer.y = param2 + 90; + _linkBtn.x = param1 + 15; + _linkBtn.y = param2 + 125; + _sendBehindBtn.x = param1 + 42; + _sendBehindBtn.y = param2; + _bringToFrontBtn.x = param1 + 42; + _bringToFrontBtn.y = param2 + 27; + _naturalDepthBtn.x = param1 + 42; + _naturalDepthBtn.y = param2 + 54; + BuddyList.updateWorldBuddyListPosition(_linkBtn); + } + + private function updateLayerButtons() : void + { + if(!canSetSelectedStacking()) + { + removeLayerButtons(); + return; + } + if(_sendBehindBtn.parent != _layerManager.room_chat) + { + _layerManager.room_chat.addChild(_sendBehindBtn); + _layerManager.room_chat.addChild(_bringToFrontBtn); + _layerManager.room_chat.addChild(_naturalDepthBtn); + } + } + + private function removeLayerButtons() : void + { + if(_sendBehindBtn.parent) + { + _sendBehindBtn.parent.removeChild(_sendBehindBtn); + } + if(_bringToFrontBtn.parent) + { + _bringToFrontBtn.parent.removeChild(_bringToFrontBtn); + } + if(_naturalDepthBtn.parent) + { + _naturalDepthBtn.parent.removeChild(_naturalDepthBtn); + } + } + + private function isOverLayerActionArea(param1:Number, param2:Number) : Boolean + { + var _loc3_:Rectangle = null; + if(_sendBehindBtn.parent == null) + { + return false; + } + // Treat the item and its controls as one continuous selection area. + // This bridges any empty pixels between a large item and its buttons. + _loc3_ = _dragItem.denItemHelper.displayObject.getBounds(_layerManager.room_avatars); + return param1 >= Math.min(_loc3_.left,_sendBehindBtn.x) - 12 && param1 <= Math.max(_loc3_.right,_sendBehindBtn.x + _sendBehindBtn.width) + 12 && param2 >= Math.min(_loc3_.top,_sendBehindBtn.y) - 12 && param2 <= Math.max(_loc3_.bottom,_naturalDepthBtn.y + _naturalDepthBtn.height) + 12; + } + + private function onCloseBtn(param1:Event) : void + { + var _loc2_:DenItemHolderEvent = null; + param1.stopPropagation(); + if(_dragItem) + { + _loc2_ = new DenItemHolderEvent("OnItemRemoved"); + _loc2_.id = _dragItem.invIdx; + _loc2_.refId = _dragItem.refId; + _loc2_.array = [_dragItem]; + releaseItem(_dragItem); + _dragItem = null; + updateCloseBtn(); + dispatchEvent(_loc2_); + } + } + + private function onFlipBtn(param1:Event) : void + { + param1.stopPropagation(); + if(_dragItem) + { + if(param1.currentTarget == _flipBtn) + { + _dragItem.flipped = !BitUtility.isBitSetForNumber(0,_dragItem.flipped) ? _dragItem.flipped ^ 1 : _dragItem.flipped ^ 1; + setItemMatrix(_dragItem,_dragItem.x,_dragItem.y,_dragItem.flipped); + } + else if(param1.currentTarget == _flipBtnVer) + { + if(!BitUtility.isBitSetForNumber(1,_dragItem.flipped)) + { + _dragItem.flipped |= 2; + } + else + { + _dragItem.flipped = !BitUtility.isBitSetForNumber(1,_dragItem.flipped) ? _dragItem.flipped | 2 : _dragItem.flipped ^ 2; + } + setItemMatrix(_dragItem,_dragItem.x,_dragItem.y,_dragItem.flipped); + } + } + } + + private function onLinkBtn(param1:MouseEvent) : void + { + param1.stopPropagation(); + if(_dragItem) + { + BuddyList.buildInWorldBuddyList(_linkBtn,_dragItem,onSelectUserToLink,_dragItem.userNameLink); + } + } + + private function onSelectUserToLink(param1:String) : void + { + if(_dragItem) + { + _dragItem.userNameLink = param1; + if(_dragItem.denItemHelper && _dragItem.denItemHelper.content && _dragItem.denItemHelper.content.hasOwnProperty("active")) + { + if(param1 != "") + { + Object(_dragItem.denItemHelper.content).active(true); + } + else + { + Object(_dragItem.denItemHelper.content).active(false); + } + } + } + } + + private function isInInitList(param1:int, param2:int) : Boolean + { + var _loc3_:int = 0; + _loc3_ = 0; + while(_loc3_ < _itemsInit.length) + { + if(_itemsInit.getDenStateItem(_loc3_).refId == param2 && _itemsInit.getDenStateItem(_loc3_).invIdx == param1) + { + return true; + } + _loc3_++; + } + return false; + } + + private function releaseItem(param1:DenStateItem, param2:Boolean = true) : void + { + var _loc3_:int = _currItems.getCoreArray().indexOf(param1); + if(_loc3_ >= 0) + { + _currItems.getCoreArray().splice(_loc3_,1); + if(param1.defId) + { + if(param1.denItemHelper.displayObject.parent) + { + param1.denItemHelper.displayObject.parent.removeChild(param1.denItemHelper.displayObject); + } + if(param1.denItemHelper.minigameDefId > 0 || param1.denItemHelper.listLauncherId > 0 || param1.denItemHelper.uniqueImageId != "") + { + removeListenersFromItem(param1.denItemHelper); + } + else if(param1.specialType == 1) + { + removePortalListenersFromItem(param1.denItemHelper); + } + else if(param1.defId == 3192 || param1.defId == 3193 || param1.defId == 3250 || param1.defId == 3585) + { + removeListenersFromItem(param1.denItemHelper); + } + else if(param1.defId >= 3312 && param1.defId <= 3319) + { + removeListenersFromItem(param1.denItemHelper); + } + else if(RoomManagerWorld.instance.isMyDen) + { + if(param1.defId == 3216) + { + removeListenersFromItem(param1.denItemHelper); + } + else if(param1.specialType == 4) + { + removeListenersFromItem(param1.denItemHelper); + if(param1.mannequinData && !param2) + { + param1.mannequinData.removeItems(); + } + } + } + else if(param1.specialType == 5) + { + removeListenersFromItem(param1.denItemHelper); + } + if(param1.specialType == 1) + { + removePortalListenersFromItem(param1.denItemHelper); + _lastItemInvId = -1; + _itemToEnterInvId = -1; + } + if(_itemRadiusBmpData) + { + _itemRadiusBmpData.dispose(); + _itemRadiusBmpData = null; + } + } + } + if(!param2) + { + _loc3_ = 0; + while(_loc3_ < _itemsInit.length) + { + if(_itemsInit.getDenStateItem(_loc3_).invIdx == param1.invIdx) + { + _itemsInit.getCoreArray().splice(_loc3_,1); + break; + } + _loc3_++; + } + } + _lastSelectedItem = null; + } + + private function setItemMatrix(param1:DenStateItem, param2:Number, param3:Number, param4:int) : void + { + var _loc14_:Sprite = null; + var _loc10_:Loader = null; + var _loc13_:MovieClip = null; + var _loc11_:Matrix = null; + var _loc12_:Number = NaN; + var _loc8_:Number = NaN; + var _loc5_:DisplayObject = param1.denItemHelper.displayObject; + param1.x = param2; + param1.y = param3; + var _loc9_:Matrix = _loc5_.transform.matrix; + _loc9_.identity(); + var _loc6_:Number = param2; + var _loc7_:Number = param3; + if(param1.denItemHelper.bFlipLabel) + { + _loc14_ = _loc5_ as Sprite; + _loc10_ = _loc14_.getChildAt(0) as Loader; + _loc13_ = _loc10_.content as MovieClip; + _loc13_.gotoAndStop(BitUtility.isBitSetForNumber(0,param4) ? "flip" : 1); + if(BitUtility.isBitSetForNumber(1,param4)) + { + _loc7_ += _loc5_.height; + _loc6_ += _loc5_.width; + } + } + else if(param4 > 0) + { + if(BitUtility.isBitSetForNumber(0,param4)) + { + _loc6_ += _loc5_.width; + } + if(BitUtility.isBitSetForNumber(1,param4)) + { + if(param1.denItemHelper.isUniqueImageItem) + { + _loc7_ += _loc5_.height * 0.8; + if(!BitUtility.isBitSetForNumber(0,param4)) + { + _loc6_ += _loc5_.width; + } + else + { + _loc6_ -= _loc5_.width; + } + } + else + { + _loc7_ += _loc5_.height; + if(!BitUtility.isBitSetForNumber(0,param4)) + { + _loc6_ += _loc5_.width; + } + else + { + _loc6_ -= _loc5_.width; + } + } + } + _loc9_.scale(BitUtility.isBitSetForNumber(0,param4) ? -1 : 1,1); + } + if(param1.denItemHelper.isUniqueImageItem) + { + _loc11_ = Object(param1.denItemHelper.content).item1.imageCont.transform.matrix; + _loc12_ = Math.abs(_loc11_.b); + _loc8_ = Math.abs(_loc11_.a); + _loc11_.a = 1; + _loc11_.b = 1; + _loc11_.a = BitUtility.isBitSetForNumber(0,param4) ? -1 : 1; + _loc11_.b = BitUtility.isBitSetForNumber(0,param4) ? -1 : 1; + _loc11_.a *= _loc8_; + _loc11_.b *= _loc12_; + Object(param1.denItemHelper.content).item1.imageCont.transform.matrix = _loc11_; + } + _loc9_.translate(_loc6_,_loc7_); + _loc5_.transform.matrix = _loc9_; + if(BitUtility.isBitSetForNumber(1,param4)) + { + _loc5_.rotation = 180; + } + else + { + _loc5_.rotation = 0; + } + } + + private function hitTest(param1:int, param2:int) : DenStateItem + { + var _loc3_:DenStateItem = null; + var _loc7_:int = 0; + var _loc9_:DenStateItem = null; + var _loc6_:DisplayObject = null; + var _loc4_:Rectangle = null; + var _loc10_:Number = NaN; + var _loc8_:Number = -999999999; + var _loc11_:int = 99999999; + var _loc5_:int = int(_currItems.length); + while(_loc7_ < _loc5_) + { + _loc9_ = _currItems.getDenStateItem(_loc7_); + if(!isTheme(_loc9_.sortCatId)) + { + _loc6_ = _loc9_.denItemHelper.displayObject; + _loc4_ = _loc6_.getBounds(_layerManager.room_avatars); + _loc4_.height = Math.max(105,_loc4_.height); + _loc10_ = _loc4_.bottom - Number(_loc6_.name); + if(param1 > _loc4_.left && param1 < _loc4_.right && param2 > _loc4_.top && param2 < _loc4_.bottom) + { + if(_loc9_.layerId <= _loc11_) + { + if(_loc9_.layerId == 1 || _loc10_ > _loc8_) + { + _loc11_ = _loc9_.layerId; + _loc8_ = _loc10_; + _loc3_ = _loc9_; + if(_loc11_ == 1) + { + _loc8_ = -999999999; + } + } + } + } + } + _loc7_++; + } + return _loc3_; + } + + private function itemLoaded(param1:DenItemHelper, param2:Boolean = false) : void + { + var _loc8_:DenStateItem = null; + var _loc3_:Sprite = null; + var _loc5_:Number = NaN; + var _loc7_:Number = NaN; + var _loc4_:Boolean = false; + var _loc11_:int = 0; + var _loc10_:int = 0; + var _loc12_:SortLayer = null; + if(!param2) + { + _savedDenItemHelpers.push(param1); + } + for each(var _loc9_:DenStateItem in _currItems.getCoreArray()) + { + if(_loc9_.denItemHelper == param1) + { + _loc8_ = _loc9_; + break; + } + } + if(_loc8_ && _loc8_.sortCatId != 4) + { + _loc3_ = param1.displayObject; + _loc8_.offsetX = -(param1.contentWidth * 0.5); + _loc8_.offsetY = -param1.contentHeight; + if(param2) + { + _loc8_.x -= _loc8_.offsetX; + _loc8_.y -= _loc8_.offsetY; + } + _loc5_ = _loc8_.x + _loc8_.offsetX; + _loc7_ = _loc8_.y + _loc8_.offsetY; + _loc4_ = _loc8_.newPlaced; + if(_loc8_.newPlaced) + { + _loc7_ += param1.contentHeight * 0.5; + _loc8_.newPlaced = false; + } + if(_roomMode == 1 || _loc8_.specialType == 7) + { + if(_loc8_.denItemHelper && _loc8_.denItemHelper.content && _loc8_.denItemHelper.content.hasOwnProperty("listenToMouse")) + { + Object(_loc8_.denItemHelper.content).listenToMouse = false; + } + } + else if(_loc3_ && _loc8_.denItemHelper && _loc8_.denItemHelper.content && _loc8_.denItemHelper.content.hasOwnProperty("ignoreMouseCompletely")) + { + Sprite(_loc3_).mouseEnabled = false; + Sprite(_loc3_).mouseChildren = false; + } + if(_loc8_.denItemHelper && _loc8_.denItemHelper.content && _loc8_.denItemHelper.content.hasOwnProperty("active")) + { + if(_loc8_.userNameLink != "") + { + Object(_loc8_.denItemHelper.content).active(true); + } + else + { + Object(_loc8_.denItemHelper.content).active(false); + } + } + if(_loc8_.denItemHelper) + { + if(_loc8_.denItemHelper.isUniqueImageItem) + { + addListenersToItem(_loc8_.denItemHelper,_loc8_); + } + } + if(_loc8_.specialType == 7 && _loc8_.ecoConsumerStateId == 1) + { + sendMouseEventToItem(_loc8_.denItemHelper.content as MovieClip); + } + _loc10_ = _loc8_.layerId; + setItemMatrix(_loc8_,_loc5_,_loc7_,_loc8_.flipped); + if(isTheme(_loc8_.sortCatId)) + { + _loc10_ = 100; + _loc3_.x = 0; + _loc3_.y = 0; + setItemMatrix(_loc8_,0,0,0); + } + if(!_loc4_) + { + for each(var _loc6_:DenStateItem in _itemsInit.getCoreArray()) + { + if(_loc8_.refId == _loc6_.refId && _loc8_.invIdx == _loc6_.invIdx) + { + if(_loc8_.x != _loc6_.x || _loc8_.y != _loc6_.y) + { + _loc6_.x = _loc8_.x; + _loc6_.y = _loc8_.y; + _loc6_.offsetX = _loc8_.offsetX; + _loc6_.offsetY = _loc8_.offsetY; + break; + } + } + } + } + switch(_loc10_) + { + case 1: + _layerManager.room_bkg_main.addChild(_loc3_); + break; + case 100: + _layerManager.room_bkg_main.addChildAt(_loc3_,0); + break; + default: + _loc11_ = param1.sortOffset; + _loc12_ = RoomManagerWorld.instance.inPreviewMode ? _layerManager.preview_room_avatar : _layerManager.room_avatars; + if(_loc11_) + { + _loc3_.name = String(_loc11_); + } + _loc12_.addChild(_loc3_); + } + } + } + + private function addListenersToItem(param1:DenItemHelper, param2:DenStateItem) : void + { + param1.addMouseListeners(param2,onItemDown,onItemOver,onItemOut); + } + + private function addPortalListenersToItem(param1:DenItemHelper, param2:DenStateItem) : void + { + param1.addPortalListeners(param2,onPortalItemDown,onPortalItemOver,onPortalItemOut); + } + + private function removeListenersFromItem(param1:DenItemHelper) : void + { + param1.removeMouseListeners(); + } + + private function removePortalListenersFromItem(param1:DenItemHelper) : void + { + param1.removePortalListeners(); + } + + private function onItemDown(param1:MouseEvent, param2:DenItemHelper) : void + { + var _loc3_:Object = null; + if(_roomMode != 0) + { + return; + } + param1.stopPropagation(); + sendMouseEvent(param1); + _lastSelectedItem = param2.denStateItem as DenStateItem; + if(param2.minigameDefId > 0) + { + _loc3_ = { + "typeDefId":param2.minigameDefId, + "fromMyDenItem":RoomManagerWorld.instance.isMyDen + }; + MinigameManager.handleGameClick(_loc3_,null); + } + else if(param2.listLauncherId > 0) + { + GuiManager.openPageFlipBook(param2.listLauncherId,true,1); + } + else if(param2.isUniqueImageItem) + { + GuiManager.openMasterpiecePreview(param2.uniqueImageId,param2.uniqueImageCreator,param2.uniqueImageCreatorDbId,param2.uniqueImageCreatorUUID,param2.version,RoomManagerWorld.instance.denOwnerName,param2.currDenItem); + } + else if(param2.defId == 3192 || param2.defId == 3193 || param2.defId == 3250 || param2.defId == 3585) + { + QuestManager.showTalkingDialog(GuiManager.guiLayer,LocalizationManager.translateIdOnly(30423).split("|"),0,-1,true,PartyXtCommManager.sendJoinPartyRequest,48); + } + else if(param2.defId >= 3312 && param2.defId <= 3319) + { + switch(param2.defId - 3312) + { + case 0: + RoomXtCommManager.sendRoomJoinRequest("jamaa_township.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 1: + RoomXtCommManager.sendRoomJoinRequest("crystal_sands.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 2: + RoomXtCommManager.sendRoomJoinRequest("appondale.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 3: + RoomXtCommManager.sendRoomJoinRequest("sarepia.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 4: + RoomXtCommManager.sendRoomJoinRequest("mountains_of_shivveer.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 5: + RoomXtCommManager.sendRoomJoinRequest("lost_temple_of_zios.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 6: + RoomXtCommManager.sendRoomJoinRequest("aussie.room_main#" + RoomManagerWorld.instance.shardId); + break; + case 7: + RoomXtCommManager.sendRoomJoinRequest("coral_canyons.room_main#" + RoomManagerWorld.instance.shardId); + } + } + else if(param2.defId == 3216) + { + GenericListGuiManager.genericListVolumeClicked(669); + } + else if(param2.isMannequin) + { + _mannaquinDenItemHelper = param2; + _mannaquinAvEditor = new AvatarEditor(); + _mannaquinAvEditor.init(_mannaquinDenItemHelper.mannequin.mannequinAvatarView.avatarData,GuiManager.guiLayer,onMannequinAvEditorClose,false,false,_mannaquinDenItemHelper); + } + else if(param2.isDenStore) + { + ShopManager.launchDenShopStore(_lastSelectedItem.invIdx); + } + else if(param2.denStateItem.specialType == 6) + { + _ecoScorePopup = new EcoScorePopup(onEcoPopupClose); + } + else if(param2.denStateItem.specialType == 7 && (param2.content as MovieClip).clickFromCode == null || (param2.content as MovieClip).clickFromCode == false) + { + _ecoPointsPopup = new EcoPointsPopup(param2.denStateItem,onEcoPointsPopupClose); + } + } + + private function onPortalItemDown(param1:MouseEvent, param2:DenItemHelper) : void + { + } + + private function onItemOver(param1:MouseEvent, param2:DenItemHelper) : void + { + if(_roomMode != 0) + { + return; + } + if(param2.isMannequin) + { + return; + } + param1.stopPropagation(); + sendMouseEvent(param1); + var _loc3_:Sprite = Sprite(param1.currentTarget); + GuiManager.toolTip.init(_layerManager.room_orbs,param2.minigameDefId > 0 ? MinigameManager.getGameName(param2.minigameDefId) : LocalizationManager.translateIdOnly(param2.denStateItem.denItemHelper.nameStrId),param2.denStateItem.x + _loc3_.width * 0.5,param2.denStateItem.y + _loc3_.height - 75); + GuiManager.toolTip.startTimer(param1); + } + + private function onPortalItemOver(param1:MouseEvent, param2:DenItemHelper) : void + { + if(_roomMode != 0) + { + return; + } + param1.stopPropagation(); + if(param2.denStateItem.userNameLink != "") + { + sendMouseEvent(param1,true); + } + } + + private function onItemOut(param1:MouseEvent) : void + { + if(_roomMode != 0) + { + return; + } + param1.stopPropagation(); + sendMouseEvent(param1); + GuiManager.toolTip.resetTimerAndSetVisibility(); + } + + private function onPortalItemOut(param1:MouseEvent) : void + { + if(_roomMode != 0) + { + return; + } + param1.stopPropagation(); + sendMouseEvent(param1,true); + } + + private function sendMouseEvent(param1:MouseEvent, param2:Boolean = false) : void + { + var _loc6_:Sprite = null; + var _loc5_:Loader = null; + var _loc3_:MovieClip = null; + var _loc4_:int = -1; + switch(param1.type) + { + case "mouseDown": + _loc4_ = 0; + break; + case "mouseOver": + _loc4_ = 1; + break; + case "mouseOut": + _loc4_ = 2; + } + if(_loc4_ >= 0) + { + if(param2) + { + _loc6_ = Sprite(param1.currentTarget.parent); + } + else + { + _loc6_ = Sprite(param1.currentTarget); + } + if(_loc6_.parent) + { + _loc5_ = _loc6_.numChildren > 0 ? _loc6_.getChildAt(0) as Loader : null; + if(_loc5_) + { + _loc3_ = MovieClip(_loc5_.content); + if(_loc3_) + { + if(_loc3_.hasOwnProperty("handleMouse")) + { + _loc3_.handleMouse(_loc4_); + } + } + } + } + } + } + + private function sendMouseEventToItem(param1:MovieClip) : void + { + var _loc2_:Boolean = false; + if(param1) + { + if(param1.hasOwnProperty("handleMouse")) + { + param1.handleMouse("mouseDown"); + } + else + { + _loc2_ = Boolean(param1.listenToMouse); + param1.listenToMouse = true; + param1.clickFromCode = true; + MovieClip(param1.item1).dispatchEvent(new MouseEvent("mouseDown")); + param1.listenToMouse = _loc2_; + param1.clickFromCode = false; + } + } + } + + private function onMannequinAvEditorClose(param1:Boolean) : void + { + var _loc2_:int = 0; + var _loc3_:DenItemCollection = null; + var _loc4_:int = 0; + _mannaquinAvEditor.destroy(); + _mannaquinAvEditor = null; + if(param1) + { + _loc3_ = gMainFrame.userInfo.playerUserInfo.denItemsPartial; + _loc4_ = _mannaquinDenItemHelper.denStateItem.invIdx; + _loc2_ = 0; + while(_loc2_ < _loc3_.length) + { + if(_loc3_.getDenItem(_loc2_).invIdx == _loc4_) + { + _loc3_.getDenItem(_loc2_).mannequinData = _mannaquinDenItemHelper.mannequin.clone(); + break; + } + _loc2_++; + } + AvatarManager.playerAvatar.inventoryDenPartial.denItemCollection = _loc3_; + _loc3_ = AvatarManager.playerAvatar.inventoryDenFull.denItemCollection; + _loc2_ = 0; + while(_loc2_ < _loc3_.length) + { + if(_loc3_.getDenItem(_loc2_).invIdx == _loc4_) + { + _loc3_.getDenItem(_loc2_).mannequinData = _mannaquinDenItemHelper.mannequin.clone(); + break; + } + _loc2_++; + } + gMainFrame.userInfo.playerUserInfo.denItemsFull = _loc3_; + saveState(_loc4_); + } + _mannaquinDenItemHelper = null; + } + + private function onEcoPopupClose() : void + { + _ecoScorePopup.destroy(); + _ecoScorePopup = null; + if(GuiManager.denEditor) + { + GuiManager.denEditor.reloadDenItems(); + } + } + + private function onEcoPointsPopupClose() : void + { + _ecoPointsPopup.destroy(); + _ecoPointsPopup = null; + if(GuiManager.denEditor) + { + GuiManager.denEditor.reloadDenItems(); + } + } + } +} +