Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MT = {};
- (function () {
- function addMultiTopic() {
- var Game = function (company) {
- this.secondTopic;
- }
- var getSelectedSecondTopic = function () {
- var modalContent = $(".simplemodal-data");
- var topicName = modalContent.find(".pickSecondTopicButton").text();
- var topic = GameManager.company.topics.first(function (t) {
- return t.name == topicName
- });
- return topic
- };
- /* Add Button To Game Definition Screen */
- var keepme = UI.showGameDefinition;
- UI.showGameDefinition = function (company, options) {
- keepme(company, options);
- var game = company.currentGame;
- $(".selectionOverlayContainer").hide();
- var content = $(".gameDefinitionContent");
- var template = $("#gameDefinitionContentTemplate").clone();
- var t = content.find('.centeredButtonWrapper').find('.pickTopicButton');
- var q = t.parent();
- template.find("#gameTitle").attr("value", company.currentGame.title);
- originalName = company.currentGame.title;
- q.append('<div class="selectorButton windowStepActionButton selectorButtonEmpty pickSecondTopicButton" style="display: inline-block;"> Pick Topic </div>');
- content.find(".pickSecondTopicButton").css("margin-left", "2.5px").css("margin-right", "2.5px").css("width", "145px");
- content.find(".pickTopicButton").css("margin-left", "2.5px").css("margin-right", "2.5px").css("width", "145px");
- var a = content.find(".pickSecondTopicButton");
- UI.maxFont(void 0, a, 18);
- content.find(".pickSecondTopicButton").clickExcl(function () {
- UI.pickSecondTopicClick()
- });
- }
- /* */
- /* Select Topic For Second Topic */
- UI.pickTopicClick = function (element) {
- Sound.click();
- var isResearch = element === "research";
- if (!isResearch) {
- var game =
- GameManager.company.currentGame;
- if (game && (game.flags.lockedSettings && game.flags.lockedSettings.topic)) {
- var container = $(".simplemodal-data").find(".pickTopicButton").parent(".centeredButtonWrapper");
- container.effect("shake", {
- times : 2,
- distance : 5
- }, 50);
- return
- }
- }
- if (!isResearch && element) {
- UI._selectTopic(element.innerText);
- return
- }
- PlatformShim.execUnsafeLocalFunction(function () {
- var modal = $(".simplemodal-data");
- modal.find(".overlayTitle").text("Pick Topic".localize("heading"));
- var container = modal.find(".listContainer");
- container.empty();
- var activeTopictemplate = '<div class="selectorButton whiteButton" onclick="UI.pickTopicClick(this)">{{name}}</div>';
- var lockedTopicTemplate = '<div class="selectorButton disabledButton">{{name}}</div>';
- var itemsPerRow = 3;
- var currentCount = 0;
- var row = 0;
- var researchVisibleCount = 0;
- var topics = General.getTopicOrder(GameManager.company);
- if(GameManager.company.currentgame != null)
- var second = modal.find(".pickSecondTopicButton").get(0).innerText;
- if (UI.pickTopicFontSize == undefined) {
- var values = [];
- for (var i = 0; i < topics.length; i++) {
- if (second == topics[i].name)
- continue;
- values.push(topics[i].name);
- }
- //UI.pickTopicFontSize = UI._getMaxFontSize("{0}pt {1}",
- //UI.IS_SEGOE_UI_INSTALLED ? "Segoe UI" : "Open Sans", 16, 10, 175, values)
- }
- for (var i = 0; i < topics.length; i++) {
- var topic = topics[i];
- currentCount++;
- if (currentCount > itemsPerRow) {
- row++;
- currentCount = 1
- }
- var isAvailable = GameManager.company.topics.indexOf(topic) != -1;
- var isInResearch = GameManager.currentResearches.filter(function (f) {
- return f.topicId === topic.id
- }).length > 0;
- var isEnabled = isResearch ? !isAvailable && (!isInResearch && researchVisibleCount < Research.TOPICS_VISIBLE) : isAvailable;
- var template = isEnabled ? activeTopictemplate :
- lockedTopicTemplate;
- var isNameHidden = isResearch && (!isEnabled && (!isAvailable && !isInResearch)) || !isResearch && !isEnabled;
- if (!isNameHidden)
- if (GameManager.areHintsEnabled() && Knowledge.hasTopicAudienceWeightingKnowledge(GameManager.company, topic)) {
- var enabledDisabledContent = !isEnabled ? " disabledButton" : '" onclick="UI.pickTopicClick(this)';
- var whiteButton = !isEnabled ? " " : " whiteButton ";
- var t = '<div class="selectorButton' + whiteButton + "pickTopicButtonAudienceHintVisible" + enabledDisabledContent + '"><span style="position:relative;top:5px;">{0}<span style="font-size:11pt;"><br/>{1}</span></span></div>';
- template = t.format(topic.name, Knowledge.getTopicAudienceHtml(GameManager.company, topic))
- } else
- template = template.replace("{{name}}", topic.name);
- else
- template = template.replace("{{name}}", "?");
- var element = $(template);
- element.css("position", "absolute");
- element.css("top", 50 * row + row * 10);
- element.css("left", (currentCount - 1) * 190 + 10);
- element.css("font-size", UI.pickTopicFontSize + "pt");
- container.append(element);
- if (isResearch && (!isAvailable && !isInResearch))
- researchVisibleCount++
- }
- modal.find(".selectionOverlayContainer").fadeIn("fast")
- })
- };
- UI._selectTopic = function (name, topicNr) {
- var pickTopicButton = topicNr == 2 ? $(".simplemodal-data").find(".pickSecondTopicButton") : $(".simplemodal-data").find(".pickTopicButton");
- var current = pickTopicButton.get(0).innerText;
- var names = name.split("\n");
- if (names == current) {
- pickTopicButton.text("Pick Genre".localize());
- pickTopicButton.addClass("selectorButtonEmpty");
- } else {
- pickTopicButton.text(names);
- pickTopicButton.removeClass("selectorButtonEmpty");
- }
- pickTopicButton.get(0).innerText = names[0];
- var game = GameManager.company.currentGame;
- var topic = Topics.topics.first(function (i) {
- return i.name == name;
- });
- if (topicNr != 2) {
- if(GameManager.company.currentgame != null) {
- game.topic = topic;
- } else {
- pickTopicButton.get(0).innerText = names[0];
- pickTopicButton.removeClass("selectorButtonEmpty");
- }
- if(GameManager.company.currentgame != null)
- if (game.topic)
- $(".simplemodal-data").find("#pickSecondGenreButton").removeClass("selectorButtonInactive windowStepActionInactive").addClass("selectorButton windowStepActionButton");
- } else
- game.secondTopic = topic;
- $(".simplemodal-data").find(".selectionOverlayContainer").fadeOut("fast");
- UI._updateGameDefinitionNextButtonEnabled()
- };
- UI.pickSecondTopicClick = function (element) {
- Sound.click();
- var isResearch = element === "research";
- if (!isResearch) {
- var game =
- GameManager.company.currentGame;
- if (game && (game.flags.lockedSettings && game.flags.lockedSettings.secondTopic)) {
- var container = $(".simplemodal-data").find(".pickSecondTopicButton").parent(".centeredButtonWrapper");
- container.effect("shake", {
- times : 2,
- distance : 5
- }, 50);
- return
- }
- }
- if (!isResearch && element) {
- UI._selectTopic(element.innerText, 2);
- return
- }
- PlatformShim.execUnsafeLocalFunction(function () {
- var modal = $(".simplemodal-data");
- modal.find(".overlayTitle").text("Pick Topic".localize("heading"));
- var container = modal.find(".listContainer");
- container.empty();
- var activeTopictemplate = '<div class="selectorButton whiteButton" onclick="UI.pickSecondTopicClick(this)">{{name}}</div>';
- var lockedTopicTemplate = '<div class="selectorButton disabledButton">{{name}}</div>';
- var itemsPerRow = 3;
- var currentCount = 0;
- var row = 0;
- var researchVisibleCount = 0;
- var topics = General.getTopicOrder(GameManager.company);
- var first = modal.find(".pickTopicButton").get(0).innerText;
- if (UI.pickSecondTopicFontSize == undefined) {
- var values = [];
- for (var i = 0; i < topics.length; i++) {
- if (first == topics[i].name)
- continue;
- values.push(topics[i].name);
- }
- //UI.pickSecondTopicFontSize = UI._getMaxFontSize("{0}pt {1}",
- //UI.IS_SEGOE_UI_INSTALLED ? "Segoe UI" : "Open Sans", 16, 10, 175, values)
- }
- for (var i = 0; i < topics.length; i++) {
- var topic = topics[i];
- currentCount++;
- if (currentCount > itemsPerRow) {
- row++;
- currentCount = 1
- }
- var isAvailable = GameManager.company.topics.indexOf(topic) != -1;
- var isInResearch = GameManager.currentResearches.filter(function (f) {
- return f.topicId === topic.id
- }).length > 0;
- var isEnabled = isResearch ? !isAvailable && (!isInResearch && researchVisibleCount < Research.TOPICS_VISIBLE) : isAvailable;
- var template = isEnabled ? activeTopictemplate :
- lockedTopicTemplate;
- var isNameHidden = isResearch && (!isEnabled && (!isAvailable && !isInResearch)) || !isResearch && !isEnabled;
- if (!isNameHidden)
- if (GameManager.areHintsEnabled() && Knowledge.hasTopicAudienceWeightingKnowledge(GameManager.company, topic)) {
- var enabledDisabledContent = !isEnabled ? " disabledButton" : '" onclick="UI.pickSecondTopicClick(this)';
- var whiteButton = !isEnabled ? " " : " whiteButton ";
- var t = '<div class="selectorButton' + whiteButton + "pickTopicButtonAudienceHintVisible" + enabledDisabledContent + '"><span style="position:relative;top:5px;">{0}<span style="font-size:11pt;"><br/>{1}</span></span></div>';
- template = t.format(topic.name, Knowledge.getTopicAudienceHtml(GameManager.company, topic))
- } else
- template = template.replace("{{name}}", topic.name);
- else
- template = template.replace("{{name}}", "?");
- var element = $(template);
- element.css("position", "absolute");
- element.css("top", 50 * row + row * 10);
- element.css("left", (currentCount - 1) * 190 + 10);
- element.css("font-size", UI.pickSecondTopicFontSize + "pt");
- container.append(element);
- if (isResearch && (!isAvailable && !isInResearch))
- researchVisibleCount++
- }
- modal.find(".selectionOverlayContainer").fadeIn("fast")
- })
- };
- /* */
- /* Update Game History */
- var GameDetail = UI._getElementForGameDetail;
- UI._getElementForGameDetail = function (game, avgReview) {
- var d = GameDetail(game, avgReview);
- if (game.secondTopic)
- d.find(".gameDetailsTopicGenre").text(game.topic.name + "-" + game.secondTopic.name + "/" + game.genre.name);
- else if (game.secondGenre)
- d.find(".gameDetailsTopicGenre").text(game.topic.name + "/" + game.genre.name + "-" + game.secondGenre.name);
- else if (game.secondToipc && game.secondGenre)
- d.find(".gameDetailsTopicGenre").text(game.topic.name + "-" + game.secondTopic.name + "/" + game.genre.name + "-" + game.secondGenre.name);
- else
- d.find(".gameDetailsTopicGenre").text(game.topic.name + "/" + game.genre.name);
- return d;
- };
- /* */
- /* Save/Load Second Topic */
- Game.prototype.getSecondTopicDisplayName = function () {
- if (!this.secondTopic)
- return this.topic.name;
- return this.topic.name + "-" + this.secondTopic.name
- };
- var save = Game.prototype.save;
- Game.prototype.save = function () {
- var data = {};
- if(this.secondTopic)
- data["secondTopic"] = this.secondTopic.id;
- save;
- }
- var load = Game.load;
- Game.load = function (data, company) {
- load(data, company);
- if (data["secondTopic"] != undefined)
- game.secondTopic = Topics.topics.first(function (item) {
- return item.id === data["secondTopic"]
- });
- }
- /* */
- } addMultiTopic();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement