Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
boltgolt committed Apr 22, 2019
2 parents 8d8781d + dd8e552 commit 1cbaaba
Show file tree
Hide file tree
Showing 38 changed files with 1,029 additions and 601 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
config.override.json5
libraryfolders.vdf
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

Advisories are automatically detected events that the observer might want to switch to.
To make switching to this event easier, the observer slot number is displayed next to an icon noting the type of advisory.
The observer should still make his own judgement of the situation.
The observer should still make his own judgment of the situation.

All possible advisories are (with increasing priority):

Expand Down Expand Up @@ -54,10 +54,10 @@ Running without window borders enables it to dedicate as much space as possible
2. Copy the `gamestate_integration_boltobserv.cfg` file from the .zip to your CSGO config folder (the same folder you'd put an `autoexec.cfg`). For most installations this should be found at `C:\Program Files\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\cfg`.
3. You're done! Start the `Boltobserv.exe` file in the unzipped folder. Boltobserv should now automatically connect to CSGO when it's launched.

Please report any bugs or feature requests here on Github.
Please report any bugs or feature requests here on Github.

## License
## License

This project is licensed under GPL-3. In short, this means that all changes you make to this project need to be made open source (among other things). Commercial use is encouraged, as is distribution.
This project is licensed under GPL-3. In short, this means that all changes you make to this project need to be made open source (among other things). Commercial use is encouraged, as is distribution.

The paragraph above is not legally binding. See the LICENSE file for the full license.
16 changes: 11 additions & 5 deletions config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Sends information about the grenades thrown this round to a server
// This information in only used to train a model to predict grenade
// landings, no personal information is send or logged
"nadeCollection": false,
"nadeCollection": true,

// Settings related to the Boltobserv window
"window": {
Expand All @@ -17,6 +17,9 @@
// Make the background of the window transparent
"transparent": false,

// Will disable GPU rendering, helps capture the window in programs like OBS
"disableGpu": false,

// The default shape and position of the window
"defaultSize": {
// The height and width in pixels
Expand Down Expand Up @@ -45,14 +48,17 @@
// Settings related to the CSGO game
"game": {
// Seconds of inactivity before considering a connection to the game client as lost
// Set to -1 to never timout
// Set to -1 to never timeout
"connectionTimout": 30,

// The port GSI will try to connect to
"networkPort": 36363
"networkPort": 36363,

// Tries to detect the CSGO game on the machine and prompts to install the CFG file if it hasn't already
"installCfg": true
},

// Settings for automatically zomming in on alive players on the map
// Settings for automatically zooming in on alive players on the map
"autozoom": {
// Enable or disable autozoom
"enable": false,
Expand All @@ -64,7 +70,7 @@
"padding": 0.3
},

// Settings that should not be used in normal oparation, but help to find issues
// Settings that should not be used in normal operation, but help to find issues
"debug": {
// Draw red squares over bombsite locations
"drawBombsites": false,
Expand Down
71 changes: 71 additions & 0 deletions detectcfg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const fs = require("fs")
const path = require("path")

const steamPaths = [
// Default Windows install path
path.join("C:", "Program Files (x86)", "Steam", "steamapps"),
// For development
path.join(__dirname)
]

module.exports = {
found: [],
search: () => {
let exp = /"\d"\s*"(.*)"/g
let commonPaths = []

for (let steamPath of steamPaths) {
let vdfPath = path.join(steamPath, "libraryfolders.vdf")

commonPaths.push(path.join(steamPath, "common"))

if (fs.existsSync(vdfPath)) {
let vdfContent = fs.readFileSync(vdfPath, "utf8")

let appPath = exp.exec(vdfContent)

while (appPath != null) {
commonPaths.push(path.join(appPath[1], "steamapps", "common"))
appPath = exp.exec(vdfContent)
}
}
}

for (let commonPath of commonPaths) {
let gamePath = path.join(commonPath, "Counter-Strike Global Offensive")

if (fs.existsSync(gamePath)) {
console.info("Found installation in", gamePath)

let configPath = path.join(gamePath, "csgo", "cfg", "gamestate_integration_boltobserv.cfg")

if (fs.existsSync(configPath)) {
let foundHeader = fs.readFileSync(configPath, "utf8").split("\n")[0]
let ownHeader = fs.readFileSync(path.join(__dirname, "gamestate_integration_boltobserv.cfg"), "utf8").split("\n")[0]

if (foundHeader != ownHeader) {
module.exports.found.push({
type: "update",
path: gamePath
})
}
}
else {
module.exports.found.push({
type: "install",
path: gamePath
})
}
}
}
},

install: (path) => {
// Need to reimport path because of electron shenanigans
let template = require("path").join(__dirname, "gamestate_integration_boltobserv.cfg")
let dest = require("path").join(path, "csgo", "cfg", "gamestate_integration_boltobserv.cfg")
fs.copyFileSync(template, dest)

console.info("Installed config file as", dest)
}
}
2 changes: 1 addition & 1 deletion gamestate_integration_boltobserv.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Boltobserv GSI"
"Boltobserv integration v2 | https://github.com/boltgolt/boltobserv"
{
"uri" "http://localhost:36363"
"timeout" "0.1"
Expand Down
4 changes: 3 additions & 1 deletion html/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<div id="siteA"></div>
<div id="siteB"></div>

<div id="bomb"></div>

<div id="player1" class="player">1</div>
<div id="player2" class="player">2</div>
<div id="player3" class="player">3</div>
Expand All @@ -43,7 +45,7 @@
<div id="dragarea"></div>

<script>
require("../maprenderer.js")
require("../renderers/_init.js")
</script>
</body>
</html>
41 changes: 38 additions & 3 deletions html/waiting.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
<title>Boltobserv - Waiting for CSGO</title>
</head>
<body>
<div>

<div id="dragarea"></div>

<div id="game">
<div id="cfgs"></div>

<img src="../img/icon.svg">
<div id="noconnection">
Waiting for CSGO to connect...
Expand All @@ -17,7 +22,6 @@

<span id="version">version 0.0.1</span>

<div id="dragarea"></div>

<script>
require("electron").ipcRenderer.on("connection", (event, data) => {
Expand All @@ -44,10 +48,41 @@
let newVersion = JSON.parse(data).version

if (version != newVersion) {
document.getElementById("version").innerHTML += ` - A newer version is available on github (${newVersion})`
document.getElementById("version").innerHTML += ` - <small onclick="releases()">A newer version is available on github! (${newVersion})</small>`
}
})
})

function releases() {
require("electron").shell.openExternal("https://github.com/boltgolt/boltobserv/releases")
}

let renderIpc = require("electron").ipcRenderer

renderIpc.send("reqInstall")

renderIpc.on("cfgInstall", (event, data) => {
for (var i = 0; i < data.length && i < 5; i++) {
let text = "Outdated config"

if (data[i].type == "install") {
text = "Found game without config"
}

let div = document.createElement("div")
div.innerHTML = `
<span>${text}</span>
<small>in ${data[i].path}</small>
<button onclick="install(this,'${data[i].path.replace(/\\/g, "\\\\")}')">${data[i].type}</button>
`
document.getElementById("cfgs").appendChild(div);
}
})

function install(elem, path) {
renderIpc.send("install", path)
elem.parentNode.parentNode.parentNode.removeChild(elem.parentNode.parentNode)
}
</script>
</body>
</html>
64 changes: 42 additions & 22 deletions http.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ let server = http.createServer(function(req, res) {
}

if (game.player) {
connObject.player = game.player.name
if (game.player.activity != "playing") {
connObject.player = game.player.name
}
}

process.send({
Expand All @@ -51,47 +53,49 @@ let server = http.createServer(function(req, res) {
}
}

// console.log(JSON.stringify(game))
if (game.allplayers) {
let playerArr = []
let context = {
defusing: false
}

if (game.phase_countdowns) {
if (game.phase_countdowns.phase == "defuse") {
context.defusing = true
}
}
for (let id in game.allplayers) {
if (!Number.isInteger(game.allplayers[id].observer_slot)) continue

for (let i in game.allplayers) {
if (!Number.isInteger(game.allplayers[i].observer_slot)) continue

const nadeIDs = ["weapon_smokegrenade", "weapon_flashbang", "weapon_hegrenade", "weapon_incgrenade", "weapon_smokegrenade"]
let player = game.allplayers[i]
let player = game.allplayers[id]
let pos = player.position.split(", ")
let angle = 0
let hasBomb = false
let bombActive = false
let nadeActive = false
let isActive = false
let rawAngle = player.forward.split(", ")

if (parseFloat(rawAngle[0]) > 0) {
angle = 90 + parseFloat(rawAngle[1]) * -1 * 90
}
else {
angle = 270 + parseFloat(rawAngle[1]) * 90
}

if (game.player) {
if (game.player.observer_slot == player.observer_slot) {
isActive = true
}
}

for (let t in player.weapons) {
if (player.weapons[t].name == "weapon_c4") {
hasBomb = true
bombActive = player.weapons[t].state == "active"
}

if (player.weapons[t].state == "active" && nadeIDs.includes(player.weapons[t].name)) {
nadeActive = true
}
}

playerArr.push({
id: id,
num: player.observer_slot,
team: player.team,
alive: player.state.health > 0,
active: isActive,
bomb: hasBomb,
bombActive: bombActive,
nadeActive: nadeActive,
angle: angle,
position: {
x: parseFloat(pos[0]),
y: parseFloat(pos[1]),
Expand All @@ -103,7 +107,6 @@ let server = http.createServer(function(req, res) {
process.send({
type: "players",
data: {
context: context,
players: playerArr
}
})
Expand Down Expand Up @@ -154,6 +157,23 @@ let server = http.createServer(function(req, res) {
oldPhase = game.round.phase
}
}

if (game.bomb) {
let pos = game.bomb.position.split(", ")

process.send({
type: "bomb",
data: {
state: game.bomb.state,
player: game.bomb.player,
position: {
x: parseFloat(pos[0]),
y: parseFloat(pos[1]),
z: parseFloat(pos[2])
}
}
})
}
})
})

Expand Down
Binary file removed img/adv-bombA.png
Binary file not shown.
Binary file removed img/adv-bombB.png
Binary file not shown.
Binary file added img/adv-plant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/bomb-defused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/bomb-dropped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/bomb-planted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1cbaaba

Please sign in to comment.