Skip to content

Commit

Permalink
Helix Beta
Browse files Browse the repository at this point in the history
Major overhaul of user interface. @impulsh
Serverside performance improvements (tested to handle 100+ players).
Improved networking reliability and efficiency.
Various bug fixes and stability improvements.
  • Loading branch information
alexgrist committed Oct 17, 2018
1 parent 1f43c94 commit a0ffb87
Show file tree
Hide file tree
Showing 141 changed files with 16,861 additions and 7,018 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

*.sublime-*
gamemode/config/sv_database.lua
docs/html
.vscode/*
.DS_Store
helix.yml
1 change: 0 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ stds.helix.read_globals = {
"IX_RELOADED",
"CHAT_CLASS",
"HOOKS_CACHE",
"HOLSTER_DRAWINFO",
"BAR_HEIGHT",
"ACCESS_LABELS",

Expand Down
4 changes: 3 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

The MIT License (MIT)

Copyright (c) 2015 Brian Hang, Kyu Yeon Lee
Copyright (c) 2018 Alexander Grist-Hucker, Igor Radovanovic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +20,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@

[![Build Status](https://travis-ci.org/NebulousCloud/helix.svg?branch=master)](https://travis-ci.org/NebulousCloud/helix)

Helix is a *work-in-progress* framework for roleplay gamemodes in [Garry's Mod](https://gmod.facepunch.com/), based off of [NutScript 1.1](https://github.com/rebel1324/NutScript). Helix provides a stable, feature-filled, open-source, and DRM-free base so you can focus more on the things you want: making gameplay.

Since Helix is still in active development, we'd advise you not to use it for any of your projects just yet - many things can and will change until we tweak and polish things off enough for an eventual release.
Helix is a framework for roleplay gamemodes in [Garry's Mod](https://gmod.facepunch.com/), based off of [NutScript 1.1](https://github.com/rebel1324/NutScript). Helix provides a stable, feature-filled, open-source, and DRM-free base so you can focus more on the things you want: making gameplay.

## Getting Started
To start working on your gamemode, you'll need to set up a schema for Helix. This is a specially structured gamemode that uses Helix as its base - but instead of creating all the files and bootstrapping properly yourself, you can fork/copy the skeleton schema that has all of this done already at https://github.com/NebulousCloud/helix-skeleton. The skeleton contains all the important elements you need to have a functioning schema so you can get coding right away.

## Documentation
Up-to-date documentation can be found at https://nebulouscloud.github.io/helix/. This is automatically updated when commits are pushed to the master branch. As it currently stands, you might find it a bit lacking. However, this will definitely improve over time as we continue polishing off the framework.

If you have questions that can't be answered through the documentation, we'd recommend you check out the NutScript community since a lot of the concepts can still be applied to Helix.

### Building documentation
We use [LDoc](https://github.com/stevedonovan/LDoc) to build our documentation. The easiest way to start building is through [LuaRocks](https://luarocks.org/).
```
Expand All @@ -28,8 +24,3 @@ Feel free to submit a pull request with any fixes/changes that you might find be

## Acknowledgements
Helix is a fork of NutScript 1.1 by [Chessnut](https://github.com/brianhang) and [rebel1234](https://github.com/rebel1324).

- NutScript Discord: https://discord.gg/QUbmYuD
- NutScript Forums: https://nutscript.net/
- NutScript Wiki: https://nutscript.miraheze.org/wiki/Main_Page
- NutScript Gitter: https://gitter.im/Chessnut/NutScript
13 changes: 0 additions & 13 deletions content/addon.json

This file was deleted.

Binary file removed content/materials/helix/gui/vignette.png
Binary file not shown.
Binary file removed content/resource/fonts/fontello.ttf
Binary file not shown.
144 changes: 78 additions & 66 deletions entities/entities/ix_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ENT.RenderGroup = RENDERGROUP_BOTH
ENT.bNoPersist = true

if (SERVER) then
util.AddNetworkString("ixItemEntityAction")

function ENT:Initialize()
self:SetModel("models/props_junk/watermelon01.mdl")
self:SetSolid(SOLID_VPHYSICS)
Expand All @@ -29,10 +31,22 @@ if (SERVER) then
end

function ENT:Use(activator, caller)
if (IsValid(caller) and caller:IsPlayer() and caller:GetChar() and self.ixItemID) then
caller:PerformInteraction(ix.config.Get("itemPickupTime", 0.5), self, function(client)
ix.item.PerformInventoryAction(client, "take", self)
end)
local itemTable = self:GetItemTable()

if (IsValid(caller) and caller:IsPlayer() and caller:GetCharacter() and itemTable) then
itemTable.player = caller
itemTable.entity = self

if (itemTable.functions.take.OnCanRun(itemTable)) then
caller:PerformInteraction(ix.config.Get("itemPickupTime", 0.5), self, function(client)
if (!ix.item.PerformInventoryAction(client, "take", self)) then
return false -- do not mark dirty if interaction fails
end
end)
end

itemTable.player = nil
itemTable.entity = nil
end
end

Expand All @@ -50,21 +64,15 @@ if (SERVER) then
local itemTable = ix.item.instances[itemID]

if (itemTable) then
local model = itemTable.OnGetDropModel and itemTable:OnGetDropModel(self) or itemTable.model
local material = itemTable:GetMaterial(self)

self:SetSkin(itemTable.skin or 0)

if (itemTable.worldModel) then
self:SetModel(itemTable.worldModel == true and "models/props_junk/cardboard_box004a.mdl" or itemTable.worldModel)
else
self:SetModel(model)
end
self:SetSkin(itemTable:GetSkin())
self:SetModel(itemTable:GetModel())

if (itemTable.material) then
self:SetMaterial(itemTable.material)
if (material) then
self:SetMaterial(material)
end

self:SetModel(model)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetNetVar("id", itemTable.uniqueID)
Expand Down Expand Up @@ -124,7 +132,7 @@ if (SERVER) then
end

if (itemTable.OnRemoved) then
itemTable:OnRemoved(self)
itemTable:OnRemoved()
end

local query = mysql:Delete("ix_items")
Expand All @@ -143,78 +151,79 @@ if (SERVER) then

return true
end

function ENT:UpdateTransmitState()
return TRANSMIT_PVS
end

net.Receive("ixItemEntityAction", function(length, client)
ix.item.PerformInventoryAction(client, net.ReadString(), net.ReadEntity())
end)
else
ENT.DrawEntityInfo = true
ENT.PopulateEntityInfo = true

local toScreen = FindMetaTable("Vector").ToScreen
local colorAlpha = ColorAlpha
local shadeColor = Color(0, 0, 0, 200)
local blockSize = 4
local blockSpacing = 2

function ENT:DrawItemSize(itemTable, x, y, alpha)
local width = itemTable.width - 1
local height = itemTable.height - 1
local heightDifference = ((height + 1) * blockSize + blockSpacing * height)
function ENT:OnPopulateEntityInfo(container)
local item = self:GetItemTable()

x = x - (width * blockSize + blockSpacing * width) * 0.5
y = y - heightDifference * 0.5
if (!item) then
return
end

for i = 0, height do
for j = 0, width do
local blockX, blockY = x + j * blockSize + j * blockSpacing, y + i * blockSize + i * blockSpacing
local blockAlpha = Lerp(alpha / 255, 0, 255 + (i + j) * 100)
local oldData = item.data

surface.SetDrawColor(ColorAlpha(shadeColor, blockAlpha))
surface.DrawRect(blockX + 1, blockY + 1, blockSize, blockSize)
item.data = self:GetNetVar("data", {})
item.entity = self

surface.SetDrawColor(ColorAlpha(ix.config.Get("color"), blockAlpha))
surface.DrawRect(blockX, blockY, blockSize, blockSize)
end
end
ix.hud.PopulateItemTooltip(container, item)

return heightDifference + 4
end
local name = container:GetRow("name")
local color = name and name:GetBackgroundColor() or ix.config.Get("color")

function ENT:OnDrawEntityInfo(alpha)
local itemTable = self:GetItemTable()
-- set the arrow to be the same colour as the title/name row
container:SetArrowColor(color)

if (itemTable) then
local oldData = itemTable.data
if ((item.width > 1 or item.height > 1) and
hook.Run("ShouldDrawItemSize", item) != false) then

itemTable.data = self.GetNetVar(self, "data", {})
itemTable.entity = self
local size = container:Add("Panel")
size:Dock(BOTTOM)

local position = toScreen(self.LocalToWorld(self, self.OBBCenter(self)))
local x, y = position.x, position.y
local description = itemTable.GetDescription(itemTable)
size.Paint = function(sizePanel, width, height)
surface.SetDrawColor(ColorAlpha(shadeColor, 60))
surface.DrawRect(0, 0, width, height)

if (description != self.description) then
self.description = description
self.markup = ix.markup.Parse("<font=ixItemDescFont>" .. description .. "</font>", ScrW() * 0.7)
end
local x, y = width * 0.5 - 1, height * 0.5 - 1
local itemWidth = item.width - 1
local itemHeight = item.height - 1
local heightDifference = ((itemHeight + 1) * blockSize + blockSpacing * itemHeight)

if ((itemTable.width > 1 or itemTable.height > 1) and
hook.Run("ShouldDrawItemSize", itemTable) != false) then
y = y + self:DrawItemSize(itemTable, x, y, alpha)
end
x = x - (itemWidth * blockSize + blockSpacing * itemWidth) * 0.5
y = y - heightDifference * 0.5

ix.util.DrawText(
itemTable.GetName and itemTable:GetName() or L(itemTable.name),
x, y, colorAlpha(ix.config.Get("color"), alpha), 1, 1, nil, alpha * 0.65
)
for i = 0, itemHeight do
for j = 0, itemWidth do
local blockX, blockY = x + j * blockSize + j * blockSpacing, y + i * blockSize + i * blockSpacing

y = y + 12
surface.SetDrawColor(shadeColor)
surface.DrawRect(blockX + 1, blockY + 1, blockSize, blockSize)

if (self.markup) then
self.markup:draw(x, y, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, alpha)
surface.SetDrawColor(color)
surface.DrawRect(blockX, blockY, blockSize, blockSize)
end
end
end

hook.Run("DrawItemDescription", self, x, y, colorAlpha(color_white, alpha), alpha * 0.65)

itemTable.entity = nil
itemTable.data = oldData
container:SizeToContents()
size:SetWide(container:GetWide())
size:SetTall(item.height * blockSize + item.height * blockSpacing + 8)
end

item.entity = nil
item.data = oldData
end

function ENT:DrawTranslucent()
Expand Down Expand Up @@ -263,7 +272,10 @@ function ENT:GetEntityMenu(client)
end

if (send != false) then
netstream.Start("invAct", k, self)
net.Start("ixItemEntityAction")
net.WriteString(k)
net.WriteEntity(self)
net.SendToServer()
end

-- don't run callbacks since we're handling it manually
Expand Down
34 changes: 15 additions & 19 deletions entities/entities/ix_money.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ if (SERVER) then
end

function ENT:Use(activator)
if (self.client and self.charID) then
local char = activator:GetChar()
if (self.ixSteamID and self.ixCharID) then
local char = activator:GetCharacter()

if (char) then
if (self.charID != char:GetID() and self.client == activator) then
activator:NotifyLocalized("logged")

return false
end
if (char and self.ixCharID != char:GetID() and self.ixSteamID == activator:SteamID()) then
activator:NotifyLocalized("itemOwned")
return false
end
end

Expand All @@ -46,19 +43,18 @@ if (SERVER) then
end
end)
end
else
ENT.DrawEntityInfo = true

local toScreen = FindMetaTable("Vector").ToScreen
local colorAlpha = ColorAlpha
local drawText = ix.util.DrawText
local configGet = ix.config.Get

function ENT:OnDrawEntityInfo(alpha)
local position = toScreen(self.LocalToWorld(self, self.OBBCenter(self)))
local x, y = position.x, position.y
function ENT:UpdateTransmitState()
return TRANSMIT_PVS
end
else
ENT.PopulateEntityInfo = true

drawText(ix.currency.Get(self.GetAmount(self)), x, y, colorAlpha(configGet("color"), alpha), 1, 1, nil, alpha * 0.65)
function ENT:OnPopulateEntityInfo(container)
local text = container:AddRow("name")
text:SetImportant()
text:SetText(ix.currency.Get(self:GetAmount()))
text:SizeToContents()
end
end

Expand Down
Loading

0 comments on commit a0ffb87

Please sign in to comment.