mirror of
https://gitlab.com/hoggit/developers/hoggit.git
synced 2025-11-10 15:43:28 +00:00
Added uglify options to dist, added documentation. Added Jenkinsfile options to build a master branch dist
This commit is contained in:
parent
9e4b734eb8
commit
967bf6570e
13
Jenkinsfile
vendored
13
Jenkinsfile
vendored
@ -4,17 +4,24 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
sh '/opt/squish/bin/squish --no-minify'
|
sh 'squish --uglify'
|
||||||
sh "ldoc ${env.WORKSPACE}"
|
sh "ldoc ${env.WORKSPACE}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
when {
|
when {
|
||||||
tag 'release-*'
|
anyOf { tag 'release-*'; branch 'master' }
|
||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh "python3 /opt/hoggit_releaser/releaser.py ${env.WORKSPACE} ${env.TAG_NAME}"
|
script {
|
||||||
|
if (env.TAG_NAME && env.TAG_NAME =~ /release-/) {
|
||||||
|
TAG = env.TAG_NAME
|
||||||
|
} else {
|
||||||
|
TAG = env.BRANCH_NAME
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sh "python3 /opt/hoggit_releaser/releaser.py ${env.WORKSPACE} ${TAG}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,12 @@
|
|||||||
|
--- communication.lua
|
||||||
|
-- Menu system for groups via the F10 comms menu and messaging groups
|
||||||
|
|
||||||
HOGGIT.GroupCommandAdded = {}
|
HOGGIT.GroupCommandAdded = {}
|
||||||
|
|
||||||
|
--- Adds a menu item for the specified Group
|
||||||
|
-- @param group Group to get the command
|
||||||
|
-- @param text Text for the menu option
|
||||||
|
-- @param parent Parent menu item to attach this command to
|
||||||
HOGGIT.GroupCommand = function(group, text, parent, handler)
|
HOGGIT.GroupCommand = function(group, text, parent, handler)
|
||||||
if HOGGIT.GroupCommandAdded[tostring(group)] == nil then
|
if HOGGIT.GroupCommandAdded[tostring(group)] == nil then
|
||||||
log("No commands from group " .. group .. " yet. Initializing menu state")
|
log("No commands from group " .. group .. " yet. Initializing menu state")
|
||||||
@ -24,12 +32,20 @@ HOGGIT.GroupMenu = function( groupId, text, parent )
|
|||||||
return HOGGIT.GroupMenuAdded[tostring(groupId)][text]
|
return HOGGIT.GroupMenuAdded[tostring(groupId)][text]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Send a message to a specific group
|
||||||
|
-- @param groupId ID of the group that should get this message
|
||||||
|
-- @param text The text that is shown in the message
|
||||||
|
-- @param displayTime Amount of time in seconds to show the message
|
||||||
|
-- @param clear if True use the clearview message option which will get rid of the black background in the message area
|
||||||
HOGGIT.MessageToGroup = function(groupId, text, displayTime, clear)
|
HOGGIT.MessageToGroup = function(groupId, text, displayTime, clear)
|
||||||
if not displayTime then displayTime = 10 end
|
if not displayTime then displayTime = 10 end
|
||||||
if clear == nil then clear = false end
|
if clear == nil then clear = false end
|
||||||
trigger.action.outTextForGroup(groupId, text, displayTime, clear)
|
trigger.action.outTextForGroup(groupId, text, displayTime, clear)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Send a message to all players on the server
|
||||||
|
-- @param text The text that is shown in the message
|
||||||
|
-- @param displayTime Amount of time in seconds to show the message
|
||||||
HOGGIT.MessageToAll = function(text, displayTime)
|
HOGGIT.MessageToAll = function(text, displayTime)
|
||||||
if not displayTime then displayTime = 10 end
|
if not displayTime then displayTime = 10 end
|
||||||
trigger.action.outText(text, displayTime)
|
trigger.action.outText(text, displayTime)
|
||||||
|
|||||||
@ -1,9 +1,16 @@
|
|||||||
HandleError = function(err)
|
--- error_handling.lua
|
||||||
|
-- Adds intelligence to the way scripting errors in DCS are handled.
|
||||||
|
-- Must be included after hoggit.logging module
|
||||||
|
|
||||||
|
local HandleError = function(err)
|
||||||
log("Error in pcall: " .. err)
|
log("Error in pcall: " .. err)
|
||||||
log(debug.traceback())
|
log(debug.traceback())
|
||||||
return err
|
return err
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Adds basic try/catch functionality
|
||||||
|
-- @param func unsafe function to call
|
||||||
|
-- @param catch the function to call if func fails
|
||||||
try = function(func, catch)
|
try = function(func, catch)
|
||||||
return function()
|
return function()
|
||||||
local r, e = xpcall(func, HandleError)
|
local r, e = xpcall(func, HandleError)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
-- Returns the location of the first unit in a given group.
|
--- Returns the location of the first unit in a given group.
|
||||||
-- If the group is nil, this function returns nil.
|
-- If the group is nil, this function returns nil.
|
||||||
-- @param grp The group you want coordinates for.
|
-- @param grp The group you want coordinates for.
|
||||||
-- @return Vec3 The group's first unit's coordinates, or nil if the group is nil
|
-- @return Vec3 The group's first unit's coordinates, or nil if the group is nil
|
||||||
@ -9,7 +9,7 @@ HOGGIT.groupCoords = function(grp)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Starts a smoke beacon at the specified group's location
|
--- Starts a smoke beacon at the specified group's location
|
||||||
-- @param grp The group to smoke. Will be placed on or near the first unit.
|
-- @param grp The group to smoke. Will be placed on or near the first unit.
|
||||||
-- @param smokeColor The trigger.smokeColor enum value to use. Defaults to White smoke
|
-- @param smokeColor The trigger.smokeColor enum value to use. Defaults to White smoke
|
||||||
HOGGIT.smokeAtGroup = function(grp, smokeColor)
|
HOGGIT.smokeAtGroup = function(grp, smokeColor)
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
|
--- Logging.lua
|
||||||
|
-- Logging utility for HOGGIT framework
|
||||||
|
|
||||||
|
-- Open a log file for use
|
||||||
logFile = io.open(HOGGIT.log_base..[[\HOGGIT.log]], "w")
|
logFile = io.open(HOGGIT.log_base..[[\HOGGIT.log]], "w")
|
||||||
|
|
||||||
|
--- Write a string to the logfile
|
||||||
|
-- @param str The string to write to the log
|
||||||
function log(str)
|
function log(str)
|
||||||
if str == nil then str = 'nil' end
|
if str == nil then str = 'nil' end
|
||||||
if logFile then
|
if logFile then
|
||||||
|
|||||||
@ -1,8 +1,18 @@
|
|||||||
|
--- utils.lua
|
||||||
|
-- Uncategorized utilities that are used often enough to justify inclusion in the framework
|
||||||
|
|
||||||
|
--- Given a table with indexes as keys (a list in any other language, thanks lua) returns a random element
|
||||||
|
-- @param table A table with indexes as keys
|
||||||
|
-- @return A random element from the table
|
||||||
HOGGIT.randomInList = function(list)
|
HOGGIT.randomInList = function(list)
|
||||||
local idx = math.random(1, #list)
|
local idx = math.random(1, #list)
|
||||||
return list[idx]
|
return list[idx]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Filters out elements that do not return true when passed to the function "filter"
|
||||||
|
-- @param t Table to iterate over
|
||||||
|
-- @param filter Function that each element in table "t" will be passed into.
|
||||||
|
-- @return New table with filtered elements only
|
||||||
HOGGIT.filterTable = function(t, filter)
|
HOGGIT.filterTable = function(t, filter)
|
||||||
local out = {}
|
local out = {}
|
||||||
for k,v in pairs(t) do
|
for k,v in pairs(t) do
|
||||||
@ -11,6 +21,10 @@ HOGGIT.filterTable = function(t, filter)
|
|||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Checks to see if value "elem" is contained in any value of table "list"
|
||||||
|
-- @param list Table to check
|
||||||
|
-- @param elem Value to look for in each table element
|
||||||
|
-- @return True/False if "elem" was found in "list"
|
||||||
HOGGIT.listContains = function(list, elem)
|
HOGGIT.listContains = function(list, elem)
|
||||||
for _, value in ipairs(list) do
|
for _, value in ipairs(list) do
|
||||||
if value == elem then
|
if value == elem then
|
||||||
@ -21,13 +35,17 @@ HOGGIT.listContains = function(list, elem)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Takes a DCS Vec2 position and returns a string with the lat and long
|
||||||
|
-- @param pos Vec2 from DCS engine
|
||||||
|
-- @param decimal if true then return result in Decimal instead of Seconds
|
||||||
|
-- @return The Lat/Long string
|
||||||
HOGGIT.getLatLongString = function(pos, decimal)
|
HOGGIT.getLatLongString = function(pos, decimal)
|
||||||
local lat, long = coord.LOtoLL(pos)
|
local lat, long = coord.LOtoLL(pos)
|
||||||
if decimal == nil then decimal = false end
|
if decimal == nil then decimal = false end
|
||||||
return mist.tostringLL(lat, long, 3, decimal)
|
return mist.tostringLL(lat, long, 3, decimal)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns a textual smoke name based on the provided enum
|
--- Returns a textual smoke name based on the provided enum
|
||||||
-- @param a trigger.smokeColor enum
|
-- @param a trigger.smokeColor enum
|
||||||
-- @return the English word as a string representing the color of the smoke. i.e. trigger.smokeColor.Red returns "Red"
|
-- @return the English word as a string representing the color of the smoke. i.e. trigger.smokeColor.Red returns "Red"
|
||||||
HOGGIT.getSmokeName = function(smokeColor)
|
HOGGIT.getSmokeName = function(smokeColor)
|
||||||
@ -38,6 +56,11 @@ HOGGIT.getSmokeName = function(smokeColor)
|
|||||||
if smokeColor == trigger.smokeColor.Blue then return "Blue" end
|
if smokeColor == trigger.smokeColor.Blue then return "Blue" end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Returns if Group object is alive.
|
||||||
|
-- This will catch some of the edge cases that the more common functions miss.
|
||||||
|
-- @param group Group
|
||||||
|
-- @return True if Group is indeed, alive. False otherwise.
|
||||||
HOGGIT.GroupIsAlive = function(group)
|
HOGGIT.GroupIsAlive = function(group)
|
||||||
local grp = nil
|
local grp = nil
|
||||||
if type(group) == "string" then
|
if type(group) == "string" then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user