Skip to content
Snippets Groups Projects
Commit 204e7253 authored by svornost's avatar svornost
Browse files

Move slave trade presets from widgets into App.Data, and get rid of the awful...

Move slave trade presets from widgets into App.Data, and get rid of the awful widget-iterating mess in customizeSlaveTrade.tw.
parent a7d2639e
No related branches found
No related tags found
No related merge requests found
:: slave trade preset widgets [widget nobr]
App.Data.NationalityPresets = {};
/* To add presets, add <<widget "NationalityPresetName">> and define it as [[Name|passage()][$nationalities = [nationalities go here]]] (old method)*/
/* Presets are weighted according to the number of times the player has incremented that nationality. */
<<widget "NationalityPresetVanillaGlobal">>
<<link "Vanilla Global">>
<<set $nationalities = {
App.Data.NationalityPresets.Vanilla = new Map ([
["Vanilla Global", {
Afghan: 2,
Albanian: 1,
Algerian: 3,
......@@ -218,15 +214,8 @@
Zairian: 3,
Zambian: 1,
Zimbabwean: 2
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaNA">>
<<link "Vanilla North America">>
<<set $nationalities = {
}],
["Vanilla North America", {
American: 6,
Antiguan: 1,
Aruban: 1,
......@@ -255,15 +244,8 @@
Salvadoran: 2,
Trinidadian: 1,
Vincentian: 1
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaSA">>
<<link "Vanilla South America">>
<<set $nationalities = {
}],
["Vanilla South America", {
Argentinian: 4,
Bolivian: 2,
Brazilian: 4,
......@@ -277,15 +259,8 @@
Surinamese: 1,
Uruguayan: 2,
Venezuelan: 3
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaME">>
<<link "Vanilla Middle East">>
<<set $nationalities = {
}],
["Vanilla Middle East", {
Afghan: 2,
Armenian: 2,
Azerbaijani: 1,
......@@ -308,15 +283,8 @@
Syrian: 1,
Turkish: 3,
Yemeni: 2
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaAfrica">>
<<link "Vanilla Africa">>
<<set $nationalities = {
}],
["Vanilla Africa", {
Algerian: 3,
Angolan: 1,
Beninese: 1,
......@@ -371,15 +339,8 @@
Zairian: 3,
Zambian: 1,
Zimbabwean: 2
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaAsia">>
<<link "Vanilla Asia">>
<<set $nationalities = {
}],
["Vanilla Asia", {
Bangladeshi: 4,
Bhutanese: 1,
Bruneian: 1,
......@@ -409,15 +370,8 @@
Turkmen: 1,
Uzbek: 2,
Vietnamese: 3
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaEU">>
<<link "Vanilla Europe">>
<<set $nationalities = {
}],
["Vanilla Europe", {
Albanian: 1,
Andorran: 1,
Austrian: 2,
......@@ -465,15 +419,8 @@
Swiss: 2,
Ukrainian: 3,
Vatican: 1
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetVanillaAU">>
<<link "Vanilla Australia">>
<<set $nationalities = {
}],
["Vanilla Australia", {
Australian: 3,
"a Cook Islander": 1,
Fijian: 1,
......@@ -493,15 +440,11 @@
"a Solomon Islander": 1,
Tongan: 1,
Tuvaluan: 1
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
}],
]);
<<widget "NationalityPresetModNA">>
<<link "Realism North America">>
<<set $nationalities = {
App.Data.NationalityPresets.Mod = new Map([
["Realism North America", {
American: 36503,
Antiguan: 11,
Aruban: 10,
......@@ -530,15 +473,8 @@
Salvadoran: 688,
Trinidadian: 136,
Vincentian: 11
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModSA">>
<<link "Realism South America">>
<<set $nationalities = {
}],
["Realism South America", {
Argentinian: 5102,
Bolivian: 1392,
Brazilian: 22920,
......@@ -552,15 +488,8 @@
Surinamese: 63,
Uruguayan: 362,
Venezuelan: 3826
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModME">>
<<link "Realism Middle East">>
<<set $nationalities = {
}],
["Realism Middle East", {
Afghan: 5090,
Armenian: 286,
Azerbaijani: 1086,
......@@ -583,15 +512,8 @@
Syrian: 2888,
Turkish: 9091,
Yemeni: 3996
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModAfrica">>
<<link "Realism Africa">>
<<set $nationalities = {
}],
["Realism Africa", {
Algerian: 5107,
Angolan: 5166,
Beninese: 1756,
......@@ -646,15 +568,8 @@
Zairian: 13815,
Zambian: 2844,
Zimbabwean: 2355
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModAsia">>
<<link "Realism Asia">>
<<set $nationalities = {
}],
["Realism Asia", {
Bangladeshi: 19160,
Bhutanese: 94,
Bruneian: 50,
......@@ -684,16 +599,9 @@
Turkmen: 707,
Uzbek: 3805,
Vietnamese: 3255
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
/* I need reweighting and possibly country additions */
<<widget "NationalityPresetModEurope">>
<<link "Realism Europe">>
<<set $nationalities = {
}],
/* I need reweighting and possibly country additions */
["Realism Europe", {
Albanian: 289,
Andorran: 7,
Austrian: 897,
......@@ -741,15 +649,8 @@
Swiss: 941,
Ukrainian: 3989,
Vatican: 1
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModAustralia">>
<<link "Realism Australia">>
<<set $nationalities = {
}],
["Realism Australia", {
Australian: 2952,
"a Cook Islander": 1,
Fijian: 98,
......@@ -769,39 +670,10 @@
"a Solomon Islander": 83,
Tongan: 12,
Tuvaluan: 1
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModEastAsia">>
<<link "East Asia">>
<<set $nationalities = {Chinese: 21, Japanese: 2, Korean: 1}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModUSA">>
<<link USA>>
<<set $nationalities = {American: 8, Canadian: 1, Mexican: 3}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModJapan">>
<<link Japan>>
<<set $nationalities = {Japanese: 3}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModBrazil">>
<<link Brazil>>
<<set $nationalities = {
}],
["East Asia", {Chinese: 21, Japanese: 2, Korean: 1}],
["USA", {American: 8, Canadian: 1, Mexican: 3}],
["Brazil", {
Argentinian: 4,
Bolivian: 2,
Brazilian: 30,
......@@ -815,16 +687,45 @@
Surinamese: 1,
Uruguayan: 2,
Venezuelan: 2
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
}],
["Mediterranean", {
Albanian: 29,
Algerian: 404,
Andorran: 1,
Bosnian: 35,
British: 1,
Bulgarian: 71,
Catalan: 75,
Croatian: 42,
Cypriot: 12,
Egyptian: 948,
French: 671,
Georgian: 49,
Greek: 108,
Israeli: 89,
Italian: 605,
Lebanese: 60,
Libyan: 63,
Maltese: 5,
Monégasque: 1,
Montenegrin: 7,
Moroccan: 358,
Palestinian: 18,
Portuguese: 102,
Romanian: 132,
Russian: 40,
Sammarinese: 1,
Slovene: 21,
Spanish: 466,
Syrian: 171,
Tunisian: 113,
Turkish: 808,
Ukrainian: 105,
Vatican: 1,
}],
/* I need reweighting */
<<widget "NationalityPresetModGlobalRealism">>
<<link "Realism Global">>
<<set $nationalities = {
/* I need reweighting */
["Realism Global", {
Afghan: 5090,
Albanian: 289,
Algerian: 5107,
......@@ -1037,50 +938,5 @@
Zairian: 13815,
Zambian: 2844,
Zimbabwean: 2355
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
<<widget "NationalityPresetModMediterranean">>
<<link Mediterranean>>
<<set $nationalities = {
Albanian: 29,
Algerian: 404,
Andorran: 1,
Bosnian: 35,
British: 1,
Bulgarian: 71,
Catalan: 75,
Croatian: 42,
Cypriot: 12,
Egyptian: 948,
French: 671,
Georgian: 49,
Greek: 108,
Israeli: 89,
Italian: 605,
Lebanese: 60,
Libyan: 63,
Maltese: 5,
Monégasque: 1,
Montenegrin: 7,
Moroccan: 358,
Palestinian: 18,
Portuguese: 102,
Romanian: 132,
Russian: 40,
Sammarinese: 1,
Slovene: 21,
Spanish: 466,
Syrian: 171,
Tunisian: 113,
Turkish: 808,
Ukrainian: 105,
Vatican: 1,
}>>
<<set _gotoPassage = passage()>>
<<goto _gotoPassage>>
<</link>>
<</widget>>
\ No newline at end of file
}],
]);
......@@ -16,5 +16,13 @@ App.CustomSlaveTrade = {
};
$("#importExportArea").html("").append(textArea).append(button);
},
generatePresetLinks: function(group) {
let links = [];
for (const [name, nationalities] of App.Data.NationalityPresets[group]) {
links.push(App.UI.link(name, () => V.nationalities = nationalities, [], passage()));
}
return links.join(" | ");
}
};
......@@ -22,31 +22,13 @@
[[Reset filters|passage()][$baseControlsFilter = "all"]] | [[Clear all nationalities|passage()][$nationalities = {}]]
</div>
<br style="clear:both"><hr style="margin:0">
Vanilla presets:
<span id="vanilla-presets"></span>
<<script>>
var widgets = Story.widgets
.map(function(wp) { return wp.text.match(/<<widget\s+"NationalityPresetVanilla\S+"\s*>>/g); })
.filter(function(ws) { return ws; })
.reduce(function(arr, el) { return arr.concat(el); }, [])
.map(function(w) { return w.replace(/widget\s+"(.*)"\s*/, '$1'); })
.filter(function(w) { return Macro.has(w.replace(/[<>]/g, '')); })
.sort().join(' | ');
setTimeout(function() { new Wikifier(jQuery('#vanilla-presets'), widgets); }, 0);
<</script>>
<div>
Vanilla presets:
<<= App.CustomSlaveTrade.generatePresetLinks("Vanilla")>>
</div>
<div>
Mod presets:
<span id="mod-presets"></span>
<<script>>
var widgets = Story.widgets
.map(function(wp) { return wp.text.match(/<<widget\s+"NationalityPresetMod\S+"\s*>>/g); })
.filter(function(ws) { return ws; })
.reduce(function(arr, el) { return arr.concat(el); }, [])
.map(function(w) { return w.replace(/widget\s+"(.*)"\s*/, '$1'); })
.filter(function(w) { return Macro.has(w.replace(/[<>]/g, '')); })
.sort().join(' | ');
setTimeout(function() { new Wikifier(jQuery('#mod-presets'), widgets); }, 0);
<</script>>
<<= App.CustomSlaveTrade.generatePresetLinks("Mod")>>
</div>
<p>
<<link "Export Settings">><<script>>App.CustomSlaveTrade.export()<</script>><</link>> | <<link "Import Settings">><<script>>App.CustomSlaveTrade.import()<</script>><</link>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment