Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions server/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ type Setting struct {
}

type Customize struct {
WebsiteURL string `json:"websiteURL" yaml:"websiteURL"`
WebsiteLogo string `json:"websiteLogo" yaml:"websiteLogo"`
WebsiteLogoSize string `json:"websiteLogoSize" yaml:"websiteLogoSize"`
WebsiteURL string `json:"websiteURL" yaml:"websiteURL"`
WebsiteLogo string `json:"websiteLogo" yaml:"websiteLogo"`
WebsiteLogoSize string `json:"websiteLogoSize" yaml:"websiteLogoSize"`
DisableKillCount bool `json:"disableKillCount" yaml:"disableKillCount"`
}

func NewSetting() (setting Setting, err error) {
Expand Down Expand Up @@ -51,7 +52,7 @@ func NewSetting() (setting Setting, err error) {
viper.SetDefault("customize.websiteLogoSize", "32px")

// workaround for https://github.com/spf13/viper/issues/761
envKeys := []string{"listen", "secret", "db", "markers", "ammo", "maps", "data", "static", "customize.websiteurl", "customize.websitelogo", "customize.websitelogosize"}
envKeys := []string{"listen", "secret", "db", "markers", "ammo", "maps", "data", "static", "customize.websiteurl", "customize.websitelogo", "customize.websitelogosize", "customize.disableKillCount"}
for _, key := range envKeys {
env := strings.ToUpper(strings.ReplaceAll(key, ".", "_"))
if err = viper.BindEnv(key, env); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"logger": true,
"customize": {
"websiteURL": "",
"websiteLogo": ""
"websiteLogo": "",
"disableKillCount": false
}
}
4 changes: 2 additions & 2 deletions static/scripts/ocap.event.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class HitKilledEvent extends GameEvent {

// CausedBy
const causedBySpan = document.createElement("span");
if ((causedBy instanceof Unit) && (causedBy.getId() != null)) {
causedBySpan.className = this.causedBy.getSideClass()
if ((causedBy instanceof Unit) && (causedBy.getId() != null) && !ui.disableKillCount) {
causedBySpan.className = this.causedBy.getSideClass();
switch (this.type) {
case "killed":
causedBySpan.textContent = `${this.causedBy.getName()} (${causedBy.killCount - (causedBy.teamKillCount*2)} kills)`;
Expand Down
3 changes: 1 addition & 2 deletions static/scripts/ocap.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ function initOCAP () {
mapDiv = document.getElementById("map");
defineIcons();
ui = new UI();
ui.updateCustomize();

const args = getArguments();

ui.setModalOpList()
Promise.all([ui.updateCustomize(), ui.setModalOpList()])
.then(() => {
/*
window.addEventListener("keypress", function (event) {
Expand Down
20 changes: 16 additions & 4 deletions static/scripts/ocap.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class UI {
this.missionTimeMultiplier = null;
this.elapsedTime = null;

this.disableKillCount = false;

this._init();
};

Expand Down Expand Up @@ -602,20 +604,28 @@ class UI {
<table class="stats">
<tr>
<th class="name">Name</th>
`;
if (!ui.disableKillCount) {
content += `
<th class="kills">Kills</th>
<th class="tkills">TKills</th>
<th class="deaths">Deaths</th>
</tr>
`;
`;
}
content += `</tr>`;
for (const unit of units) {
content += `
<tr>
<td class="name">${unit.name.encodeHTMLEntities()}</td>
`;
if (!ui.disableKillCount) {
content += `
<td class="kills">${unit.killCount}</td>
<td class="tkills">${unit.teamKillCount}</td>
<td class="deaths">${unit.deathCount}</td>
</tr>
`;
}
content += `</tr>`;
}
content += `</table>`;

Expand Down Expand Up @@ -802,7 +812,7 @@ class UI {
}

updateCustomize() {
fetch("/api/v1/customize")
return fetch("/api/v1/customize")
.then(response => response.json())
.then((data) => {
const container = document.getElementById("container");
Expand All @@ -825,6 +835,8 @@ class UI {
container.prepend(logo);
}
}

this.disableKillCount = data.disableKillCount;
});
}

Expand Down
28 changes: 16 additions & 12 deletions static/scripts/ocap.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,24 @@ class Unit extends Entity {
}
if (this._name !== name) {
this._name = name;
if (this._role) {
this._element.textContent = `(${this._role}) ` + name + " (" + this.killCount.toString() + ")";
this._marker.getPopup()._contentNode.textContent = name;
} else {
this._element.textContent = name + " (" + this.killCount.toString() + ")";
this._marker.getPopup()._contentNode.textContent = name;
}
this._marker.getPopup()._contentNode.textContent = name;
this.updateElementText();
}
}

updateElementText() {
let text = "";
if (this._role) {
text = `(${this._role}) ${this._name}`;
} else {
text = this._name;
}
if (!ui.disableKillCount) {
text += ` (${this.killCount})`;
}
this._element.textContent = text;
}

createMarker(latLng) {
super.createMarker(latLng);

Expand Down Expand Up @@ -127,11 +135,6 @@ class Unit extends Entity {
makeElement(liTarget) { // Make and add element to UI target list
let liUnit = document.createElement("li");
liUnit.className = "liUnit";
if (this._role) {
liUnit.textContent = `(${this._role}) ` + this._name + " (" + this.killCount.toString() + ")";
} else {
liUnit.textContent = this._name + " (" + this.killCount.toString() + ")";
}
liUnit.addEventListener("click", () => {
let marker = this.getMarker();
if (marker != null) {
Expand All @@ -140,6 +143,7 @@ class Unit extends Entity {
}
});
this.setElement(liUnit);
this.updateElementText();
liTarget.appendChild(liUnit);
}

Expand Down