Skip to content

Commit

Permalink
UI position changed, some other progress
Browse files Browse the repository at this point in the history
  • Loading branch information
cat24max committed Jun 18, 2020
1 parent 9af5606 commit 6988aed
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion WebUI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div id="page">
<div id="orangeRect">
<label>FairRoundStart</label>
<label>FAIR ROUND START</label>
</div>
<ul id="playerList">
</ul>
Expand Down
11 changes: 6 additions & 5 deletions WebUI/script/script.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
function addMedics(medics) {
function updateText(medics) {
// Just in case we make sure the medics param is an array, not an object. This happens when a lua table is empty, as the JSON encoder doesn't
// know if the table is supposed to be an array or an object.
if (typeof medics == 'object') {
medics = Object.values(medics);
}

// Clear previous elements first.
removeAllMedics();
removeText();

// Now we want to create an element for each medic in the array.
for (let j = 0; j < medics.length; j++) {
let medic = medics[j];
let li = '<li class="nameBox" id="item' + j + '"><label>' + medic.name + '</label></li>';
let li = '<li class="nameBox" id="item' + j + '"><label>' + medic + '</label></li>';
// Attach it to the playerList element.
let el = document.getElementById("playerList");
el.innerHTML += li;
}
}

// Clears all player info elements.
function removeAllMedics(){
function removeText(){
let el = document.getElementById("playerList");
el.innerHTML = '';
}
Expand All @@ -40,6 +40,7 @@ window.onresize = function(event) {
};

window.onload = function(event) {
addMedics([{name: 'US: Waiting for 3 more... (13/32)'}, {name: 'RU: Waiting for 5 more... (11/32)'}])
WebUI.Call('Hide')
updateText(['Error communicating with VEXT', 'WebUI not initialized'])
fontsize();
};
9 changes: 4 additions & 5 deletions WebUI/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
}



/* Vanilla UI keeps a fixed aspect ratio of 16/9 that fits the whole screen
Above 720p this aspect ratio is kept at that resolution and doesn't grow any longer.
*/
Expand Down Expand Up @@ -35,8 +34,8 @@

#orangeRect {
background: linear-gradient(rgba(255, 156, 55, 0.96), rgba(181,109,35,0.96));
margin-top: -2%;
margin-left: 39.5%;
margin-top: 48.6%;
margin-left: 7.47%;
width:20.5%;
height: 4.3%;

Expand All @@ -47,7 +46,7 @@
/*background-color: rgba(41,0,63,0.4); */
display: flex;
flex-direction: column;
margin-left: 39.5%;
margin-left: 7.47%;
bottom: 0;
}

Expand All @@ -56,7 +55,7 @@
background-color: rgba(41,56,63,0.8);
margin-top: 0px;
margin-right: 5px;
width:33.9%;
width:22.15%;
height: 4.3%;
}
label{
Expand Down
22 changes: 18 additions & 4 deletions ext/Client/__init__.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@ function FairRoundStart:RegisterVars()
end

function FairRoundStart:RegisterEvents()
Events:Subscribe('Level:Loaded', function(levelName, gameMode)
Events:Subscribe('Extension:Loaded', function(levelName, gameMode)
WebUI:Init()
WebUI:ExecuteJS("updateText(['Error', 'Something is wrong lol'])")
end)
self.movementBlocker = Events:Subscribe('Player:Respawn', self, self.onPlayerRespawn)
Events:Subscribe('Level:Loaded', function(player)
WebUI:ExecuteJS("WebUI.Call('Show')")
end)
NetEvents:Subscribe('FairRoundStart:Start', function()
self.movementBlocker:Unsubscribe()
self:DisableInput(PlayerManager:GetLocalPlayer(), true)
WebUI:ExecuteJS("WebUI.Call('Hide')")
end)
Events:Subscribe('Level:Destroy', function()
WebUI:ExecuteJS("WebUI.Call('Hide')")
end)
NetEvents:Subscribe('FairRoundStart:UpdateUI', function(team1current, team2current, team1min, team2min)
WebUI:ExecuteJS("updateText(['US: Waiting for ".. (team1min - team1current) .." more... (".. team1current .."/".. team1min ..")', 'RU: Waiting for ".. (team2min - team2current) .." more... (".. team2current .."/".. team2min ..")'])")
end)
NetEvents:Subscribe('FairRoundStart:Reset', function(team1current, team2current, team1min, team2min)
self.roundStarted = false
end)
end

Expand All @@ -34,9 +48,9 @@ end


function FairRoundStart:onPlayerRespawn(player)
self:DisableInput(player, false)
WebUI:ExecuteJS("WebUI.Call('Show')")
WebUI:ExecuteJS('app.$data.message = "<strong>FairRoundStart</strong><br>Waiting for 50% of players to spawn...<br>RU: 8/16<br>US: 13/15";')
if not self.roundStarted then
self:DisableInput(player, false)
end
end


Expand Down
34 changes: 20 additions & 14 deletions ext/Server/__init__.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ function FairRoundStart:__init()
self:RegisterVars()
self:RegisterEvents()





Events:Subscribe('Player:Chat', function(player, recipientMask, message)
if message == "GO" then
self:StartRound()
Expand All @@ -23,14 +19,9 @@ function FairRoundStart:RegisterVars()
end

function FairRoundStart:RegisterEvents()
-- Events:Subscribe('Player:Respawn', self, self.onPlayerRespawn)
self.movementBlocker = Events:Subscribe('Player:UpdateInput', function(player, dt)
player.input:SetLevel(EntryInputActionEnum.EIAThrottle, 0)
player.input:SetLevel(EntryInputActionEnum.EIAStrafe, 0)
if not self.roundStarted then
self:DisableInput(player, false)
end
end)
Events:Subscribe('Player:Respawn', self, self.onPlayerRespawn)

Events:Subscribe('Level:Loaded', self, self.onLevelLoaded)
end

function FairRoundStart:DisableInput(player, newbool)
Expand All @@ -42,6 +33,19 @@ function FairRoundStart:DisableInput(player, newbool)
player:EnableInput(31, newbool) -- EIAThrowGrenade
end

function FairRoundStart:onLevelLoaded(levelName, gameMode, round, roundsPerMap)
self.roundStarted = false
self.movementBlocker = Events:Subscribe('Player:UpdateInput', self, self.blockMovement)
NetEvents:Broadcast("FairRoundStart:Reset")
NetEvents:Broadcast("FairRoundStart:UpdateUI", 0, 0, 32, 32)
end

function FairRoundStart:blockMovement(player, dt)
player.input:SetLevel(EntryInputActionEnum.EIAThrottle, 0)
player.input:SetLevel(EntryInputActionEnum.EIAStrafe, 0)
self:DisableInput(player, false)
end

function FairRoundStart:StartRound()
self.roundStarted = true
self.movementBlocker:Unsubscribe()
Expand All @@ -56,8 +60,10 @@ end

function FairRoundStart:onPlayerRespawn(player)
if not self.roundStarted then
ChatManager:SendMessage("Round has not started yet, not enough players have joined")
self:DisableInput(player, false)
--ChatManager:SendMessage("Round has not started yet, not enough players have joined")
--self:DisableInput(player, false)
NetEvents:Broadcast("FairRoundStart:UpdateUI", 5, 6, 32, 32)
print("FairRoundStart:UpdateUI")
end
end

Expand Down

0 comments on commit 6988aed

Please sign in to comment.