1
|
{"uid":"ECF00B441300864C6059B990EDE620CE8CA1","isLoaded":true,"lastModificationTime":0,"items":{"name":"Component_FormulaHandler","type":"game_script","order":10,"content":"# ===================================================================\n#\n# Script: Component_FormulaHandler\n#\n# $$COPYRIGHT$$\n#\n# ===================================================================\nclass Component_FormulaHandler extends ui.Component_Handler\n ###*\n * A binding-handler component allows a UI game object to execute\n * property-bindings.<br><br>\n *\n * For example: A text-label can bind its text-property to a backend-field \n * like the current music-volume to always display correct music-volume. \n * If the volume changes, the text-property will be updated\n * automatically.\n *\n * To define a binding, a special property-path syntax is used. For example:<br>\n * <br>\n * $myTextField.text<br>\n * <br>\n * is a property-path to access the text-property of a text-field object\n * with the identifier \"myTextField\". For more information, take a look\n * into the \"In Game UI System\" section of the help-file.\n * \n * @module ui\n * @class Component_BindingHandler\n * @extends ui.Component_Handler\n * @memberof ui\n * @constructor\n ###\n constructor: () ->\n @breakChainAt = null\n \n ###*\n * Initializes the binding-handler.\n * \n * @method setup\n ###\n setup: ->\n \n ###*\n * Updates the binding-handler.\n * \n * @method update\n ### \n update: ->\n for formula in @object.formulas\n @executeFormula(formula)\n \n @object.initialized = yes\n \n return null\n \n executeFormula: (formula) -> \n if @checkObject(formula)\n window.o = @object\n window.d = @object.data[0]\n formula.exec()\n \n @executeFormula: (object, formula) ->\n window.o = object\n window.d = object.data[0]\n formula.exec()\n \n ###*\n * Evaluates a specified property-path and returns the result.\n * \n * @method fieldValue\n * @param {string} path - A property-path.\n * @return {Object} The value of the property-path.\n ### \n fieldValue: (path) -> ui.FormulaHandler.fieldValue(@object, path) \n \n ###*\n * Evaluates a property-path on a specified object and returns the result.\n * \n * @method fieldValue\n * @static\n * @param {Object} object - An object to evaluate the property-path on.\n * @param {string} path - A property-path.\n * @return {Object} The value of the property-path.\n ### \n @fieldValue: (object, path, readOnly) ->\n if typeof (path?.exec) == \"function\"\n window.o = object\n window.d = object?.data?[0]\n value = path.exec()\n \n return value ? 0\n else\n return path\n \nui.Component_FormulaHandler = Component_FormulaHandler","parentId":"01A95DA3K01E8A4CB4SBE17E790BCE1FC035","folder":false,"compiledContent":"var Component_FormulaHandler,\n extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },\n hasProp = {}.hasOwnProperty;\n\nComponent_FormulaHandler = (function(superClass) {\n extend(Component_FormulaHandler, superClass);\n\n\n /**\n * A binding-handler component allows a UI game object to execute\n * property-bindings.<br><br>\n *\n * For example: A text-label can bind its text-property to a backend-field \n * like the current music-volume to always display correct music-volume. \n * If the volume changes, the text-property will be updated\n * automatically.\n *\n * To define a binding, a special property-path syntax is used. For example:<br>\n * <br>\n * $myTextField.text<br>\n * <br>\n * is a property-path to access the text-property of a text-field object\n * with the identifier \"myTextField\". For more information, take a look\n * into the \"In Game UI System\" section of the help-file.\n * \n * @module ui\n * @class Component_BindingHandler\n * @extends ui.Component_Handler\n * @memberof ui\n * @constructor\n */\n\n function Component_FormulaHandler() {\n this.breakChainAt = null;\n }\n\n\n /**\n * Initializes the binding-handler.\n * \n * @method setup\n */\n\n Component_FormulaHandler.prototype.setup = function() {};\n\n\n /**\n * Updates the binding-handler.\n * \n * @method update\n */\n\n Component_FormulaHandler.prototype.update = function() {\n var formula, i, len, ref;\n ref = this.object.formulas;\n for (i = 0, len = ref.length; i < len; i++) {\n formula = ref[i];\n this.executeFormula(formula);\n }\n this.object.initialized = true;\n return null;\n };\n\n Component_FormulaHandler.prototype.executeFormula = function(formula) {\n if (this.checkObject(formula)) {\n window.o = this.object;\n window.d = this.object.data[0];\n return formula.exec();\n }\n };\n\n Component_FormulaHandler.executeFormula = function(object, formula) {\n window.o = object;\n window.d = object.data[0];\n return formula.exec();\n };\n\n\n /**\n * Evaluates a specified property-path and returns the result.\n * \n * @method fieldValue\n * @param {string} path - A property-path.\n * @return {Object} The value of the property-path.\n */\n\n Component_FormulaHandler.prototype.fieldValue = function(path) {\n return ui.FormulaHandler.fieldValue(this.object, path);\n };\n\n\n /**\n * Evaluates a property-path on a specified object and returns the result.\n * \n * @method fieldValue\n * @static\n * @param {Object} object - An object to evaluate the property-path on.\n * @param {string} path - A property-path.\n * @return {Object} The value of the property-path.\n */\n\n Component_FormulaHandler.fieldValue = function(object, path, readOnly) {\n var ref, value;\n if (typeof (path != null ? path.exec : void 0) === \"function\") {\n window.o = object;\n window.d = object != null ? (ref = object.data) != null ? ref[0] : void 0 : void 0;\n value = path.exec();\n return value != null ? value : 0;\n } else {\n return path;\n }\n };\n\n return Component_FormulaHandler;\n\n})(ui.Component_Handler);\n\nui.Component_FormulaHandler = Component_FormulaHandler;\n\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLElBQUEsd0JBQUE7RUFBQTs7O0FBQU07Ozs7QUFDRjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0VBdUJhLGtDQUFBO0lBQ1QsSUFBQyxDQUFBLFlBQUQsR0FBZ0I7RUFEUDs7O0FBR2I7Ozs7OztxQ0FLQSxLQUFBLEdBQU8sU0FBQSxHQUFBOzs7QUFFUDs7Ozs7O3FDQUtBLE1BQUEsR0FBUSxTQUFBO0FBQ0osUUFBQTtBQUFBO0FBQUEsU0FBQSxxQ0FBQTs7TUFDSSxJQUFDLENBQUEsY0FBRCxDQUFnQixPQUFoQjtBQURKO0lBR0EsSUFBQyxDQUFBLE1BQU0sQ0FBQyxXQUFSLEdBQXNCO0FBRXRCLFdBQU87RUFOSDs7cUNBUVIsY0FBQSxHQUFnQixTQUFDLE9BQUQ7SUFDWixJQUFHLElBQUMsQ0FBQSxXQUFELENBQWEsT0FBYixDQUFIO01BQ0ksTUFBTSxDQUFDLENBQVAsR0FBVyxJQUFDLENBQUE7TUFDWixNQU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ybWF0aW9uLCB0YWtlIGEgbG9va1xuICAgICogaW50byB0aGUgXCJJbiBHYW1lIFVJIFN5c3RlbVwiIHNlY3Rpb24gb2YgdGhlIGhlbHAtZmlsZS5cbiAgICAqIFxuICAgICogQG1vZHVsZSB1aVxuICAgICogQGNsYXNzIENvbXBvbmVudF9CaW5kaW5nSGFuZGxlclxuICAgICogQGV4dGVuZHMgdWkuQ29tcG9uZW50X0hhbmRsZXJcbiAgICAqIEBtZW1iZXJvZiB1aVxuICAgICogQGNvbnN0cnVjdG9yXG4gICAgIyMjXG4gICAgY29uc3RydWN0b3I6ICgpIC0+XG4gICAgICAgIEBicmVha0NoYWluQXQgPSBudWxsXG4gICAgICAgIFxuICAgICMjIypcbiAgICAqIEluaXRpYWxpemVzIHRoZSBiaW5kaW5nLWhhbmRsZXIuXG4gICAgKiBcbiAgICAqIEBtZXRob2Qgc2V0dXBcbiAgICAjIyNcbiAgICBzZXR1cDogLT5cbiAgICAgXG4gICAgIyMjKlxuICAgICogVXBkYXRlcyB0aGUgYmluZGluZy1oYW5kbGVyLlxuICAgICogXG4gICAgKiBAbWV0aG9kIHVwZGF0ZVxuICAgICMjIyAgIFxuICAgIHVwZGF0ZTogLT5cbiAgICAgICAgZm9yIGZvcm11bGEgaW4gQG9iamVjdC5mb3JtdWxhc1xuICAgICAgICAgICAgQGV4ZWN1dGVGb3JtdWxhKGZvcm11bGEpXG4gICAgICAgIFxuICAgICAgICBAb2JqZWN0LmluaXRpYWxpemVkID0geWVzXG4gICAgICAgIFxuICAgICAgICByZXR1cm4gbnVsbFxuICAgICBcbiAgICBleGVjdXRlRm9ybXVsYTogKGZvcm11bGEpIC0+IFxuICAgICAgICBpZiBAY2hlY2tPYmplY3QoZm9ybXVsYSlcbiAgICAgICAgICAgIHdpbmRvdy5vID0gQG9iamVjdFxuICAgICAgICAgICAgd2luZG93LmQgPSBAb2JqZWN0LmRhdGFbMF1cbiAgICAgICAgICAgIGZvcm11bGEuZXhlYygpXG4gICAgIC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0+XG4gICAgICAgIGlmIHR5cGVvZiAocGF0aD8uZXhlYykgPT0gXCJmdW5jdGlvblwiXG4gICAgICAgICAgICB3aW5kb3cubyA9IG9iamVjdFxuICAgICAgICAgICAgd2luZG93LmQgPSBvYmplY3Q/LmRhdGE/WzBdXG4gICAgICAgICAgICB2YWx1ZSA9IHBhdGguZXhlYygpXG4gICAgICAgICAgICBcbiAgICAgICAgICAgIHJldHVybiB2YWx1ZSA/IDBcbiAgICAgICAgZWxzZVxuICAgICAgICAgICAgcmV0dXJuIHBhdGhcbiAgICAgXG51aS5Db21wb25lbnRfRm9ybXVsYUhhbmRsZXIgPSBDb21wb25lbnRfRm9ybXVsYUhhbmRsZXIiXX0=\n//# sourceURL=Component_FormulaHandler_120.js"},"summary":["name","type"]}
|