Skip to content

Commit 3e96150

Browse files
committed
settings editor finished
1 parent 73d62c6 commit 3e96150

10 files changed

Lines changed: 478 additions & 127 deletions

File tree

source/config/settings.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,24 @@ if (user_data !== '') {
164164
attackLinks: {
165165
scoutVillage: 100,
166166
scoutPlaceLinks: [5, 100, 500],
167+
scoutPlaceLinksName: "Scout{amount}",
168+
167169
fakePlaceLink: true,
168170
fakePlaceExcludeTroops: [],
169-
noblePlaceLink: true,
170-
noblePlaceLinksForceShow: true,
171-
noblePlaceLinkDivideAddRam: false,
172-
nobleSupport: [{ Population: 200, Unit: 'light', VillageType: 'off' }, { Population: 600, Unit: 'heavy', VillageType: 'def'}]
171+
fakePlaceLinkName: "Fake",
172+
173+
noblePlaceLink: true, /* (de)Activate all noble links */
174+
noblePlaceLinkFirstName: "NobleFirst", /* Name for the first noble which has most troops */
175+
176+
noblePlaceLinkSupportName: "NobleMin", /* snob with only minimal support */
177+
noblePlaceLinksForceShow: true, /* Show NobleMin also where is only one 1 snob in the village */
178+
nobleSupport: [
179+
{ amount: 50, unit: 'light', villageType: 'off' },
180+
{ amount: 50, unit: 'heavy', villageType: 'def'}
181+
],
182+
183+
noblePlaceLinkDivideName: "NobleDivide",
184+
noblePlaceLinkDivideAddRam: false /* false: Rams are not sent along with NobleDivide */
173185
},
174186
alternativeTargetPosition: false,
175187
customPlaceLinks:
@@ -220,7 +232,13 @@ if (user_data !== '') {
220232
twMapPlayerGraph: { player: [true, true], p_player: [false, false], oda_player: [true, false], odd_player: [true, false] },
221233
twMapTribeGraph: { tribe: [true, true], p_tribe: [false, false], oda_tribe: [true, false], odd_tribe: [true, false] },
222234

223-
popup: { show: true, width: 900, height: 865 }
235+
popup: {
236+
show: true,
237+
width: 900,
238+
height: 865,
239+
left: ($('window').width() - 990), /* Heh heh nice dependency :) */
240+
top: 50
241+
}
224242
},
225243
smithy:
226244
[

source/config/trans.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ trans = {
5757
settings: {
5858
reset: "De standaard Sangu Package settings herstellen",
5959
resetAll: "Sangu Package 'fabrieksinstellingen' herstellen",
60+
configuration: "Configuratie",
61+
configurationFormTogglerTooltip: "Klik op de knoppen om de verschillende editeerschermen te openen",
6062
activate: "Activeer",
6163
deleteTooltip: "Verwijderen",
6264
addRecord: "» Toevoegen",
@@ -152,8 +154,7 @@ trans = {
152154
backOn: "Terug op",
153155
onlyAttack: "1 aanval op {arrivalDateFirst} ({timeLeftFirst})",
154156
multipleAttack: "{amount} aanvallen tussen {arrivalDateFirst} ({timeLeftFirst}) en {arrivalDateLast} ({timeLeftLast})",
155-
changeSpeedImageTooltips: "{originalTitle} - Klik om de traagste eenheid te wijzigen",
156-
attackLinkNames: { fake: 'Fake', scout: 'Scout', nobleMax: 'NobleFirst', nobleMin: 'NobleMin', nobleDivide: 'NobleDivide' }
157+
changeSpeedImageTooltips: "{originalTitle} - Klik om de traagste eenheid te wijzigen"
157158
},
158159
jumper: {
159160
goToMap: "Ga naar de kaart"

source/mergeIt.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SetWorkingDir, %A_ScriptDir%
1111

1212
UpdateVersion("version.txt")
1313
ParseAndSaveFile(inputFile, savePath, saveAs)
14-
;ParseAndSaveFile("release.user.js", "..\site\", saveAs)
14+
ParseAndSaveFile("release.user.js", "..\site\", saveAs)
1515
ParseAndSaveFile("..\site\index_toMerge.php", "..\site\", "index.php")
1616

1717
; Autocopy to Firefox greasemonkey directory

source/page/info_villageplayertribe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ if (user_data.profile.show && (location.href.indexOf('screen=info_village') == -
203203
var popupWidth = profile.popup.width;
204204
var popupHeight = profile.popup.height;
205205
infoTable.after('<div class="messagepop pop" id="popup" style="display: none"><iframe src=' + twLink + ' width=' + popupWidth + ' height=' + popupHeight + '></div>');
206-
$("#popup").css({ "left": ($('window').width() - 60 - popupWidth), "top": 10, "background-color": "#FFFFFF", "border": "1px solid #999999", "position": "absolute", "width": popupWidth, "height": popupHeight, "z-index": 50, "padding": "25px 25px 20px" });
206+
$("#popup").css({ "left": profile.popup.left, "top": profile.popup.top, "background-color": "#FFFFFF", "border": "1px solid #999999", "position": "absolute", "width": popupWidth, "height": popupHeight, "z-index": 50, "padding": "25px 25px 20px" });
207207

208208
$(function () {
209209
$("#conquers").on('click', function (event) {

source/page/place/extratrooplinks.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (world_config.hasMinFakeLimit) {
2323
}
2424

2525
if (user_data.place.attackLinks.fakePlaceLink && units['total'] >= minFake) {
26-
createRallyPointScript(linksContainer, world_data.units, trans.sp.place.attackLinkNames.fake, 0, function (amount, v, tag) {
26+
createRallyPointScript(linksContainer, world_data.units, user_data.place.attackLinks.fakePlaceLinkName, 0, function (amount, v, tag) {
2727
if ((v == 'ram' || v == 'catapult') && !tag.rammed && amount > 0) {
2828
tag.rammed = true;
2929
return 1;
@@ -75,8 +75,8 @@ $.each(user_data.place.customPlaceLinks, function (i, v) {
7575
}
7676
if (send > 0 && !tag.ignoreNobles) {
7777
$.each(user_data.place.attackLinks.nobleSupport, function (i, val) {
78-
if (unitVal == val.Unit && villageType.isMatch(val.VillageType)) {
79-
send -= Math.ceil(units.snob * (val.Population / world_data.unitsSize['unit_' + unitVal]));
78+
if (unitVal == val.unit && villageType.isMatch(val.villageType)) {
79+
send -= Math.ceil(units.snob * val.amount);
8080
}
8181
});
8282
}
@@ -118,49 +118,51 @@ $.each(user_data.place.customPlaceLinks, function (i, v) {
118118
if (units.spy >= user_data.place.attackLinks.scoutVillage && user_data.place.attackLinks.scoutPlaceLinks != null && user_data.place.attackLinks.scoutPlaceLinks.length > 0) {
119119
$.each(user_data.place.attackLinks.scoutPlaceLinks, function (i, v) {
120120
if (units.spy >= v) {
121-
createRallyPointScript(linksContainer, ["spy"], trans.sp.place.attackLinkNames.scout + v, 0, function (amount, v, tag) {
121+
createRallyPointScript(linksContainer, ["spy"], user_data.place.attackLinks.scoutPlaceLinksName.replace("{amount}", v), 0, function (amount, v, tag) {
122122
return tag;
123123
}, v);
124124
}
125125
});
126126
}
127127

128128
if (units.snob > 0 && user_data.place.attackLinks.noblePlaceLink) {
129-
createRallyPointScript(linksContainer, world_data.units, trans.sp.place.attackLinkNames.nobleMax, 0, function (amount, v, tag) {
130-
if (v == 'snob') {
131-
return 1;
132-
}
133-
if (tag > 0) {
134-
var returned = null;
135-
$.each(user_data.place.attackLinks.nobleSupport, function (i, val) {
136-
if (v == val.Unit && villageType.isMatch(val.VillageType)) {
137-
returned = amount - Math.ceil((tag - 1) * (val.Population / world_data.unitsSize['unit_' + v]));
138-
}
139-
});
140-
if (returned != null) {
141-
return returned;
142-
}
143-
}
144-
return amount;
145-
}, units.snob);
129+
if (user_data.place.attackLinks.noblePlaceLinkFirstName) {
130+
createRallyPointScript(linksContainer, world_data.units, user_data.place.attackLinks.noblePlaceLinkFirstName, 0, function (amount, v, tag) {
131+
if (v == 'snob') {
132+
return 1;
133+
}
134+
if (tag > 0) {
135+
var returned = null;
136+
$.each(user_data.place.attackLinks.nobleSupport, function (i, val) {
137+
if (v == val.unit && villageType.isMatch(val.villageType)) {
138+
returned = amount - Math.ceil((tag - 1) * val.amount);
139+
}
140+
});
141+
if (returned != null) {
142+
return returned;
143+
}
144+
}
145+
return amount;
146+
}, units.snob);
147+
}
146148

147-
if (units.snob > 1 || user_data.place.attackLinks.noblePlaceLinksForceShow) {
148-
createRallyPointScript(linksContainer, world_data.units, trans.sp.place.attackLinkNames.nobleMin, 0, function (amount, v, tag) {
149+
if (user_data.place.attackLinks.noblePlaceLinkSupportName && (units.snob > 1 || user_data.place.attackLinks.noblePlaceLinksForceShow)) {
150+
createRallyPointScript(linksContainer, world_data.units, user_data.place.attackLinks.noblePlaceLinkSupportName, 0, function (amount, v, tag) {
149151
if (v == 'snob') {
150152
return 1;
151153
}
152154
var returned = 0;
153155
$.each(user_data.place.attackLinks.nobleSupport, function (i, val) {
154-
if (v == val.Unit && villageType.isMatch(val.VillageType)) {
155-
returned = Math.ceil(1 * (val.Population / world_data.unitsSize['unit_' + v]));
156+
if (v == val.unit && villageType.isMatch(val.villageType)) {
157+
returned = Math.ceil(1 * val.amount);
156158
}
157159
});
158160
return returned;
159161
});
160162
}
161163

162-
if (units.snob > 0) {
163-
createRallyPointScript(linksContainer, world_data.units, trans.sp.place.attackLinkNames.nobleDivide, 0, function (amount, v, tag) {
164+
if (units.snob > 0 && user_data.place.attackLinks.noblePlaceLinkDivideName) {
165+
createRallyPointScript(linksContainer, world_data.units, user_data.place.attackLinks.noblePlaceLinkDivideName, 0, function (amount, v, tag) {
164166
if (v == 'snob') {
165167
return 1;
166168
}

source/page/settings/sangu/inject.js

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,60 @@
6161

6262
(function() {
6363
var sanguSettingsForm,
64-
configIterator;
64+
configIterator,
65+
settingFormTogglerHtml,
66+
settingsFormsOpenFromPersistence,
67+
adornButton = function(button) { $(button).css("background-color", user_data.colors.error); };
6568

66-
// build the property handler editting form
6769
sanguSettingsForm = $("#sanguSettingsForm");
70+
71+
settingFormTogglerHtml = "<h3>" + trans.sp.sp.settings.configuration + "</h3>";
72+
settingFormTogglerHtml +=
73+
"<table class='vis' width='100%'><tr class='row_a'><th>"
74+
+ trans.sp.sp.settings.configurationFormTogglerTooltip
75+
+ "</th></tr><tr class='row_b'><td>";
76+
for (configIterator = 0; configIterator < user_data_configs.length; configIterator++) {
77+
settingFormTogglerHtml +=
78+
"<input type='button' value=\""
79+
+ user_data_configs[configIterator].title
80+
+ "\" id='"+user_data_configs[configIterator].id
81+
+ "_button' class='editFormToggler' /> &nbsp;";
82+
}
83+
settingFormTogglerHtml += "</td></tr></table><br>";
84+
sanguSettingsForm.append(settingFormTogglerHtml);
85+
$(".editFormToggler", sanguSettingsForm).click(function() {
86+
var openForms = "",
87+
linkedDiv = $("#" + this.id.replace("_button", ""));
88+
89+
if (linkedDiv.is(":visible")) {
90+
linkedDiv.hide();
91+
$(this).css("background-color", "");
92+
} else {
93+
linkedDiv.fadeIn();
94+
adornButton(this);
95+
}
96+
97+
$(".propertyEditFormContainer", sanguSettingsForm).each(function() {
98+
if ($(this).is(":visible")) {
99+
openForms += this.id + "|";
100+
}
101+
});
102+
pers.set("settingsFormsOpen", openForms);
103+
});
104+
105+
// build the property handler editting form
68106
for (configIterator = 0; configIterator < user_data_configs.length; configIterator++) {
69107
buildConfigForm(sanguSettingsForm, user_data_configs[configIterator]);
70-
sanguSettingsForm.append("<br>");
71108
}
109+
110+
settingsFormsOpenFromPersistence = pers.get("settingsFormsOpen");
111+
q(settingsFormsOpenFromPersistence);
112+
$(".propertyEditFormContainer", sanguSettingsForm).each(function() {
113+
if (settingsFormsOpenFromPersistence.indexOf(this.id+"|") > -1) {
114+
adornButton($("#" + this.id + "_button"));
115+
$(this).show();
116+
}
117+
});
72118
})();
73119

74120
// notable contributors

source/page/settings/sangu/propui.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function createSettingType(inputHandler, editors, editorIndex, arrayOptions) {
9292
case "bool":
9393
return {
9494
build: function(id) {
95-
assert(typeof value === 'boolean', (typeof value) + ": not a boolean");
95+
//assert(typeof value === 'boolean', (typeof value) + ": not a boolean");
9696
return "<input type='checkbox' id='"+id+"' "+(value ? " checked" : "")+" />";
9797
},
9898
bind: function(id) {
@@ -361,7 +361,8 @@ function buildConfigForm(contentPage, propertyFormConfig) {
361361
properties = [],
362362
propIndex,
363363
form = "",
364-
formRow;
364+
formRow,
365+
container;
365366

366367
// show only relevant properties
367368
// has side-effects
@@ -389,7 +390,11 @@ function buildConfigForm(contentPage, propertyFormConfig) {
389390
form += "<tr><th colspan='2'>" + propertyFormConfig.title + "</th>";
390391
form += "</table>";
391392
form = $(form);
392-
contentPage.append(form);
393+
394+
container = $("<div class='propertyEditFormContainer' id='"+propertyFormConfig.id+"' style='display: none' />");
395+
container.append(form).append("<br>");
396+
397+
contentPage.append(container);
393398

394399
for (propIndex = 0; propIndex < properties.length; propIndex++) {
395400
var propUI = properties[propIndex];

0 commit comments

Comments
 (0)