Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This file has been truncated, but you can view the full file.
'use strict';
var COMPILED = !0, goog = goog || {};
goog.global = this;
goog.DEBUG = !1;
goog.LOCALE = "en";
goog.provide = function (a) {
if (!COMPILED) {
if (goog.isProvided_(a))
throw Error('Namespace "' + a + '" already declared.');
delete goog.implicitNamespaces_[a];
for (var b = a; (b = b.substring(0, b.lastIndexOf("."))) && !goog.getObjectByName(b); )
goog.implicitNamespaces_[b] = !0
}
goog.exportPath_(a)
};
goog.setTestOnly = function (a) {
if (COMPILED && !goog.DEBUG)
throw a = a || "", Error("Importing test-only code into non-debug environment" + a ? ": " + a : ".");
};
COMPILED || (goog.isProvided_ = function (a) {
return !goog.implicitNamespaces_[a] && !!goog.getObjectByName(a)
}, goog.implicitNamespaces_ = {});
goog.exportPath_ = function (a, b, c) {
a = a.split(".");
c = c || goog.global;
!(a[0]in c) && c.execScript && c.execScript("var " + a[0]);
for (var d; a.length && (d = a.shift()); )
!a.length && goog.isDef(b) ? c[d] = b : c = c[d] ? c[d] : c[d] = {}
};
goog.getObjectByName = function (a, b) {
for (var c = a.split("."), d = b || goog.global, e; e = c.shift(); )
if (goog.isDefAndNotNull(d[e]))
d = d[e];
else
return null;
return d
};
goog.globalize = function (a, b) {
var c = b || goog.global,
d;
for (d in a)
c[d] = a[d]
};
goog.addDependency = function (a, b, c) {
if (!COMPILED) {
for (var d, a = a.replace(/\\/g, "/"), e = goog.dependencies_, f = 0; d = b[f]; f++) {
e.nameToPath[d] = a;
a in e.pathToNames || (e.pathToNames[a] = {});
e.pathToNames[a][d] = true
}
for (d = 0; b = c[d]; d++) {
a in e.requires || (e.requires[a] = {});
e.requires[a][b] = true
}
}
};
goog.ENABLE_DEBUG_LOADER = !0;
goog.require = function (a) {
if (!COMPILED && !goog.isProvided_(a)) {
if (goog.ENABLE_DEBUG_LOADER) {
var b = goog.getPathFromDeps_(a);
if (b) {
goog.included_[b] = true;
goog.writeScripts_();
return
}
}
a = "goog.require could not find: " + a;
goog.global.console && goog.global.console.error(a);
throw Error(a);
}
};
goog.basePath = "";
goog.nullFunction = function () {};
goog.identityFunction = function (a) {
return a
};
goog.abstractMethod = function () {
throw Error("unimplemented abstract method");
};
goog.addSingletonGetter = function (a) {
a.getInstance = function () {
if (a.instance_)
return a.instance_;
goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = a);
return a.instance_ = new a
}
};
goog.instantiatedSingletons_ = [];
!COMPILED && goog.ENABLE_DEBUG_LOADER && (goog.included_ = {}, goog.dependencies_ = {
pathToNames : {},
nameToPath : {},
requires : {},
visited : {},
written : {}
}, goog.inHtmlDocument_ = function () {
var a = goog.global.document;
return typeof a != "undefined" && "write" in a
}, goog.findBasePath_ = function () {
if (goog.global.CLOSURE_BASE_PATH)
goog.basePath = goog.global.CLOSURE_BASE_PATH;
else if (goog.inHtmlDocument_())
for (var a = goog.global.document.getElementsByTagName("script"), b = a.length - 1; b >= 0; --b) {
var c = a[b].src,
d = c.lastIndexOf("?"),
d = d == -1 ? c.length : d;
if (c.substr(d - 7, 7) == "base.js") {
goog.basePath = c.substr(0, d - 7);
break
}
}
}, goog.importScript_ = function (a) {
var b = goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_;
!goog.dependencies_.written[a] && b(a) && (goog.dependencies_.written[a] = true)
}, goog.writeScriptTag_ = function (a) {
if (goog.inHtmlDocument_()) {
goog.global.document.write('<script type="text/javascript" src="' + a + '"><\/script>');
return true
}
return false
}, goog.writeScripts_ = function () {
function a(e) {
if (!(e in d.written)) {
if (!(e in
d.visited)) {
d.visited[e] = true;
if (e in d.requires)
for (var g in d.requires[e])
if (!goog.isProvided_(g))
if (g in d.nameToPath)
a(d.nameToPath[g]);
else
throw Error("Undefined nameToPath for " + g);
}
if (!(e in c)) {
c[e] = true;
b.push(e)
}
}
}
var b = [],
c = {},
d = goog.dependencies_,
e;
for (e in goog.included_)
d.written[e] || a(e);
for (e = 0; e < b.length; e++)
if (b[e])
goog.importScript_(goog.basePath + b[e]);
else
throw Error("Undefined script input");
}, goog.getPathFromDeps_ = function (a) {
return a in goog.dependencies_.nameToPath ? goog.dependencies_.nameToPath[a] :
null
}, goog.findBasePath_(), goog.global.CLOSURE_NO_DEPS || goog.importScript_(goog.basePath + "deps.js"));
goog.typeOf = function (a) {
var b = typeof a;
if (b == "object")
if (a) {
if (a instanceof Array)
return "array";
if (a instanceof Object)
return b;
var c = Object.prototype.toString.call(a);
if (c == "[object Window]")
return "object";
if (c == "[object Array]" || typeof a.length == "number" && typeof a.splice != "undefined" && typeof a.propertyIsEnumerable != "undefined" && !a.propertyIsEnumerable("splice"))
return "array";
if (c == "[object Function]" || typeof a.call != "undefined" && typeof a.propertyIsEnumerable != "undefined" && !a.propertyIsEnumerable("call"))
return "function"
} else
return "null";
else if (b == "function" && typeof a.call == "undefined")
return "object";
return b
};
goog.isDef = function (a) {
return a !== void 0
};
goog.isNull = function (a) {
return a === null
};
goog.isDefAndNotNull = function (a) {
return a != null
};
goog.isArray = function (a) {
return goog.typeOf(a) == "array"
};
goog.isArrayLike = function (a) {
var b = goog.typeOf(a);
return b == "array" || b == "object" && typeof a.length == "number"
};
goog.isDateLike = function (a) {
return goog.isObject(a) && typeof a.getFullYear == "function"
};
goog.isString = function (a) {
return typeof a == "string"
};
goog.isBoolean = function (a) {
return typeof a == "boolean"
};
goog.isNumber = function (a) {
return typeof a == "number"
};
goog.isFunction = function (a) {
return goog.typeOf(a) == "function"
};
goog.isObject = function (a) {
var b = typeof a;
return b == "object" && a != null || b == "function"
};
goog.getUid = function (a) {
return a[goog.UID_PROPERTY_] || (a[goog.UID_PROPERTY_] = ++goog.uidCounter_)
};
goog.removeUid = function (a) {
"removeAttribute" in a && a.removeAttribute(goog.UID_PROPERTY_);
try {
delete a[goog.UID_PROPERTY_]
} catch (b) {}
};
goog.UID_PROPERTY_ = "closure_uid_" + Math.floor(2147483648 * Math.random()).toString(36);
goog.uidCounter_ = 0;
goog.getHashCode = goog.getUid;
goog.removeHashCode = goog.removeUid;
goog.cloneObject = function (a) {
var b = goog.typeOf(a);
if (b == "object" || b == "array") {
if (a.clone)
return a.clone();
var b = b == "array" ? [] : {},
c;
for (c in a)
b[c] = goog.cloneObject(a[c]);
return b
}
return a
};
goog.bindNative_ = function (a, b, c) {
return a.call.apply(a.bind, arguments)
};
goog.bindJs_ = function (a, b, c) {
if (!a)
throw Error();
if (arguments.length > 2) {
var d = Array.prototype.slice.call(arguments, 2);
return function () {
var c = Array.prototype.slice.call(arguments);
Array.prototype.unshift.apply(c, d);
return a.apply(b, c)
}
}
return function () {
return a.apply(b, arguments)
}
};
goog.bind = function (a, b, c) {
goog.bind = Function.prototype.bind && Function.prototype.bind.toString().indexOf("native code") != -1 ? goog.bindNative_ : goog.bindJs_;
return goog.bind.apply(null, arguments)
};
goog.partial = function (a, b) {
var c = Array.prototype.slice.call(arguments, 1);
return function () {
var b = Array.prototype.slice.call(arguments);
b.unshift.apply(b, c);
return a.apply(this, b)
}
};
goog.mixin = function (a, b) {
for (var c in b)
a[c] = b[c]
};
goog.now = Date.now || function () {
return +new Date
};
goog.globalEval = function (a) {
if (goog.global.execScript)
goog.global.execScript(a, "JavaScript");
else if (goog.global.eval) {
if (goog.evalWorksForGlobals_ == null) {
goog.global.eval("var _et_ = 1;");
if (typeof goog.global._et_ != "undefined") {
delete goog.global._et_;
goog.evalWorksForGlobals_ = true
} else
goog.evalWorksForGlobals_ = false
}
if (goog.evalWorksForGlobals_)
goog.global.eval(a);
else {
var b = goog.global.document,
c = b.createElement("script");
c.type = "text/javascript";
c.defer = false;
c.appendChild(b.createTextNode(a));
b.body.appendChild(c);
b.body.removeChild(c)
}
} else
throw Error("goog.globalEval not available");
};
goog.evalWorksForGlobals_ = null;
goog.getCssName = function (a, b) {
var c = function (a) {
return goog.cssNameMapping_[a] || a
},
d = function (a) {
for (var a = a.split("-"), b = [], d = 0; d < a.length; d++)
b.push(c(a[d]));
return b.join("-")
},
d = goog.cssNameMapping_ ? goog.cssNameMappingStyle_ == "BY_WHOLE" ? c : d : function (a) {
return a
};
return b ? a + "-" + d(b) : d(a)
};
goog.setCssNameMapping = function (a, b) {
goog.cssNameMapping_ = a;
goog.cssNameMappingStyle_ = b
};
!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING && (goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING);
goog.getMsg = function (a, b) {
var c = b || {},
d;
for (d in c)
var e = ("" + c[d]).replace(/\$/g, "$$$$"), a = a.replace(RegExp("\\{\\$" + d + "\\}", "gi"), e);
return a
};
goog.exportSymbol = function (a, b, c) {
goog.exportPath_(a, b, c)
};
goog.exportProperty = function (a, b, c) {
a[b] = c
};
goog.inherits = function (a, b) {
function c() {}
c.prototype = b.prototype;
a.superClass_ = b.prototype;
a.prototype = new c;
a.prototype.constructor = a
};
goog.base = function (a, b, c) {
var d = arguments.callee.caller;
if (d.superClass_)
return d.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1));
for (var e = Array.prototype.slice.call(arguments, 2), f = false, g = a.constructor; g; g = g.superClass_ && g.superClass_.constructor)
if (g.prototype[b] === d)
f = true;
else if (f)
return g.prototype[b].apply(a, e);
if (a[b] === d)
return a.constructor.prototype[b].apply(a, e);
throw Error("goog.base called from a method of one name to a method of a different name");
};
goog.scope = function (a) {
a.call(goog.global)
};
var simcity = {
AgentQueryUI : {},
cAgentQueryUIHandler : function () {
this.UIHandler = scrui.cUIHandler;
this.UIHandler();
this.mAgentQueryUILayout = this.mParentControl = null;
this.mOriginalLayoutWidth = 0;
this.mNameTextControl = null;
this.mDefaultNamePositionLeft = 0;
this.mDataBindings = this.mZoomToSourceButtonControl = this.mFollowButtonControl = this.mResourceBarAmountControl = this.mResourceBarFillControl = this.mResourceBarContainerControl = this.mResourceTextControl = this.mResourceWindowControl = this.mSimStatusIconWindowControl =
this.mSourceTextControl = this.mDestinationTextControl = null;
this.mCurrentSharedBindings = [];
this.mCurrentSharedTimedRefreshBindings = [];
this.mCurrentDataBindings = [];
this.mRefreshTimer = 0;
this.mDefaultDestinationTextColor = this.mDestinationPrependText = this.mDestinationText = "";
this.mAvatarTemplateContainer = null;
this.mAgentGender = 1
}
};
goog.inherits(simcity.cAgentQueryUIHandler, scrui.cUIHandler);
simcity.cAgentQueryUIHandler.kLayoutNameTextID = 164191353;
simcity.cAgentQueryUIHandler.kLayoutIconWindowID = 237484883;
simcity.cAgentQueryUIHandler.kLayoutDestinationTextID = 236702504;
simcity.cAgentQueryUIHandler.kLayoutSourceTextID = 237570896;
simcity.cAgentQueryUIHandler.kLayoutSimStatusIconWindowID = 237916421;
simcity.cAgentQueryUIHandler.kLayoutResourceWindowID = 238178069;
simcity.cAgentQueryUIHandler.kLayoutResourceTextID = 237979994;
simcity.cAgentQueryUIHandler.kLayoutResourceBarContainerID = 238178071;
simcity.cAgentQueryUIHandler.klayoutResourceBarFillID = 238178073;
simcity.cAgentQueryUIHandler.kLayoutResourceBarAmountID = 252673365;
simcity.cAgentQueryUIHandler.kLayoutFollowAgentCamButtonID = 238781781;
simcity.cAgentQueryUIHandler.kLayoutZoomToSourceButtonID = 238783027;
simcity.cAgentQueryUIHandler.kLayoutAvatarTemplateContainer = 253206823;
simcity.cAgentQueryUIHandler.kBindingTypePosition = 238092092;
simcity.cAgentQueryUIHandler.kBindingTypeName = 238084822;
simcity.cAgentQueryUIHandler.kBindingTypeGender = 244221262;
simcity.cAgentQueryUIHandler.kBindingTypeDestination = 238086977;
simcity.cAgentQueryUIHandler.kBindingTypeSource = 238090037;
simcity.cAgentQueryUIHandler.kBindingTypeSimStatus = 238092041;
simcity.cAgentQueryUIHandler.kBindingTypePrependDestination = 238853567;
simcity.cAgentQueryUIHandler.kBindingTypeResourceBin = 238091235;
simcity.cAgentQueryUIHandler.kBindingTypeShowGoToSource = 251821342;
simcity.cAgentQueryUIHandler.kBindingTypeRegionalBoxUID = 253205894;
simcity.cAgentQueryUIHandler.kRefreshTime = 1E3;
simcity.cAgentQueryUIHandler.prototype.Init = function (a) {
scrui.Assert(null !== a);
this.mParentControl = a;
this.mAgentQueryUILayout = gUIManager.LoadLayout("Layouts/AgentQueryLayout.js", this.mParentControl);
this.mOriginalLayoutWidth = this.mAgentQueryUILayout.mWidth;
this.mNameTextControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutNameTextID);
this.mDefaultNamePositionLeft = this.mNameTextControl.mLeft;
this.mDestinationTextControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutDestinationTextID);
this.mSourceTextControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutSourceTextID);
this.mSimStatusIconWindowControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutSimStatusIconWindowID);
this.mResourceWindowControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutResourceWindowID);
this.mResourceTextControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutResourceTextID);
this.mResourceBarContainerControl =
this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutResourceBarContainerID);
this.mResourceBarFillControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.klayoutResourceBarFillID);
this.mResourceBarAmountControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutResourceBarAmountID);
this.mFollowButtonControl = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutFollowAgentCamButtonID);
this.mZoomToSourceButtonControl =
this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutZoomToSourceButtonID);
this.mDefaultDestinationTextColor = this.mDestinationTextControl.mTextElement.style.color;
this.mAvatarTemplateContainer = this.mAgentQueryUILayout.FindControlByID(simcity.cAgentQueryUIHandler.kLayoutAvatarTemplateContainer);
this.Hide();
this.mDataBindings = simcity.AgentQueryDataBindings
};
simcity.cAgentQueryUIHandler.prototype.AddDataBinding = function (a) {
a && this.mCurrentDataBindings.push(a)
};
simcity.cAgentQueryUIHandler.prototype.AddDataBindings = function (a) {
if (a)
for (var b = a.length, c = 0; c < b; ++c)
this.AddDataBinding(a[c])
};
simcity.cAgentQueryUIHandler.prototype.HandleGameEvent = function (a, b) {
switch (a) {
case simcity.kGameMessageAgentSelected:
this.mRefreshTimer = 0;
this.mCurrentDataBindings = [];
this.Hide();
this.mAgentQueryUILayout.SetWidth(this.mOriginalLayoutWidth);
this.mCurrentSharedBindings = simcity.kSharedAgentQueryDataBindings;
this.mCurrentSharedTimedRefreshBindings = simcity.kSharedAgentQueryTimedRefreshDataBindings;
scrui.Assert(simcity.AgentQueryDataBindings[b.transportType], "Agent has invalid scTransportUIType. Please check the prop file for this agent.");
this.AddDataBindings(simcity.AgentQueryDataBindings[b.transportType]);
this.Show(!0);
this.SendDataBindingRequest(this.mCurrentSharedTimedRefreshBindings, !1);
this.SendDataBindingRequest(this.mCurrentDataBindings, !1);
simcity.gEventManager.TriggerEvent(simcity.gEventTypes.GENERICEVENT, b.transportType, this.mAgentQueryUILayout);
break;
case simcity.kGameMessageActorSelected:
this.mRefreshTimer = 0;
this.Hide();
this.mAgentQueryUILayout.SetWidth(this.mOriginalLayoutWidth);
this.mCurrentSharedBindings = simcity.kSharedActorQueryDataBindings;
this.mCurrentSharedTimedRefreshBindings = simcity.kSharedActorQueryTimedRefreshDataBindings;
this.mCurrentDataBindings = [];
this.Show(!1);
this.SendDataBindingRequest(this.mCurrentSharedTimedRefreshBindings, !1);
this.SendDataBindingRequest(this.mCurrentDataBindings, !1);
break;
case simcity.kGameMessageAgentDeselected:
this.mCurrentSharedBindings = [],
this.mCurrentSharedTimedRefreshBindings = [],
this.mCurrentDataBindings = [],
this.Hide()
}
};
simcity.cAgentQueryUIHandler.prototype.HandleUIMessage = function (a, b) {
switch (a) {
case scrui.kMsgTypeButtonClicked:
switch (b) {
case simcity.cAgentQueryUIHandler.kLayoutFollowAgentCamButtonID:
scrui.PostGameCommand(scrui.BuildCommand([simcity.kCommandActivateFollowAgentCam]));
break;
case simcity.cAgentQueryUIHandler.kLayoutZoomToSourceButtonID:
simcity.IsTutorialInProgress() || scrui.PostGameCommand(scrui.BuildCommand([simcity.kCommandZoomToAgentSource]))
}
}
};
simcity.cAgentQueryUIHandler.prototype.Update = scrui.Client_ProfZone("AgentQueryUIUpdate", function (a) {
this.mAgentQueryUILayout && (this.mAgentQueryUILayout.mIsVisible && this.mCurrentDataBindings) && (this.SendDataBindingRequest(this.mCurrentSharedBindings, !0), this.mRefreshTimer -= a, 0 >= this.mRefreshTimer && (this.mRefreshTimer = simcity.cAgentQueryUIHandler.kRefreshTime, this.mAgentQueryUILayout.SetWidth(this.mOriginalLayoutWidth), this.AutoResizeLayout(this.mNameTextControl), this.SendDataBindingRequest(this.mCurrentSharedTimedRefreshBindings,
!0), this.SendDataBindingRequest(this.mCurrentDataBindings, !0)))
});
simcity.cAgentQueryUIHandler.prototype.SendDataBindingRequest = function (a, b) {
var c = this,
d = a.length,
e = [],
f = [];
simcity.GenerateDataBindingQueries(a, e, {}, f, b);
simcity.RequestDataBindingData(e, a, f, b, function (e) {
for (var f = 0; f < d; ++f) {
var i = a[f];
if (i.dynamic || !1 === b)
switch (i.bindingType) {
case simcity.cAgentQueryUIHandler.kBindingTypePosition:
c.SetPosition(e[f].screenPosition);
break;
case simcity.cAgentQueryUIHandler.kBindingTypeShowGoToSource:
c.SetGoToSourceVisible(i.update(e[f]));
break;
case simcity.cAgentQueryUIHandler.kBindingTypeName:
c.SetName(i.update(e[f]));
break;
case simcity.cAgentQueryUIHandler.kBindingTypeGender:
c.SetGender(i.update(e[f]));
break;
case simcity.cAgentQueryUIHandler.kBindingTypeRegionalBoxUID:
c.SetPlayerDisplay(i.update(e[f]));
break;
case simcity.cAgentQueryUIHandler.kBindingTypeDestination:
c.SetDestination(i.update(e[f]), i.color);
break;
case simcity.cAgentQueryUIHandler.kBindingTypeSource:
c.SetSource(i.update(e[f]));
break;
case simcity.cAgentQueryUIHandler.kBindingTypeSimStatus:
c.SetSimStatus(i.update(e[f]), i.iconPath);
break;
case simcity.cAgentQueryUIHandler.kBindingTypePrependDestination:
c.SetDestinationPrependText(i.update(e[f]),
i.color);
break;
case simcity.cAgentQueryUIHandler.kBindingTypeResourceBin:
c.SetResourceBinInfo(e[f].resource, i.localeString, i.formatType);
break;
default:
i.hasOwnProperty("update") && i.update(e[f])
}
}
})
};
simcity.cAgentQueryUIHandler.prototype.SetPosition = function (a) {
a && this.mAgentQueryUILayout.SetPosition(a[0] - this.mAgentQueryUILayout.mWidth / 2, a[1] - this.mAgentQueryUILayout.mHeight)
};
simcity.cAgentQueryUIHandler.prototype.SetGoToSourceVisible = function (a) {
a ? this.mZoomToSourceButtonControl.SetVisibility(a) : this.mZoomToSourceButtonControl.SetVisibility(!1)
};
simcity.cAgentQueryUIHandler.prototype.SetName = function (a) {
var b = "";
a.vehicleName ? this.mNameTextControl.SetLocaleText(scrui.LocaleStringFromLocaleProperty(a.vehicleName), {
cityName : a.cityName
}) : (a.firstName && (b = scrui.TextFromLocaleProperty(a.firstName)), a.lastName && (b += " " + this.GetGenderedTextFromLocaleString(scrui.LocaleStringFromLocaleProperty(a.lastName), this.mAgentGender)), this.mNameTextControl.SetRawText(b));
this.mDestinationTextControl.SetTextColor(this.mDefaultDestinationTextColor);
this.AutoResizeLayout(this.mNameTextControl)
};
simcity.cAgentQueryUIHandler.prototype.SetGender = function (a) {
this.mAgentGender = a
};
simcity.cAgentQueryUIHandler.prototype.SetPlayerDisplay = function (a) {
0 < a ? (a = simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData.mBoxes[a], simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription({
playerID : a.creatorId,
layoutInfo : this.mAvatarTemplateContainer,
isBoxClaimed : !0,
isMyBox : a.creatorId == simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData.mPlayingBox.creatorId,
isCurrentBox : !1,
showAlerts : !1,
group : "agentQuery" + a.uid,
boxID : a.uid
}), this.mAvatarTemplateContainer.SetVisibility(!0)) :
this.mAvatarTemplateContainer.SetVisibility(!1)
};
simcity.cAgentQueryUIHandler.prototype.SetDestination = function (a, b) {
a && (this.mDestinationText = this.GetGenderedTextFromLocaleString(scrui.LocaleStringFromLocaleProperty(a), this.mAgentGender), this.UpdateDestination(b))
};
simcity.cAgentQueryUIHandler.prototype.SetSource = function (a) {
a ? (this.mSourceTextControl.SetVisibility(!0), this.mSourceTextControl.UpdateLocaleText({
sourceName : a,
gender : this.mAgentGender
}), this.AutoResizeLayout(this.mSourceTextControl)) : this.mSourceTextControl.SetVisibility(!1)
};
simcity.cAgentQueryUIHandler.prototype.SetSimStatus = function (a, b) {
a && (this.mSimStatusIconWindowControl.SetVisibility(!0), this.mSimStatusIconWindowControl.SetWindowImage(b), this.SetDestinationPrependText(a, null))
};
simcity.cAgentQueryUIHandler.prototype.SetDestinationPrependText = function (a, b) {
a && (this.mDestinationPrependText = this.GetGenderedTextFromLocaleString(a, this.mAgentGender), this.UpdateDestination(b))
};
simcity.cAgentQueryUIHandler.prototype.SetResourceBinInfo = function (a, b, c) {
this.mResourceWindowControl.SetVisibility(!0);
var d;
b.LoadString(function () {
d = b.GetText()
});
this.mResourceTextControl.SetRawText(d);
this.AutoResizeLayout(this.mResourceTextControl);
var e = a.amount / a.capacity;
this.mResourceBarFillControl.SetWidth(e * this.mResourceBarContainerControl.mWidth);
var f = this.GetResourceTextString(c);
if ("undefined" != c && c != simcity.NumberFormat.Standard) {
var g = c ? simcity.FormatLargeNumberByType(a.amount,
c).number : a.amount,
a = c ? simcity.FormatLargeNumberByType(a.capacity, c).number : a.capacity,
h;
f.LoadString(function () {
h = f.GetText()
});
this.mResourceBarAmountControl.SetRawText(g + "/" + a + " " + h);
this.AutoResizeProgressBar(this.mResourceBarAmountControl, e)
} else
this.mResourceBarAmountControl.SetRawText(a.amount + "/" + a.capacity)
};
simcity.cAgentQueryUIHandler.prototype.GetResourceTextString = function (a) {
var b = 0;
switch (a) {
case simcity.NumberFormat.Tons:
b = "0x0e8d4573";
break;
case simcity.NumberFormat.Barrels:
b = "0x0e8d4575";
break;
case simcity.NumberFormat.Crates:
case simcity.NumberFormat.Units:
b = "0x0e8d4574"
}
return new scrui.cLocaleString("BuildingRollover.json", b, "AgentQueryUI")
};
simcity.cAgentQueryUIHandler.prototype.AutoResizeLayout = function (a) {
var b = a.GetTextWidth(),
a = a.mWidth - b;
0 > a && this.mAgentQueryUILayout.SetWidth(this.mAgentQueryUILayout.mWidth - a + 1)
};
simcity.cAgentQueryUIHandler.prototype.AutoResizeProgressBar = function (a) {
var b = a.GetTextWidth(),
c = a.mWidth - b;
0 > c ? (a.SetPosition(a.mLeft + c, a.mTop, b, a.mHeight), this.mAgentQueryUILayout.SetWidth(this.mAgentQueryUILayout.mWidth - a.mLeft + this.mResourceTextControl.mWidth), this.mResourceBarContainerControl.SetPosition(this.mResourceBarContainerControl.mLeft + c, this.mResourceBarContainerControl.mTop, b + 1, this.mResourceBarContainerControl.mHeight)) : this.mAgentQueryUILayout.SetWidth(this.mAgentQueryUILayout.mWidth -
a.mLeft + this.mResourceTextControl.mWidth + 10)
};
simcity.cAgentQueryUIHandler.prototype.GetGenderedTextFromLocaleString = function (a, b) {
var c = "";
a.LoadString(function () {
c = a.GetText({
gender : b
})
});
return c
};
simcity.cAgentQueryUIHandler.prototype.UpdateDestination = function (a) {
a ? this.mDestinationTextControl.SetTextColor(a) : this.mDestinationTextControl.SetTextColor(this.mDefaultDestinationTextColor);
this.mDestinationTextControl.SetRawText(this.mDestinationPrependText + " " + this.mDestinationText);
this.AutoResizeLayout(this.mDestinationTextControl)
};
simcity.cAgentQueryUIHandler.prototype.Show = function (a) {
this.mAgentQueryUILayout.SetVisibility(!0);
this.mFollowButtonControl.SetSelected(!1);
this.mZoomToSourceButtonControl.SetEnabled(a);
this.mZoomToSourceButtonControl.SetVisibility(!1);
this.mAvatarTemplateContainer.SetVisibility(!1);
this.mDestinationTextControl.SetRawText("");
this.mNameTextControl.SetPosition(this.mDefaultNamePositionLeft, this.mNameTextControl.mTop);
a ? this.mFollowButtonControl.SetVisibility(!0) : this.mFollowButtonControl.SetVisibility(!1)
};
simcity.cAgentQueryUIHandler.prototype.Hide = function () {
this.mAgentQueryUILayout.SetVisibility(!1);
this.mSimStatusIconWindowControl.SetVisibility(!1);
this.mResourceWindowControl.SetVisibility(!1);
this.mDestinationPrependText = this.mDestinationText = "";
this.mAgentGender = 1;
this.mDestinationTextControl.SetTextColor(this.mDefaultDestinationTextColor)
};
simcity.RegionTradeUI = {};
simcity.kRegionTradeOutgoingTokenPanelID = 239646136;
simcity.kRegionTradeIncomingTokenPanelID = 239644807;
simcity.kRegionTradeRefreshTime = 1E3;
simcity.kRegionTradeTokenType_Fire = "fire";
simcity.kRegionTradeTokenType_Police = "police";
simcity.kRegionTradeTokenType_Garbage = "garbage";
simcity.kRegionTradeTokenType_Health = "health";
simcity.kRegionTradeTokenTypes = [simcity.kRegionTradeTokenType_Fire, simcity.kRegionTradeTokenType_Police, simcity.kRegionTradeTokenType_Garbage, simcity.kRegionTradeTokenType_Health];
simcity.kRegionTradeResourceGiftAmount = 1E4;
simcity.kRegionTradeResourceGiftMaxAmount = 1E7;
simcity.kUtilityPanelIDs = {
myCity : {
rootPanel : 239654550,
tradePanel : 239644807,
noTradeText : 239811505,
titleText : 239812302
},
item : {
cityOwnerIcon : 240577914,
cityNameText : 242413919,
cityOwnerText : 242413908,
statusText : 242397569,
receivingFromCityText : 253390028,
button : 242397758
}
};
simcity.kTokenPanelIDs = {
outgoing : {
rootPanel : 239654560,
tokensPanel : 239646136,
noTokensText : 239811492,
titleText : 239812235,
removeTokenPanel : 239901846,
removeTokenButton : 239901837,
removeTokenText : 239901832
},
incoming : {
rootPanel : 239654550,
tokensPanel : 239644807,
noTokensText : 239811505,
titleText : 239812302,
shareTokenPanel : 239811577,
shareTokenButton : 239811671,
shareTokenText : 239811734
},
avatar : {
avatarImage : 237907905,
btnAvatar : 242832115,
avatarOnlineHighlight : 239800634,
avatarAlert : 239807635,
textWindow : 242832079,
playerName : 242832082
},
vehicle : {
iconAndButtonWindow : 247687083,
amountText : 244665831,
tooltipText : 239656078,
buttonsWindow : 246016822,
buttonAdd : 246016823,
buttonSubtract : 246016824,
icon : 239656036
}
};
simcity.kGiftingPanelIDs = {
resources : {
startingTabID : 249422240,
lastTabID : 249422250,
titleBarText : 241808376,
selectedCityTitleBarText : 241808377,
playingCity : {
amountText : 249485363,
nameText : 249485369,
truckIcon : 249761536,
railIcon : 249761537,
boatIcon : 249761538
},
viewingCity : {
avatarWindow : 243530044,
amountText : 249485356,
nameText : 249485359,
displayInfoAnimation : 249648679,
truckIcon : 249761539,
railIcon : 249761540,
boatIcon : 249761541
},
unconnectedCity : {
window : 249764729,
nameText : 249918847,
displayInfoAnimation : 249918411
},
sendButton : 236790941,
sendAmountText : 241707655,
incrementButton : 236790942,
decrementButton : 236790943,
maxAmountButton : 249916003,
pendingText : 249574691,
tab : {
button : 249484086,
lightIcon : 249484087,
darkIcon : 249484088,
tooltipResourceText : 249914354,
tooltipAmountText : 249914355
}
}
};
simcity.kGiftingTooltips = {
SendingEnabled : "",
UnclaimedOrUnconnectedCity : new scrui.cLocaleString("Gifting.json", "0x0ee94dee", "City not connected/claimed placeholder"),
GiftInProgress : new scrui.cLocaleString("Gifting.json", "0x0e952dc6", "Gift in progress placeholder"),
EmptyGiftAmount : new scrui.cLocaleString("Gifting.json", "0x0ee94def", "Increase gift amount placeholder")
};
simcity.cRegionTradeUIHandler = function () {
this.UIHandler = scrui.cUIHandler;
this.UIHandler();
this.mRegionViewUI = simcity.gGlobalUIHandler.mRegionViewUIHandler;
this.mStatusIconLayoutPath = "Layouts/Region/TradeTokenStatusIcon.js";
this.mTimeSinceLastUpdate = 0;
this.mResourceGiftingItemControls = [];
this.mResourceGiftingCurrentAmount = this.mResourceGiftingSelectedTab = this.mRefreshTimer = 0;
this.mResourceGiftingMaxAmount = !1;
this.mResourceGiftingCurrentClickAmount = this.mResourceGiftingLastTickPress = this.mResourceGiftingLegendControl =
0
};
goog.inherits(simcity.cRegionTradeUIHandler, scrui.cUIHandler);
simcity.cRegionTradeUIHandler.kVehicleContainers = [249129195, 249129200, 249129202, 249129206, 249129209];
simcity.cRegionTradeUIHandler.kVehicleContainerImage = 248984352;
simcity.cRegionTradeUIHandler.kVehicleContainerTextAmount = 248984355;
simcity.cRegionTradeUIHandler.kNoCitySelectedBanner = 248983030;
simcity.cRegionTradeUIHandler.kGivingToBox = 248983052;
simcity.cRegionTradeUIHandler.kCoveringBox = 248983055;
simcity.cRegionTradeUIHandler.kTxtMyCityName = 248983081;
simcity.cRegionTradeUIHandler.kTxtNeighborCityName = 248983044;
simcity.cRegionTradeUIHandler.kTxtSpinnerValue = 248979371;
simcity.cRegionTradeUIHandler.kTxtServiceHoverName = 250259057;
simcity.cRegionTradeUIHandler.kTxtServiceHoverDescription = 250258365;
simcity.cRegionTradeUIHandler.kTxtServiceHoverImage = 250259876;
simcity.cRegionTradeUIHandler.kBtnIncrementVehicle = 248979367;
simcity.cRegionTradeUIHandler.kBtnDecrementVehicle = 248979369;
simcity.cRegionTradeUIHandler.kTxtSpinnerAmount = 248979371;
simcity.cRegionTradeUIHandler.kYourAvatarContainer = 248983083;
simcity.cRegionTradeUIHandler.kTradePartnerAvatarContainer = 249493477;
simcity.cRegionTradeUIHandler.kTxtServiceTradeTitleNeighbour = 249659712;
simcity.cRegionTradeUIHandler.kTxtServiceTradeTitle = 249659715;
simcity.cRegionTradeUIHandler.kTxtSelectCityText = 248983033;
simcity.cRegionTradeUIHandler.prototype.Init = function () {};
simcity.cRegionTradeUIHandler.prototype.HandleUIMessage = function (a, b, c) {
switch (a) {
case scrui.kMsgTypeButtonClicked:
switch (b) {
case simcity.cRegionTradeUIHandler.kBtnIncrementVehicle:
c.mUserData && this.ServiceVehicleButtonPressed("increment", c.mUserData);
break;
case simcity.cRegionTradeUIHandler.kBtnDecrementVehicle:
c.mUserData && this.ServiceVehicleButtonPressed("decrement", c.mUserData);
break;
case simcity.kUtilityPanelIDs.item.button:
c.mUserData && this.ToggleUtilityTrade(c);
break;
case simcity.kGiftingPanelIDs.resources.tab.button:
0 <=
c.mUserData && this.ShowGiftingTab(c.mUserData);
break;
case simcity.kGiftingPanelIDs.resources.sendButton:
c.mUserData && this.SendResourceGift(c);
break;
case simcity.kGiftingPanelIDs.resources.maxAmountButton:
this.mResourceGiftingMaxAmount = !0;
this.UpdateGiftingTextForSelectedTab();
break;
case simcity.kGiftingPanelIDs.resources.incrementButton:
this.UpdateGiftingClickRun();
this.mResourceGiftingCurrentAmount = 19 <= this.mResourceGiftingCurrentClickAmount && 0 == this.mResourceGiftingCurrentAmount % (50 * simcity.kRegionTradeResourceGiftAmount) ?
this.mResourceGiftingCurrentAmount + 50 * simcity.kRegionTradeResourceGiftAmount : 14 <= this.mResourceGiftingCurrentClickAmount && 0 == this.mResourceGiftingCurrentAmount % (10 * simcity.kRegionTradeResourceGiftAmount) ? this.mResourceGiftingCurrentAmount + 10 * simcity.kRegionTradeResourceGiftAmount : 5 <= this.mResourceGiftingCurrentClickAmount && 0 == this.mResourceGiftingCurrentAmount % (5 * simcity.kRegionTradeResourceGiftAmount) ? this.mResourceGiftingCurrentAmount + 5 * simcity.kRegionTradeResourceGiftAmount : this.mResourceGiftingCurrentAmount +
simcity.kRegionTradeResourceGiftAmount;
this.UpdateGiftingTextForSelectedTab();
break;
case simcity.kGiftingPanelIDs.resources.decrementButton:
this.UpdateGiftingClickRun(),
this.mResourceGiftingCurrentAmount = 19 <= this.mResourceGiftingCurrentClickAmount && 0 == this.mResourceGiftingCurrentAmount % (50 * simcity.kRegionTradeResourceGiftAmount) ? this.mResourceGiftingCurrentAmount - 50 * simcity.kRegionTradeResourceGiftAmount : 14 <= this.mResourceGiftingCurrentClickAmount && 0 == this.mResourceGiftingCurrentAmount % (10 * simcity.kRegionTradeResourceGiftAmount) ?
this.mResourceGiftingCurrentAmount - 10 * simcity.kRegionTradeResourceGiftAmount : 5 <= this.mResourceGiftingCurrentClickAmount && 0 == this.mResourceGiftingCurrentAmount % (5 * simcity.kRegionTradeResourceGiftAmount) ? this.mResourceGiftingCurrentAmount - 5 * simcity.kRegionTradeResourceGiftAmount : this.mResourceGiftingCurrentAmount - simcity.kRegionTradeResourceGiftAmount,
this.UpdateGiftingTextForSelectedTab()
}
}
};
simcity.cRegionTradeUIHandler.prototype.GetViewingCity = function () {
return this.mRegionViewUI.mSelectedRegionViewItem ? this.mRegionViewUI.mSelectedRegionViewItem.mRegionalBoxID : this.mRegionViewUI.mRegionData.mPlayingBox.uid
};
simcity.cRegionTradeUIHandler.prototype.GetServiceVehicleButton = function (a, b) {
var c = simcity.gGlobalUIHandler.mRegionViewUIHandler.mContextPanelObj,
d = this.mRegionViewUI.mContextPanelDataBinding.getServiceVehicles();
if (!c || !d)
return null;
for (d = 0; d < simcity.cRegionTradeUIHandler.kVehicleContainers.length; d++) {
var e = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[d]);
if (e && (e = e.FindControlByID(a)) && e.mUserData && e.mUserData[0] == b)
return e
}
return null
};
simcity.cRegionTradeUIHandler.prototype.GetResourceButton = function (a) {
for (var b = simcity.kGiftingPanelIDs.resources.startingTabID, c = simcity.gGlobalUIHandler.mRegionViewUIHandler.mContextPanelObj, d = 0, e = simcity.kGiftableResourcesDataBindings.length; d < e; ++d) {
if (simcity.kGiftableResourcesDataBindings[d]) {
var f = c.FindControlByID(b).FindControlByID(simcity.kGiftingPanelIDs.resources.tab.button);
if (f && f.mUserData == a)
return f
}
++b
}
return null
};
simcity.cRegionTradeUIHandler.prototype.ShowTokenUI = function (a) {
for (var b = this.mRegionViewUI.mContextPanelDataBinding, c = b.getServiceVehicles(), d = this.IsViewingOwnBox(), e = this.IsConnectedToPlayingCityViaRoad(this.GetViewingCity()), f = simcity.gGlobalUIHandler.mRegionViewUIHandler, g = f.mRegionData, h = f.mContextPanelObj, i = 0; i < simcity.cRegionTradeUIHandler.kVehicleContainers.length; i++) {
var j = h.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[i]);
if (j && (j.SetVisibility(!1), i < c.length && (j.SetVisibility(!0),
d || !e ? (j.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetVisibility(!1), j.FindControlByID(simcity.cRegionTradeUIHandler.kBtnDecrementVehicle).SetVisibility(!1)) : (j.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetVisibility(!0), j.FindControlByID(simcity.cRegionTradeUIHandler.kBtnDecrementVehicle).SetVisibility(!0)), j.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerImage).SetWindowImage(c[i].icon), j.FindControlByID(simcity.cRegionTradeUIHandler.kTxtServiceHoverName).SetLocaleText(c[i].text),
j.FindControlByID(simcity.cRegionTradeUIHandler.kTxtServiceHoverImage).SetWindowImage(c[i].rolloverIcon), j.FindControlByID(simcity.cRegionTradeUIHandler.kTxtServiceHoverDescription).SetLocaleText(c[i].rolloverText), f.mSelectedRegionViewItem))) {
var k = g.mConnectedUnits[f.mSelectedRegionViewItem.mRegionalBoxID];
j.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).mUserData = [c[i].index, k];
j.FindControlByID(simcity.cRegionTradeUIHandler.kBtnDecrementVehicle).mUserData = [c[i].index, k]
}
}
simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("tradeServicesYou");
c = h.FindControlByID(simcity.cRegionTradeUIHandler.kYourAvatarContainer);
c = {
playerID : g.mPlayingBox.creatorId,
layoutInfo : c,
isBoxClaimed : "true",
isMyBox : !0,
isCurrentBox : !1,
showAlerts : !1,
group : "tradeServicesYou",
boxID : g.mPlayingBox.uid
};
simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription(c);
d ? h.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSelectCityText).SetLocaleText(new scrui.cLocaleString("RegionView.json", "0x0ed7185a", "Select a city.")) : this.IsConnectedToPlayingCityViaRoad(this.GetViewingCity()) ?
h.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSelectCityText).SetLocaleText(new scrui.cLocaleString("RegionView.json", "0x0ef7ea23", "Unclaimed city!")) : h.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSelectCityText).SetLocaleText(new scrui.cLocaleString("RegionView.json", "0x0ef7ea24", "Too far away!"));
h.FindControlByID(simcity.cRegionTradeUIHandler.kTxtServiceTradeTitle).SetLocaleText(b.getServiceString());
b = b.getServiceDestinationString();
!d && e && (d = simcity.gGlobalUIHandler.mRegionViewUIHandler.mSelectedRegionViewItem.mRegionalBoxID,
e = "", e = g.mCities[d] ? g.mCities[d].name : scrui.ParseLocaleString(g.mCityDefaultData.cities[d].cityName).LoadAndGetTextSynchronous(), h.FindControlByID(simcity.cRegionTradeUIHandler.kTxtServiceTradeTitleNeighbour).SetLocaleText(b, {
cityname : e
}), simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("tradeServicesTradePartner"), g.mBoxes[d] && (e = h.FindControlByID(simcity.cRegionTradeUIHandler.kTradePartnerAvatarContainer), c = {
playerID : g.mBoxes[d].creatorId,
layoutInfo : e,
isBoxClaimed : "true",
isMyBox : g.mPlayingBox.creatorId ==
g.mBoxes[d].creatorId,
isCurrentBox : !1,
showAlerts : !1,
group : "tradeServicesTradePartner",
boxID : d
}, simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription(c)));
(g = h.FindControlByID(253646199)) && g.UpdateLocaleText({
amount : this.GetIncomeTotalForTradedService(a)
});
this.SetupResourceTradingBaseUIState(h)
};
simcity.cRegionTradeUIHandler.prototype.GetIncomeTotalForTradedService = function (a) {
for (var b = 0, c = simcity.GetHistoryData(simcity.kTransactionsToTrack, 20), d = 0, e = c.length; d < e; d++) {
var f = c[d].label;
if ("fire" == a && f == simcity.gHistoryData[simcity.kHashServiceIncomeFire].label || "police" == a && f == simcity.gHistoryData[simcity.kHashServiceIncomePolice].label || "garbage" == a && f == simcity.gHistoryData[simcity.kHashServiceIncomeGarbage].label || "garbage" == a && f == simcity.gHistoryData[simcity.kHashServiceIncomeRecycling].label ||
"health" == a && f == simcity.gHistoryData[simcity.kHashServiceIncomeHealth].label)
b += c[d].amount
}
return b
};
simcity.cRegionTradeUIHandler.prototype.UpdateTokenUI = function () {
var a = this.mRegionViewUI.mContextPanelDataBinding,
b = simcity.gGlobalUIHandler.mRegionViewUIHandler,
c = b.mContextPanelObj,
d = a.getCurrentValueQueries();
scrui.RequestGameData(d, function (a) {
var b = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[0]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerImage).SetOpacity(a[0] ? 1 : 0.3);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerTextAmount).SetRawText(" " +
(a[0] - a[1]) + "/" + a[0]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSpinnerValue).SetRawText("0");
b.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetEnabled(0 < a[0] - a[1]);
b = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[1]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerImage).SetOpacity(a[2] ? 1 : 0.3);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerTextAmount).SetRawText(" " + (a[2] - a[3]) + "/" + a[2]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSpinnerValue).SetRawText("0");
b.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetEnabled(0 < a[2] - a[3]);
b = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[2]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerImage).SetOpacity(a[4] ? 1 : 0.3);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerTextAmount).SetRawText(" " + (a[4] - a[5]) + "/" + a[4]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSpinnerValue).SetRawText("0");
b.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetEnabled(0 <
a[4] - a[5]);
b = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[3]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerImage).SetOpacity(a[6] ? 1 : 0.3);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerTextAmount).SetRawText(" " + (a[6] - a[7]) + "/" + a[6]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSpinnerValue).SetRawText("0");
b.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetEnabled(0 < a[6] - a[7]);
b = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[4]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerImage).SetOpacity(a[8] ? 1 : 0.3);
b.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainerTextAmount).SetRawText(" " + (a[8] - a[9]) + "/" + a[8]);
b.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSpinnerValue).SetRawText("0");
b.FindControlByID(simcity.cRegionTradeUIHandler.kBtnIncrementVehicle).SetEnabled(0 < a[8] - a[9])
});
d = b.mSelectedRegionViewItem ? b.mSelectedRegionViewItem.mRegionalBoxID : null;
if (!this.IsViewingOwnBox() && this.IsConnectedToPlayingCityViaRoad(d))
for (var a =
a.getServiceVehicles(), b = b.mRegionData.mConnectedUnits[b.mSelectedRegionViewItem.mRegionalBoxID], e = 0; e < a.length; e++) {
var f = [a[e]],
d = [],
g = [];
simcity.GenerateDataBindingQueries(f, d, {
argumentList : [b]
}, g, !1, "queries");
simcity.RequestDataBindingData(d, f, g, !1, function (a) {
var a = a[0].outgoingVehicle,
b = c.FindControlByID(simcity.cRegionTradeUIHandler.kVehicleContainers[e]);
if (b) {
b.FindControlByID(simcity.cRegionTradeUIHandler.kBtnDecrementVehicle).SetEnabled(a > 0);
(b = b.FindControlByID(simcity.cRegionTradeUIHandler.kTxtSpinnerAmount)) &&
b.SetText(a)
}
})
}
};
simcity.cRegionTradeUIHandler.prototype.SetupResourceTradingBaseUIState = function (a) {
var b = this.IsViewingOwnBox(),
c = this.IsConnectedToPlayingCityViaRoad(this.GetViewingCity()),
d = simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData;
a.FindControlByID(simcity.cRegionTradeUIHandler.kNoCitySelectedBanner).SetVisibility(b || !c);
a.FindControlByID(simcity.cRegionTradeUIHandler.kGivingToBox).SetVisibility(!b && c);
a.FindControlByID(simcity.cRegionTradeUIHandler.kCoveringBox).SetVisibility(b || !c);
b ? this.SetupTradingAvatars(a) :
(b = simcity.gGlobalUIHandler.mRegionViewUIHandler.mSelectedRegionViewItem.mRegionalBoxID, c = "", c = d.mCities[b] ? d.mCities[b].name : scrui.ParseLocaleString(d.mCityDefaultData.cities[b].cityName).LoadAndGetTextSynchronous(), a.FindControlByID(simcity.cRegionTradeUIHandler.kTxtNeighborCityName).SetText(c));
a.FindControlByID(simcity.cRegionTradeUIHandler.kTxtMyCityName).SetText(d.mPlayingBox.name);
this.UpdateTokenUI()
};
simcity.cRegionTradeUIHandler.prototype.GetCoveringAndReceivingDetails = function () {
var a = this.mRegionViewUI.mContextPanelDataBinding,
b = simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData;
this.mListOfBoxesYouCover = {};
this.mListOfBoxesCoveringYou = {};
for (var c = this, d = Object.keys(b.mCityTradeData[b.mPlayingBox.uid].connections), e = a.getServiceVehicles(), f = 0; f < d.length; f++) {
var g = b.mBoxes[d[f]];
if (g && "true" === g.isClaimed && this.IsConnectedToPlayingCityViaRoad(d[f])) {
var h = parseInt(g.uid),
g = b.mConnectedUnits[h];
c.mListOfBoxesYouCover[h] = [];
c.mListOfBoxesCoveringYou[h] = [];
for (var i = 0; i < e.length; i++) {
var j = [e[i]],
k = [],
l = [];
simcity.GenerateDataBindingQueries(j, k, {
argumentList : [g]
}, l, !1, "queries");
simcity.RequestDataBindingData(k, j, l, !1, function (b) {
b = b[0];
if (b.outgoingVehicle) {
var d = {
category : a.tokenType,
icon : e[i].icon,
count : b.outgoingVehicle
};
c.mListOfBoxesYouCover[h].push(d)
}
if (b.incomingVehicle) {
d = {
category : a.tokenType,
icon : e[i].icon,
count : b.incomingVehicle
};
c.mListOfBoxesCoveringYou[h].push(d)
}
})
}
}
}
};
simcity.cRegionTradeUIHandler.prototype.SetupTradingAvatars = function (a) {
for (var b = [249487666, 249487665, 249487663, 249487661, 249487658], c = [249487650, 249487652, 249487654, 249487655, 249487657], d = 0; d < b.length; d++) {
var e = a.FindControlByID(b[d]);
e.SetVisibility(!1);
e = a.FindControlByID(c[d]);
e.SetVisibility(!1)
}
var f = simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData,
g = simcity.cRegionTradeUIHandler.prototype.GetYourBoxID();
this.GetCoveringAndReceivingDetails();
for (var h = Object.keys(this.mListOfBoxesYouCover),
d = 0; d < h.length; d++) {
var i = h[d];
if (this.mListOfBoxesYouCover[i] && this.mListOfBoxesYouCover[i].length) {
var j = b[d],
e = a.FindControlByID(j);
e.SetVisibility(!0);
var j = e.FindControlByID(249494366),
k = i == g;
simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("servicesCovering" + d);
j = {
playerID : f.mCities[i].creatorId,
layoutInfo : j,
isBoxClaimed : "true",
isMyBox : k,
isCurrentBox : !1,
showAlerts : !1,
group : "servicesCovering" + d,
boxID : i
};
simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription(j);
j = e.FindControlByID(249587886);
this.mHoverWindowDefaultHeight || (this.mHoverWindowDefaultHeight = j.mHeight);
e.FindControlByID(248984626).SetText(f.mCities[i].name);
e = e.FindControlByID(249576388);
this.mVehicleHoverLayouts = [];
for (var k = this.mListOfBoxesYouCover[i].length, l = 0; l < k; l++) {
this.mVehicleHoverLayouts[l] = gUIManager.LoadAndCacheLayout("Layouts/Region/TokenVehicle_AvatarCoverage.js", e);
this.mVehicleHoverLayouts[l].FindControlByID(249576508).SetWindowImage(this.mListOfBoxesYouCover[i][l].icon);
this.mVehicleHoverLayouts[l].FindControlByID(249576511).SetText("" +
this.mListOfBoxesYouCover[i][l].count);
var m = this.mVehicleHoverLayouts[l].mHeight,
n = this.mVehicleHoverLayouts[l].mLeft,
p = this.mVehicleHoverLayouts[l].mTop;
this.mVehicleHoverLayouts[l].SetPosition(n, p + l * m)
}
j.SetHeight(this.mHoverWindowDefaultHeight + e.mHeight * (k - 1) + 10)
}
}
for (d = 0; d < h.length; d++)
if (i = h[d], this.mListOfBoxesCoveringYou[i] && this.mListOfBoxesCoveringYou[i].length) {
j = c[d];
e = a.FindControlByID(j);
e.SetVisibility(!0);
j = e.FindControlByID(249494366);
k = i == g;
simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("servicesReceiving" +
d);
j = {
playerID : f.mCities[i].creatorId,
layoutInfo : j,
isBoxClaimed : "true",
isMyBox : k,
isCurrentBox : !1,
showAlerts : !1,
group : "servicesReceiving" + d,
boxID : i
};
simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription(j);
j = e.FindControlByID(249587886);
this.mHoverWindowDefaultHeight || (this.mHoverWindowDefaultHeight = j.mHeight);
e.FindControlByID(248984626).SetText(f.mCities[i].name);
e = e.FindControlByID(249576388);
this.mVehicleHoverLayoutsReceive = [];
k = this.mListOfBoxesCoveringYou[i].length;
for (l = 0; l < k; l++)
this.mVehicleHoverLayoutsReceive[l] =
gUIManager.LoadAndCacheLayout("Layouts/Region/TokenVehicle_AvatarCoverage.js", e), this.mVehicleHoverLayoutsReceive[l].FindControlByID(249576508).SetWindowImage(this.mListOfBoxesCoveringYou[i][l].icon), this.mVehicleHoverLayoutsReceive[l].FindControlByID(249576511).SetText("" + this.mListOfBoxesCoveringYou[i][l].count), m = this.mVehicleHoverLayoutsReceive[l].mHeight, n = this.mVehicleHoverLayoutsReceive[l].mLeft, p = this.mVehicleHoverLayoutsReceive[l].mTop, this.mVehicleHoverLayoutsReceive[l].SetPosition(n, p +
l * m);
j.SetHeight(this.mHoverWindowDefaultHeight + e.mHeight * (k - 1) + 10)
}
};
simcity.cRegionTradeUIHandler.prototype.IsViewingClaimedBox = function () {
var a = !1,
b = simcity.gGlobalUIHandler.mRegionViewUIHandler,
c = b.mSelectedRegionViewItem;
c && (b.mRegionData.mBoxes[c.mRegionalBoxID] && "true" == b.mRegionData.mBoxes[c.mRegionalBoxID].isClaimed) && (a = this.IsConnectedToPlayingCityViaRoad(c.mRegionalBoxID));
return a
};
simcity.cRegionTradeUIHandler.prototype.IsConnectedToPlayingCityViaRoad = function (a) {
a = this.mRegionViewUI.GetDirectionalCityTradeData(a, simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData.mPlayingBox.uid);
return null != a && 0 < a.transport.data.numberRoadConnections
};
simcity.cRegionTradeUIHandler.prototype.GetYourBoxID = function () {
return simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData.mPlayingBox.uid
};
simcity.cRegionTradeUIHandler.prototype.IsViewingOwnBox = function () {
var a = null,
b = simcity.gGlobalUIHandler.mRegionViewUIHandler,
a = b.mSelectedRegionViewItem ? b.mSelectedRegionViewItem.mRegionalBoxID : b.mRegionData.mPlayingBox.uid;
return b.mRegionData.mPlayingBox.uid == a
};
simcity.cRegionTradeUIHandler.prototype.ServiceVehicleButtonPressed = function (a, b) {
if (b[1]) {
for (var c = 0; c < b[0]; ++c)
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", b[1], simcity.kRuleIDSCPlayerRuleCycleResearch]));
switch (a) {
case "increment":
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", b[1], simcity.kRuleIDSCPlayerRuleStartResearch]));
break;
case "decrement":
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", b[1], simcity.kRuleIDSCPlayerRuleCancelResearch]))
}
}
};
simcity.cRegionTradeUIHandler.prototype.GetCityTokens = function (a, b) {
for (var c = this.mRegionViewUI.GetCityTradeData(a), d = [], e = [], f = 0, g = c.outgoing.length; f < g; f++) {
var h = c.outgoing[f];
-1 != h.tradeData[b + "TokenPending"] ? 1 == h.tradeData[b + "TokenPending"] && d.push(h.cityData) : h.tradeData[b + "Token"] && d.push(h.cityData)
}
f = 0;
for (g = c.incoming.length; f < g; f++)
h = c.incoming[f], -1 != h.tradeData[b + "TokenPending"] ? 1 == h.tradeData[b + "TokenPending"] && e.push(h.cityData) : h.tradeData[b + "Token"] && e.push(h.cityData);
return {
outgoing : d,
incoming : e
}
};
simcity.cRegionTradeUIHandler.prototype.CanShareToken = function (a, b) {
var c = this.mRegionViewUI.mRegionData.mPlayingBox.uid;
if (this.mRegionViewUI.IsConnectedCity(a)) {
var d = this.mRegionViewUI.GetCityTradeData(c) || null,
e = this.mRegionViewUI.GetCityTradeData(a) || null;
if (d && (e && this.IsTokenAvailable(c, a, b)) && !this.IsSharingToken(c, a, b))
return !0
} else if (c == a && (d = this.mRegionViewUI.GetRegionalConnectedCities(c), 0 < d.length && (a = d[0][0].uid, d = this.mRegionViewUI.GetCityTradeData(c) || null, e = this.mRegionViewUI.GetCityTradeData(a) || null,
d && (e && this.IsTokenAvailable(c, a, b)) && !this.IsSharingToken(c, a, b))))
return !0;
return !1
};
simcity.cRegionTradeUIHandler.prototype.IsTokenAvailable = function (a, b, c) {
var d,
e,
f,
g,
h = [scrui.BuildRequestQuery(["bins", simcity.kResourceIDGarbageServiceTokenCounter]), scrui.BuildRequestQuery(["bins", simcity.kResourceIDFireServiceTokenCounter]), scrui.BuildRequestQuery(["bins", simcity.kResourceIDPoliceServiceTokenCounter]), scrui.BuildRequestQuery(["bins", simcity.kResourceIDHealthServiceTokenCounter])];
scrui.RequestGameData(h, function (a) {
d = 0 < a[0].amount;
e = 0 < a[1].amount;
f = 0 < a[2].amount;
g = 0 < a[3].amount
});
h = this.mRegionViewUI.mRegionData.mCityTradeData[b];
b = null;
if (h && (a = h.connections[a]) && a.connectionData && a.connectionData.hasOwnProperty("t2"))
b = a.connectionData.t2.data;
if (b)
switch (c) {
case simcity.kRegionTradeTokenType_Fire:
return 0 < b.fireStations || e;
case simcity.kRegionTradeTokenType_Police:
return 0 < b.policeStations || f;
case simcity.kRegionTradeTokenType_Garbage:
return 0 < b.garbageBases || d;
case simcity.kRegionTradeTokenType_Health:
return 0 < b.hospitals || g
}
return !1
};
simcity.cRegionTradeUIHandler.prototype.IsSharingToken = function (a, b, c) {
if (this.mRegionViewUI.IsConnectedCity(b) && (b = this.mRegionViewUI.GetCityTradeData(b) || null))
for (var d = 0, e = b.incoming.length; d < e; d++)
if (b.incoming[d].cityData.uid == a) {
var f = b.incoming[d].tradeData;
switch (c) {
case simcity.kRegionTradeTokenType_Fire:
return 0 <= f.fireTokenPending ? f.fireTokenPending : f.fireToken;
case simcity.kRegionTradeTokenType_Police:
return 0 <= f.policeTokenPending ? f.policeTokenPending : f.policeToken;
case simcity.kRegionTradeTokenType_Garbage:
return 0 <=
f.garbageTokenPending ? f.garbageTokenPending : f.garbageToken;
case simcity.kRegionTradeTokenType_Health:
return 0 <= f.healthTokenPending ? f.healthTokenPending : f.healthToken
}
}
return !1
};
simcity.cRegionTradeUIHandler.prototype.UpdateUtilityTradePanel = function (a, b, c, d) {
var e = Object.keys(this.mRegionViewUI.mRegionData.mCityTradeData[b].connections),
f = [],
g = [];
switch (a) {
case "Power":
g = ["0x0eb384b5", "0x0eb384b6", "0x0eb384b7", "0x0eb384b8"];
f = ["0x0e731a2a", "0x0e731a2b", "0x0e731a2c"];
break;
case "Water":
g = ["0x0eb384bb", "0x0eb384bc", "0x0eb384bd", "0x0eb384be"];
f = ["0x0e731a3a", "0x0e731a3b", "0x0e731a3c"];
break;
case "Sewage":
g = ["0x0eb384cb", "0x0eb384cc", "0x0eb384cd", "0x0eb384ce"];
f = ["0x0e731a4a",
"0x0e731a4b", "0x0e731a4c"];
break;
default:
scrui.Assert(!1, "ShowTradeUI - Undefined utility type: " + a)
}
var h = 0,
i = 0,
j = 0,
k = [scrui.BuildRequestQuery(["bins", simcity.kResourceIDPowerImportExchangeRate]), scrui.BuildRequestQuery(["bins", simcity.kResourceIDWaterImportExchangeRate]), scrui.BuildRequestQuery(["bins", simcity.kResourceIDSewageTreatmentImportExchangeRate])];
scrui.RequestGameData(k, function (a) {
h = a[0].amount;
i = a[1].amount;
j = a[2].amount
});
c.DestroyChildren();
for (var k = 0, l = [], m = !1, n = this.GetViewingCity(),
p = 0, q = e.length; p < q; ++p) {
var o = e[p];
if (n == this.mRegionViewUI.mRegionData.mPlayingBox.uid || n == o) {
var r = this.mRegionViewUI.mRegionData.mCities[o];
if (r) {
var s = this.mRegionViewUI.GetDirectionalCityTradeData(b, o),
t = this.mRegionViewUI.GetDirectionalCityTradeData(o, b);
if (this.IsConnectedToPlayingCityViaRoad(o)) {
var u = 0,
v = 0,
x = 0,
w = 0,
A = 0,
z = 0,
y = null;
switch (a) {
case "Power":
u = s.power.data.tradePower;
A = this.mRegionViewUI.mRegionData.mPlayingBox.uid != b ? 0 : t.power.data.boughtPowerPerHour;
v = this.mRegionViewUI.mRegionData.mPlayingBox.uid ==
b ? 0 : t.power.data.tradePower;
y = t.power.visualizedTradeData.tradePower;
z = h;
break;
case "Water":
u = s.water.data.tradingWater;
A = this.mRegionViewUI.mRegionData.mPlayingBox.uid != b ? 0 : t.water.data.boughtWaterPerHour;
v = this.mRegionViewUI.mRegionData.mPlayingBox.uid == b ? 0 : t.water.data.tradingWater;
y = t.water.visualizedTradeData.tradeWater;
z = i;
break;
case "Sewage":
u = s.sewage.data.tradeSewage,
A = this.mRegionViewUI.mRegionData.mPlayingBox.uid != b ? 0 : t.sewage.data.boughtTreatmentCapacityPerHour,
v = this.mRegionViewUI.mRegionData.mPlayingBox.uid ==
b ? 0 : t.sewage.data.tradeSewage,
y = t.sewage.visualizedTradeData.tradeSewage,
z = j
}
x = this.mRegionViewUI.DetermineTradeData(u, v);
s = !0;
x && 0 != x.amount ? (0 < x.amount ? (w = 2, x = x.amount) : (m = !0, x = -x.amount), s = "Sewage" == a ? this.mRegionViewUI.DetermineTradeStatus(o, b, !m, y) : this.mRegionViewUI.DetermineTradeStatus(b, o, !m, y)) : x = 0;
if (0 < x && (b == this.mRegionViewUI.mRegionData.mPlayingBox.uid && m || s)) {
y = gUIManager.LoadAndCacheLayout("Layouts/Region/UtilityTradeItem.js", c);
t = y.FindControlByID(simcity.kUtilityPanelIDs.item.button);
if (m && b == this.mRegionViewUI.mRegionData.mPlayingBox.uid) {
if (o = this.mRegionViewUI.mRegionData.mConnectedUnits[o]) {
u = 0;
switch (a) {
case "Power":
u = 13;
break;
case "Water":
u = 14;
break;
case "Sewage":
u = 15
}
t.mUserData = {
"0" : u,
1 : o
};
t.SetVisibility(!0);
t.SetSelected(s);
t.SetEnabled(!0);
s || (w = 1)
}
} else
t.SetVisibility(!1);
l.push({
cityName : r.name,
tradeAmount : x,
tradeAmountUsed : A,
exchangeRate : z,
textIndex : w,
layout : y
});
y.FindControlByID(simcity.kUtilityPanelIDs.item.cityNameText).SetRawText(r.name);
y.FindControlByID(simcity.kUtilityPanelIDs.item.cityOwnerText).SetRawText(r.creator.screenName);
z = y.FindControlByID(simcity.kUtilityPanelIDs.item.cityOwnerIcon);
simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("tradeServicesHim" + r.creator.id);
simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription({
playerID : r.creator.id,
layoutInfo : z,
isBoxClaimed : "true",
isMyBox : r.creator.id == this.mRegionViewUI.mRegionData.mPlayingBox.creatorId,
isCurrentBox : !1,
showAlerts : !1,
group : "tradeServicesHim" + r.creator.id,
boxID : r.uid
});
y.FindControlByID(simcity.kUtilityPanelIDs.item.statusText).SetLocaleText(new scrui.cLocaleString("RegionView.json",
f[w], "Receiving Utility"));
y.SetPosition(0, y.mHeight * k);
k++
}
}
}
}
}
p = 0;
for (b = l.length; p < b; p++) {
c = l[p];
w = c.textIndex;
z = c.exchangeRate / 1E3;
e = c.tradeAmountUsed;
r = simcity.FormatDecimalPlace(e / (1E3 * z), 0);
f = {
number : c.tradeAmount,
exponent : ""
};
m = {
number : e,
exponent : ""
};
q = z;
switch (a) {
case "Power":
f = simcity.FormatLargeNumberForPower(c.tradeAmount);
m = simcity.FormatLargeNumberForPower(c.tradeAmountUsed);
break;
case "Water":
case "Sewage":
f = simcity.FormatLargeNumberForFluid(c.tradeAmount),
m = simcity.FormatLargeNumberForFluid(c.tradeAmountUsed)
}
1 ==
w ? c.layout.FindControlByID(simcity.kUtilityPanelIDs.item.statusText).UpdateLocaleText({
amount1 : f.number,
exponent1 : f.exponent,
amount2 : q
}) : 1 > e / (1E3 * z) ? c.layout.FindControlByID(simcity.kUtilityPanelIDs.item.statusText).UpdateLocaleText({
amount : m.number,
amount1 : f.number,
amount2 : 0,
exponent : m.exponent,
exponent1 : f.exponent
}) : c.layout.FindControlByID(simcity.kUtilityPanelIDs.item.statusText).UpdateLocaleText({
amount : m.number,
amount1 : f.number,
amount2 : r,
exponent : m.exponent,
exponent1 : f.exponent
});
c.layout.FindControlByID(simcity.kUtilityPanelIDs.item.receivingFromCityText).UpdateLocaleText({
city : c.cityName
})
}
d.SetVisibility(0 ==
k);
0 == k && (n == this.mRegionViewUI.mRegionData.mPlayingBox.uid ? d.SetLocaleText(new scrui.cLocaleString("RegionView.json", g[0], "NO TRADES")) : this.IsConnectedToPlayingCityViaRoad(n) ? this.IsViewingClaimedBox() ? d.SetLocaleText(new scrui.cLocaleString("RegionView.json", g[1], "NO TRADES"), {
city : this.mRegionViewUI.mRegionData.mCities[n].name
}) : d.SetLocaleText(new scrui.cLocaleString("RegionView.json", g[2], "NO TRADES")) : d.SetLocaleText(new scrui.cLocaleString("RegionView.json", g[3], "NO TRADES")))
};
simcity.cRegionTradeUIHandler.prototype.ShowTradeUI = function (a) {
var b = gUIManager.FindControlByID(simcity.kUtilityPanelIDs.myCity.rootPanel),
c = this.mRegionViewUI.mRegionData.mCities[this.mRegionViewUI.mRegionData.mPlayingBox.uid];
b && (b.FindControlByID(simcity.kUtilityPanelIDs.myCity.titleText).SetRawText(c.name), this.UpdateUtilityTradePanel(a, this.mRegionViewUI.mRegionData.mPlayingBox.uid, b.FindControlByID(simcity.kUtilityPanelIDs.myCity.tradePanel), b.FindControlByID(simcity.kUtilityPanelIDs.myCity.noTradeText)))
};
simcity.cRegionTradeUIHandler.prototype.ToggleUtilityTrade = function (a) {
for (var b = 0; b < a.mUserData[0]; ++b)
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", a.mUserData[1], simcity.kRuleIDSCPlayerRuleCycleResearch]));
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", a.mUserData[1], simcity.kRuleIDSCPlayerRuleStartResearch]));
a.SetSelected(!a.mIsSelected);
this.mRegionViewUI.mInitialTradeDataRequestCompleted = !1;
this.mRegionViewUI.mTimeSinceLastDataUpdate = simcity.kRegionViewDataUpdateTimeMS -
1E3;
this.mRegionViewUI.mShouldUpdateDataLayerContextPanel = !0
};
simcity.cRegionTradeUIHandler.prototype.ShowGreatWorksUI = function () {};
simcity.cRegionTradeUIHandler.prototype.ShowGiftingUI = function () {
for (var a = this.mRegionViewUI.mRegionData.mPlayingBox.uid, b = this.GetViewingCity(), c = simcity.kGiftingPanelIDs.resources.startingTabID, d = simcity.gGlobalUIHandler.mRegionViewUIHandler.mContextPanelObj, e = 0, f = simcity.kGiftableResourcesDataBindings.length; e < f; ++e) {
var g = simcity.kGiftableResourcesDataBindings[e];
if (g) {
var h = d.FindControlByID(c);
h && (h.FindControlByID(simcity.kGiftingPanelIDs.resources.tab.button).mUserData = e, h.FindControlByID(simcity.kGiftingPanelIDs.resources.tab.button).SetSelected(this.mResourceGiftingSelectedTab ==
e), h.FindControlByID(simcity.kGiftingPanelIDs.resources.tab.lightIcon).SetWindowImage(g.lightIcon), h.FindControlByID(simcity.kGiftingPanelIDs.resources.tab.darkIcon).SetWindowImage(g.darkIcon), g.text.LoadString(), h.FindControlByID(simcity.kGiftingPanelIDs.resources.tab.tooltipResourceText).SetRawText(g.text.GetText()));
++c
}
}
this.mResourceGiftingLegendControl = 0;
simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("giftingResourcesPlayingCity");
c = d.FindControlByID(243530043);
c = {
playerID : this.mRegionViewUI.mRegionData.mPlayingBox.creatorId,
layoutInfo : c,
isBoxClaimed : "true",
isMyBox : !0,
isCurrentBox : !1,
showAlerts : !1,
group : "giftingResourcesPlayingCity",
boxID : this.mRegionViewUI.mRegionData.mPlayingBox.uid
};
simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription(c);
d.FindControlByID(simcity.kGiftingPanelIDs.resources.viewingCity.avatarWindow).SetVisibility(a != b);
if (a != b) {
if (d.FindAnimationByID(simcity.kGiftingPanelIDs.resources.viewingCity.displayInfoAnimation).Start(scrui.cAnimation.kPlayForward), simcity.gGlobalUIHandler.mAvatarManagerHandler.ClearSubscriptions("giftingResourcesViewingCity"),
c = d.FindControlByID(243530044), this.mRegionViewUI.mRegionData.mBoxes[b] && (c = {
playerID : this.mRegionViewUI.mRegionData.mBoxes[b].creatorId,
layoutInfo : c,
isBoxClaimed : "true",
isMyBox : !1,
isCurrentBox : !1,
showAlerts : !1,
group : "giftingResourcesViewingCity",
boxID : this.mRegionViewUI.mRegionData.mBoxes[b].uid
}, simcity.gGlobalUIHandler.mAvatarManagerHandler.AddSubscription(c)), a = (a = this.mRegionViewUI.mRegionData.mCityTradeData[a]) && null != a.connections[b], d.FindControlByID(simcity.kGiftingPanelIDs.resources.unconnectedCity.window).SetVisibility(!a),
!a)
a = simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData, c = "", c = a.mCities[b] ? a.mCities[b].name : scrui.ParseLocaleString(a.mCityDefaultData.cities[b].cityName).LoadAndGetTextSynchronous(), d.FindControlByID(simcity.kGiftingPanelIDs.resources.unconnectedCity.nameText).UpdateLocaleText({
cityName : c
}), d.FindAnimationByID(simcity.kGiftingPanelIDs.resources.unconnectedCity.displayInfoAnimation).Start(scrui.cAnimation.kPlayForward)
} else
d.FindControlByID(simcity.kGiftingPanelIDs.resources.unconnectedCity.window).SetVisibility(!1);
this.ShowGiftingTab(this.mResourceGiftingSelectedTab)
};
simcity.cRegionTradeUIHandler.prototype.ShowGiftingTab = function (a) {
if (this.mResourceGiftingLegendControl) {
var b = simcity.gGlobalUIHandler.mLayerUIHandler.mLegendLayout;
b && (b.FindControlByID(this.mResourceGiftingLegendControl).SetVisibility(!1), this.mResourceGiftingLegendControl = 0)
}
var c = simcity.gGlobalUIHandler.mRegionViewUIHandler.mContextPanelObj,
d = simcity.kGiftableResourcesDataBindings[a];
if (d) {
simcity.gGlobalUIHandler.mLayerUIHandler.ActivateLayer(d.layerID);
this.mResourceGiftingSelectedTab != a &&
(this.mResourceGiftingCurrentAmount = 0);
if (d.legendID && (b = simcity.gGlobalUIHandler.mLayerUIHandler.mLegendLayout))
this.mResourceGiftingLegendControl = d.legendID, b.FindControlByID(this.mResourceGiftingLegendControl).SetVisibility(!0);
this.mResourceGiftingSelectedTab = a;
a = this.GetViewingCity();
d.text.LoadString();
b = simcity.gGlobalUIHandler.mRegionViewUIHandler.mRegionData;
c.FindControlByID(simcity.kGiftingPanelIDs.resources.titleBarText).UpdateLocaleText({
resource : d.text.GetText()
});
c.FindControlByID(simcity.kGiftingPanelIDs.resources.playingCity.nameText).UpdateLocaleText({
cityName : b.mPlayingBox.name
});
var e = "",
e = b.mCities[a] ? b.mCities[a].name : scrui.ParseLocaleString(b.mCityDefaultData.cities[a].cityName).LoadAndGetTextSynchronous();
c.FindControlByID(simcity.kGiftingPanelIDs.resources.selectedCityTitleBarText).UpdateLocaleText({
resource : d.text.GetText(),
cityName : e
});
c.FindControlByID(simcity.kGiftingPanelIDs.resources.viewingCity.nameText).UpdateLocaleText({
cityName : e
});
c.FindControlByID(simcity.kGiftingPanelIDs.resources.sendButton).mUserData = d.scriptIndex;
this.UpdateGiftingTextForSelectedTab()
}
};
simcity.cRegionTradeUIHandler.prototype.UpdateGiftingTextForSelectedTab = function () {
var a = this.mRegionViewUI.mRegionData.mPlayingBox.uid,
b = this.GetViewingCity(),
c = simcity.gGlobalUIHandler.mRegionViewUIHandler.mContextPanelObj,
d = simcity.kGiftableResourcesDataBindings[this.mResourceGiftingSelectedTab];
if (d) {
var e = 0,
f = 0,
g = this.mRegionViewUI.mRegionData.mConnectedUnits[b];
g && d.enRouteQueries && (d.resourceID == simcity.kResourceIDSimoleons ? scrui.RequestGameData(d.enRouteQueries(g), function (a) {
e = a[0];
f = a[1]
}) :
scrui.RequestGameData(d.enRouteQueries(g), function (a) {
e = Math.max(0, a[0] + a[1]) * simcity.kRegionTradeResourceGiftAmount;
f = Math.max(0, a[2] + a[3]) * simcity.kRegionTradeResourceGiftAmount
}));
d.amountText.LoadString();
g = simcity.FormatLargeNumberByType(e, d.formatType);
g = d.amountText.GetText({
amount : g.number,
exponent : g.exponent
});
c.FindControlByID(simcity.kGiftingPanelIDs.resources.pendingText).UpdateLocaleText({
amount : g
});
if ((g = this.mRegionViewUI.mRegionData.mCityTradeData[a]) && g.giftableResources) {
var h = Math.max(0,
d.calculateTotal(g.giftableResources.data) - f),
i = Math.min(h, simcity.kRegionTradeResourceGiftMaxAmount);
if (this.mResourceGiftingMaxAmount) {
for (; this.mResourceGiftingCurrentAmount + simcity.kRegionTradeResourceGiftAmount <= i; )
this.mResourceGiftingCurrentAmount += simcity.kRegionTradeResourceGiftAmount;
this.mResourceGiftingMaxAmount = !1
} else {
for (; this.mResourceGiftingCurrentAmount > i; )
this.mResourceGiftingCurrentAmount -= simcity.kRegionTradeResourceGiftAmount;
this.mResourceGiftingCurrentAmount = Math.max(0, this.mResourceGiftingCurrentAmount)
}
var j =
simcity.kGiftingTooltips.SendingEnabled;
if (null == g.connections[b])
j = simcity.kGiftingTooltips.UnclaimedOrUnconnectedCity;
else if (0 == this.mResourceGiftingCurrentAmount && (j = simcity.kGiftingTooltips.EmptyGiftAmount), d.resourceID == simcity.kResourceIDSimoleons)
0 < f && (j = simcity.kGiftingTooltips.GiftInProgress), h = Math.max(0, d.calculateTotal(g.giftableResources.data));
c.FindControlByID(simcity.kGiftingPanelIDs.resources.sendButton).SetEnabled(j == simcity.kGiftingTooltips.SendingEnabled);
c.FindControlByID(simcity.kGiftingPanelIDs.resources.sendButton).SetTooltipLocaleText(j);
h = simcity.FormatLargeNumberByType(h, d.formatType);
c.FindControlByID(simcity.kGiftingPanelIDs.resources.playingCity.amountText).SetLocaleText(d.amountText, {
amount : h.number,
exponent : h.exponent
});
c.FindControlByID(simcity.kGiftingPanelIDs.resources.incrementButton).SetEnabled(this.mResourceGiftingCurrentAmount + simcity.kRegionTradeResourceGiftAmount <= i);
c.FindControlByID(simcity.kGiftingPanelIDs.resources.decrementButton).SetEnabled(0 < this.mResourceGiftingCurrentAmount);
h = simcity.FormatLargeNumberByType(this.mResourceGiftingCurrentAmount,
d.formatType);
c.FindControlByID(simcity.kGiftingPanelIDs.resources.sendAmountText).SetLocaleText(d.amountText, {
amount : h.number,
exponent : h.exponent
});
c.FindControlByID(simcity.kGiftingPanelIDs.resources.playingCity.truckIcon).SetVisibility(0 < g.giftableResources.data.numberOfTruckLots);
c.FindControlByID(simcity.kGiftingPanelIDs.resources.playingCity.railIcon).SetVisibility(0 < g.giftableResources.data.numberOfRailLots);
c.FindControlByID(simcity.kGiftingPanelIDs.resources.playingCity.boatIcon).SetVisibility(0 <
g.giftableResources.data.numberOfBoatLots)
}
if ((g = this.mRegionViewUI.mRegionData.mCityTradeData[b]) && g.giftableResources)
h = d.calculateTotal(g.giftableResources.data), h = simcity.FormatLargeNumberByType(h, d.formatType), c.FindControlByID(simcity.kGiftingPanelIDs.resources.viewingCity.amountText).SetLocaleText(d.amountText, {
amount : h.number,
exponent : h.exponent
}), c.FindControlByID(simcity.kGiftingPanelIDs.resources.viewingCity.truckIcon).SetVisibility(0 < g.giftableResources.data.numberOfTruckLots), c.FindControlByID(simcity.kGiftingPanelIDs.resources.viewingCity.railIcon).SetVisibility(0 <
g.giftableResources.data.numberOfRailLots), c.FindControlByID(simcity.kGiftingPanelIDs.resources.viewingCity.boatIcon).SetVisibility(0 < g.giftableResources.data.numberOfBoatLots)
}
b = simcity.kGiftingPanelIDs.resources.startingTabID;
c = simcity.gGlobalUIHandler.mRegionViewUIHandler.mContextPanelObj;
i = 0;
for (j = simcity.kGiftableResourcesDataBindings.length; i < j; ++i)
if (d = simcity.kGiftableResourcesDataBindings[i]) {
var k = c.FindControlByID(b);
if (k && (g = this.mRegionViewUI.mRegionData.mCityTradeData[a]) && g.giftableResources)
h =
Math.max(0, d.calculateTotal(g.giftableResources.data)), h = simcity.FormatLargeNumberByType(h, d.formatType), k.FindControlByID(simcity.kGiftingPanelIDs.resources.tab.tooltipAmountText).SetLocaleText(d.amountText, {
amount : h.number,
exponent : h.exponent
});
++b
}
};
simcity.cRegionTradeUIHandler.prototype.UpdateGiftingClickRun = function () {
this.mResourceGiftingLastTickPress > gUIManager.mTickCount - 8 ? this.mResourceGiftingCurrentClickAmount++ : this.mResourceGiftingCurrentClickAmount = 0;
this.mResourceGiftingLastTickPress = gUIManager.mTickCount
};
simcity.cRegionTradeUIHandler.prototype.SendResourceGift = function (a) {
var b = this.mRegionViewUI.mRegionData.mConnectedUnits[this.GetViewingCity()];
if (b) {
for (; 0 < this.mResourceGiftingCurrentAmount; ) {
for (var c = 0; c < a.mUserData; ++c)
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", b, simcity.kRuleIDSCPlayerRuleCycleResearch]));
scrui.PostGameCommand(scrui.BuildCommand(["runUnitPlayerRule", b, simcity.kRuleIDSCPlayerRuleStartResearch]));
this.mResourceGiftingCurrentAmount -= simcity.kRegionTradeResourceGiftAmount
}
this.mResourceGiftingCurrentAmount =
0;
0 == this.mResourceGiftingSelectedTab && simcity.CreateUnit("Trading_SendSimoleonGift", b);
simcity.ShowTradeCompleteSurvey()
}
};
simcity.cRegionTradeUIHandler.prototype.Update = scrui.Client_ProfZone("RegionTradeUIUpdate", function (a) {
this.mRegionViewUI.mIsContextPanelActive && this.mRegionViewUI.mContextPanelDataBinding && (this.mRefreshTimer -= a, 0 >= this.mRefreshTimer && (this.mRefreshTimer = simcity.kRegionTradeRefreshTime, "gifting" == this.mRegionViewUI.mContextPanelDataBinding.tradeType ? this.UpdateGiftingTextForSelectedTab() : "token" == this.mRegionViewUI.mContextPanelDataBinding.tradeType && this.UpdateTokenUI()))
});
simcity.CategoryQuerying = {};
simcity.gCategoryQueryDataBindings = {};
simcity.gCategoryDLC = {};
simcity.SetAlertLevel = function (a, b) {
var c = simcity.gGlobalUIHandler.mToolPaletteUIHandler,
d = a.hasOwnProperty("parentCategoryID");
if (d) {
var e = simcity.gGlobalUIHandler.mCategoryQueryingHandler;
e.mParentCategoryAlertLevels[a.parentCategoryID] = e.mParentCategoryAlertLevels.hasOwnProperty(a.parentCategoryID) ? Math.max(e.mParentCategoryAlertLevels[a.parentCategoryID], b) : b
}
c.UpdateAlert(a.categoryID, b, d)
};
simcity.UpdateCategoryAlert = function (a, b, c, d) {
var e = simcity.gGlobalUIHandler.mAlertsUIHandler;
void 0 === d && (d = 0);
e.UpdateAlertForCategory(a, b, c, d)
};
simcity.UpdateContextualInfo = function (a, b, c, d, e) {
var f = void 0 !== b,
g = simcity.gGlobalUIHandler.mCategoryQueryingHandler;
a && a.categoryID && (g.mContextualInfo[a.categoryID] = void 0 !== e ? {
showInfo : f,
tableID : b,
headerTextID : c,
bodyTextID : d,
bodyTableID : e
}
: {
showInfo : f,
tableID : b,
headerTextID : c,
bodyTextID : d
})
};
simcity.UpdateGenericContextualInfo = function (a, b) {
simcity.GenericCategory.updateCategoryInfo(a, b)
};
simcity.GetCategoryInfo = function (a, b) {
return simcity.gGlobalUIHandler.mCategoryQueryingHandler.GetDataBinding(a, b)
};
simcity.ForceUpdateCategory = function (a, b) {
var c = simcity.gGlobalUIHandler.mCategoryQueryingHandler,
d = b ? c.GetParentCategoryFromCategory(a) : a;
if (d)
for (var e = Object.keys(c.mDataBindings), f = 0, g = e.length; f < g; ++f)
if (e[f] == d) {
c.mDataBindingIndex = f;
c.mDataBindingForceUpdateIndex = f;
break
}
c.mTimeSinceLastQuery = 1E3;
c.RunQueries()
};
simcity.GetDLCAlert = function (a, b, c, d) {
if (b !== simcity.kAlertLevelCritical && a.hasOwnProperty("DLCAlerts"))
for (var e = 0, f = a.DLCAlerts.length; e < f; ++e) {
var g = (0, a.DLCAlerts[e])(c, d),
b = Math.max(b, g);
if (b === simcity.kAlertLevelCritical)
break
}
return b
};
simcity.UpdateDLCCategoryInfo = function (a, b, c, d) {
if (a.hasOwnProperty("DLCCategoryInfo"))
for (var e = 0, f = a.DLCCategoryInfo.length; e < f; ++e) {
var g = (0, a.DLCCategoryInfo[e])(b, c, d);
if (g)
return simcity.UpdateContextualInfo(a, g[0], g[1], g[2]), !0
}
return !1
};
simcity.GetCategoryInfoLayout = function () {
var a = null,
b = simcity.gGlobalUIHandler.mToolPaletteUIHandler;
b.mDemolishPanelOpen ? a = b.mDemolishInfoContainer : b.mInfoLayout && (a = b.mInfoLayout);
return a
};
simcity.GetCategoryInfoControl = function (a, b) {
var c = null,
d = simcity.GetCategoryInfoLayout(a);
if (d) {
if (d.hasOwnProperty(b))
return d[b];
c = d.FindControlByID(b);
d[b] = c
}
return c
};
simcity.NumberFormat = {};
simcity.NumberFormat.kiloGUID = 2030840470;
simcity.NumberFormat.megaGUID = 2724999403;
simcity.NumberFormat.gigaGUID = 1070310141;
simcity.NumberFormat.teraGUID = 3140225643;
simcity.NumberFormat.Tons = 3209013327;
simcity.NumberFormat.Units = 1821810158;
simcity.NumberFormat.Crates = 1016488917;
simcity.NumberFormat.Fluids = 2997842382;
simcity.NumberFormat.Power = 2391494160;
simcity.NumberFormat.Barrels = 2833605196;
simcity.NumberFormat.Standard = 3025917178;
simcity.FormatLargeNumber = function (a) {
var b = 1;
0 > a && (b = -1);
var c = 0;
1E12 < b * a ? (a /= 1E12, c = simcity.NumberFormat.teraGUID) : 1E9 < b * a ? (a /= 1E9, c = simcity.NumberFormat.gigaGUID) : 1E6 < b * a ? (a /= 1E6, c = simcity.NumberFormat.megaGUID) : 1E3 < b * a && (a /= 1E3, c = simcity.NumberFormat.kiloGUID);
b = "";
0 != c && (b = scrui.TextFromLocaleProperty({
tableID : simcity.StringID.TableGlobalUI,
stringID : c
}));
a = Math.round(100 * a) / 100;
return {
number : a,
exponent : b,
exponentGUID : c
}
};
simcity.FormatDecimalPlace = function (a, b) {
0 <= b && (a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b));
return a
};
simcity.FormatLargeNumberForPower = function (a) {
var b = simcity.NumberFormat.megaGUID,
c = scrui.TextFromLocaleProperty({
tableID : simcity.StringID.TableGlobalUI,
stringID : b
}),
a = simcity.FormatDecimalPlace(a / 1E3, 1);
return {
number : a,
exponent : c,
exponentGUID : b
}
};
simcity.FormatLargeNumberForFluid = function (a) {
var a = a / 1E3,
b = simcity.NumberFormat.kiloGUID,
c = scrui.TextFromLocaleProperty({
tableID : simcity.StringID.TableGlobalUI,
stringID : b
}),
a = simcity.FormatDecimalPlace(a, 1);
return {
number : a,
exponent : c,
exponentGUID : b
}
};
simcity.FormatLargeNumberForBarrels = function (a) {
a = simcity.FormatDecimalPlace(a / 10, 1);
return {
number : a,
exponent : "",
exponentGUID : 0
}
};
simcity.FormatLargeNumberForTons = function (a) {
a = simcity.FormatDecimalPlace(a / 1E3, 1);
return {
number : a,
exponent : "",
exponentGUID : 0
}
};
simcity.FormatLargeNumberForCrates = function (a) {
a = simcity.FormatDecimalPlace(a / 10, 1);
return {
number : a,
exponent : "",
exponentGUID : 0
}
};
simcity.FormatLargeNumberByType = function (a, b) {
switch (b) {
case simcity.NumberFormat.Power:
return simcity.FormatLargeNumberForPower(a);
case simcity.NumberFormat.Fluids:
return simcity.FormatLargeNumberForFluid(a);
case simcity.NumberFormat.Tons:
return simcity.FormatLargeNumberForTons(a);
case simcity.NumberFormat.Crates:
case simcity.NumberFormat.Units:
return simcity.FormatLargeNumberForCrates(a);
case simcity.NumberFormat.Barrels:
return simcity.FormatLargeNumberForBarrels(a);
case simcity.NumberFormat.Standard:
return simcity.FormatLargeNumber(a)
}
return {
number : a,
exponent : "",
exponentGUID : 0
}
};
simcity.IsFormattableType = function (a) {
switch (a) {
case simcity.NumberFormat.Power:
return !0;
case simcity.NumberFormat.Fluids:
return !0;
case simcity.NumberFormat.Tons:
return !0;
case simcity.NumberFormat.Crates:
case simcity.NumberFormat.Units:
return !0;
case simcity.NumberFormat.Barrels:
return !0;
case simcity.NumberFormat.Standard:
return !0
}
return !1
};
simcity.UpdateCategoryInfoMaintenaceCost = function (a, b) {
var c = simcity.GetCategoryInfoControl(a, 196874183);
c && (0 !== b && (b *= -1), c.UpdateLocaleText({
maintenance : b
}))
};
simcity.UpdateCategoryInfoWorkers = function (a, b, c) {
(a = simcity.GetCategoryInfoControl(a, 210950011)) && a.UpdateLocaleText({
amount : b,
capacity : c
})
};
simcity.UpdateCategoryInfoTextControl = function (a, b, c) {
(a = simcity.GetCategoryInfoControl(a, b)) && a.UpdateLocaleText(c)
};
simcity.UpdateCategoryInfoHorizontalSliderControl = function (a, b, c) {
if (a = simcity.GetCategoryInfoControl(a, b))
c = Math.max(0, Math.min(1, c)), a.SetPosition(a.mParentControl.mWidth * c - a.mWidth / 2, a.mTop)
};
simcity.UpdateCategoryInfoGauge = function (a, b, c) {
if (a = simcity.GetCategoryInfoControl(a, b))
c = Math.max(0, Math.min(1, c)), c = scrui.math.GetValueInRange(-90, 90, c), a.SetRotation(c)
};
simcity.UpdateCategoryInfoMeter = function (a, b, c, d) {
1 < c && (c = 1);
a = simcity.GetCategoryInfoControl(a, b);
d ? scrui.SetProgressBarHeight(a, c) : scrui.SetProgressBarWidth(a, c)
};
simcity.UpdateCategoryInfoAnimation = function (a, b, c, d) {
1 < c ? c = 1 : 0 > c && (c = 0);
a = a.FindAnimationByID(b);
b = a.GetDurationMS();
d ? a.PlayToTime(c * b) : a.JumpToTime(c * b)
};
simcity.cCategoryQueryingHandler = function () {
this.UIHandler = scrui.cUIHandler;
this.UIHandler();
this.mTimeSinceLastQuery = 0;
this.mDataBindings = {};
this.mDataBindingIndex = 0;
this.mDataBindingForceUpdateIndex = null;
this.mUpdateOpenCategory = !1;
this.mContextualInfo = {};
this.mParentCategoryAlertLevels = {};
this.mQueryInProgress = this.mShouldDisplayContextualInfo = !1
};
goog.inherits(simcity.cCategoryQueryingHandler, scrui.cUIHandler);
simcity.cCategoryQueryingHandler.prototype.Update = scrui.Client_ProfZone("cCategoryQueryingHandler.Update", function (a) {
this.mTimeSinceLastQuery += a;
this.RunQueries()
});
simcity.cCategoryQueryingHandler.prototype.Init = function () {
for (var a in simcity.gCategoryQueryDataBindings) {
var b = simcity.gCategoryQueryDataBindings[a];
b.hasOwnProperty("parentCategoryID") ? (this.mDataBindings.hasOwnProperty(b.parentCategoryID) || (this.mDataBindings[b.parentCategoryID] = []), this.mDataBindings[b.parentCategoryID].push(b)) : this.mDataBindings[b.categoryID] = [b]
}
for (a in simcity.gCategoryDLC) {
var c = simcity.gCategoryDLC[a],
b = scrui.BuildRequestQuery([simcity.kDataBinAmount, c.unlockBin]);
scrui.RequestGameData([b],
function (a) {
if (a[0]) {
var a = c.category,
b = a.alertQueries,
f;
for (f in c.alertQueries)
b[f] = c.alertQueries[f];
a.DLCAlerts.push(c.getAlerts);
b = a.categoryInfoQueries;
for (f in c.categoryInfoQueries)
b[f] = c.categoryInfoQueries[f];
a.DLCCategoryInfo.push(c.getCategoryInfo)
}
})
}
};
simcity.cCategoryQueryingHandler.prototype.PrintDebugInfo = function () {
simcity.DEBUG && scrui.DebugPrint("cCategoryQueryingHandler gCategoryQueryDataBindings = " + Object.keys(simcity.gCategoryQueryDataBindings).length + ", gCategoryDLC = " + Object.keys(simcity.gCategoryDLC).length + ", mDataBindings = " + Object.keys(this.mDataBindings).length)
};
simcity.cCategoryQueryingHandler.prototype.GetDataBinding = function (a, b) {
if (a) {
if (!b && this.mDataBindings.hasOwnProperty(a))
return this.mDataBindings[a][0];
for (var c in this.mDataBindings)
for (var d = this.mDataBindings[c], e = 0, f = d.length; e < f; ++e) {
var g = d[e];
if (g.categoryID === a || g.categoryID === b)
return g
}
}
return null
};
simcity.cCategoryQueryingHandler.prototype.GetParentCategoryFromCategory = function (a) {
if (a)
for (var b in this.mDataBindings) {
if (b === a)
return b;
for (var c = this.mDataBindings[b], d = 0, e = c.length; d < e; ++d)
if (c[d].categoryID === a)
return b
}
return null
};
simcity.AddCategoryInfoDataBinding = function (a, b, c, d) {
var e = a.categoryInfoQueries;
b.push(e);
simcity.AddSimpleQueries(c, e);
d.push(a)
};
simcity.cCategoryQueryingHandler.prototype.RunQueries = scrui.Client_ProfZone("cCategoryQueryingHandler.RunQueries", function () {
if (!this.mQueryInProgress) {
this.mQueryInProgress = !0;
var a = simcity.gGlobalUIHandler.mToolPaletteUIHandler,
b = a.GetParentAndSubCategoryIDs(),
c = b[0],
d = b[1];
null === c && (this.mDataBindingForceUpdateIndex = null);
b = Object.keys(this.mDataBindings);
if (null == this.mDataBindingForceUpdateIndex && simcity.IsMainTutorialInProgress())
this.mQueryInProgress = !1;
else {
var e = null !== this.mDataBindingForceUpdateIndex &&
(this.mUpdateOpenCategory || simcity.IsMainTutorialInProgress()) ? this.mDataBindingForceUpdateIndex : this.mDataBindingIndex++;
this.mUpdateOpenCategory = !this.mUpdateOpenCategory;
var f = this.mDataBindings[b[e]];
this.mDataBindingIndex ===