This repository has been archived by the owner on Jul 6, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
baronbar.user.js
152 lines (132 loc) · 7.07 KB
/
baronbar.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// ==UserScript==
// @name LoU Baron Bar
// @namespace php|uber.leet
// @license Creative Commons Attribution-ShareAlike 3.0 Unported License - http://creativecommons.org/licenses/by-sa/3.0/
// @description Add Baron information to the players title bar. Created by resurrecting the discontinued "LoU UI MS Baron" script by OzGoober. Updated by orshee, Alchemist42 and DanT1
// @include http://prodgame*.lordofultima.com/*/index.aspx*
// @version 2.0.8
// ==/UserScript==
(function () {
try {
var mainLoU_Baron = function () {
try {
var oApp, oPlayer, oTech, playerBar;
var BaronLabel, BaronValue, availableBarons, PurifiedResourcesLabel, PurifiedResourcesValue;
function startCheck() {
window.setTimeout(checkIfLoaded, 2000);
}
function checkIfLoaded() {
try {
var isLoaded = false;
oApp = qx.core.Init.getApplication(); // application
oPlayer = webfrontend.data.Player.getInstance(); // player data
if (oApp && oPlayer) {
if (oApp.title) {
playerBar = oApp.title; // top player info bar
oTech = webfrontend.data.Tech.getInstance();
if (oTech && oTech.getBonus("baronCount", webfrontend.data.Tech.research) > 0) {
isLoaded = true;
}
}
}
if (isLoaded) {
//console.log("oApp");
//console.log(oApp);
//console.log("oPlayer");
//console.log(oPlayer);
//console.log("oTech");
//console.log(oTech);
console.log("LoU Baron Bar: Injecting");
tweakGuiLoU();
}
else {
console.log("LoU Baron Bar: Waiting");
startCheck();
}
}
catch (e) {
console.log(e);
}
}
function tweakGuiLoU() {
try {
var Appearance = "label-playername-banner";
var Color = "player-name-banner-dark";
var ToolTip = "Total / Current / Recruiting / Available";
var LeftIdent = 1000;
// Baron Info in Title Bar
BaronLabel = new qx.ui.basic.Label("Barons:");
BaronLabel.setAppearance(Appearance);
BaronLabel.setTextColor(Color);
BaronLabel.setToolTipText(ToolTip);
playerBar.add(BaronLabel, { top: 37, left: LeftIdent+5 });
BaronValue = new qx.ui.basic.Label("0/0/0/0");
BaronValue.setAppearance(Appearance);
BaronValue.setToolTipText(ToolTip);
playerBar.add(BaronValue, { top: 37, left: LeftIdent + 45 });
webfrontend.base.Timer.getInstance().addListener("uiTick", updateCurBarons, this);
PurifiedResourcesLabel = new qx.ui.basic.Label("Purified Resources:");
PurifiedResourcesLabel.setAppearance(Appearance);
PurifiedResourcesLabel.setTextColor(Color);
PurifiedResourcesLabel.setToolTipText("Darkwood / Runestone / Veritum / Trueseed");
playerBar.add(PurifiedResourcesLabel, { top: 37, left: LeftIdent + 100 });
PurifiedResourcesValue = new qx.ui.basic.Label("0/0/0/0");
PurifiedResourcesValue.setAppearance(Appearance);
PurifiedResourcesValue.setToolTipText("Darkwood / Runestone / Veritum / Trueseed");
playerBar.add(PurifiedResourcesValue, { top: 37, left: LeftIdent + 198 });
webfrontend.base.Timer.getInstance().addListener("uiTick", updatPurifiedResources, this);
CastleLabel = new qx.ui.basic.Label("Castles:");
CastleLabel.setAppearance(Appearance);
CastleLabel.setTextColor(Color);
CastleLabel.setToolTipText("Castles");
playerBar.add(CastleLabel, { top: 37, left: LeftIdent + 410 });
CastleValue = new qx.ui.basic.Label("Castles");
CastleValue.setAppearance(Appearance);
CastleValue.setToolTipText("Castles");
playerBar.add(CastleValue, { top: 37, left: LeftIdent + 450 });
webfrontend.base.Timer.getInstance().addListener("uiTick", updatCastleCount, this);
}
catch (e) {
console.log(e);
}
} // tweakGuiLoU
function updateCurBarons() {
var TotalBarons = oPlayer.getBarons();
var IdleBarons = oPlayer.getBaronsIdle();
var QueuedBarons = oPlayer.getBaronsQueue();
var AvailableBarons = oTech.getBonus("baronCount", webfrontend.data.Tech.research) - ((oPlayer.getNumCities() - 1) + IdleBarons + QueuedBarons);
BaronValue.setValue(TotalBarons + "/" + IdleBarons + "/" + QueuedBarons + "/" + AvailableBarons);
//BaronValue.setValue("100/100/20/100");
}
function updatPurifiedResources() {
var pr = oPlayer.getVoidResources();
if (pr) {
PurifiedResourcesValue.setValue(pr[3][1] + "/" + pr[2][1] + "/" + pr[1][1] + "/" + pr[0][1]);
//PurifiedResourcesLabel.setValue("100/100/20/100");
}
}
function updatCastleCount(){
var castles = oPlayer.getNumCastles();
if (castles) {
CastleValue.setValue(castles);
//CastleValue.setValue("42");
}
}
startCheck();
console.log("LoU Baron Bar: Loaded");
}
catch (e) {
console.log(e);
}
} // mainLoU_Baron
var louUIBaronBarScript = document.createElement("script");
var txt = mainLoU_Baron.toString();
if (window.opera != undefined) txt = txt.replace(/</g, "<");
louUIBaronBarScript.innerHTML = "(" + txt + ")();";
louUIBaronBarScript.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(louUIBaronBarScript);
}
catch (e) {
console.log(e);
}
})();