mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Added warn to player list
This commit is contained in:
202
old/modules/DONE/Guis/ExpGamingAdmin/Gui/control.lua
Normal file
202
old/modules/DONE/Guis/ExpGamingAdmin/Gui/control.lua
Normal file
@@ -0,0 +1,202 @@
|
||||
--- Adds a gui that can be used to access all the admin commands.
|
||||
-- @module ExpGamingAdmin.Gui@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias AdminGui
|
||||
|
||||
-- Module Require
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local playerInfo -- ExpGamingPlayer.playerInfo@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local AdminGui = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo')
|
||||
else playerInfo = function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'ExpGamingAdmin.no-info-file'}
|
||||
}
|
||||
end end
|
||||
--code
|
||||
end,
|
||||
buttons={}
|
||||
}
|
||||
|
||||
function Admin.open(player,pre_select_player,pre_select_action)
|
||||
Gui.center.clear(player)
|
||||
Admin.center(player,pre_select_player,pre_select_action)
|
||||
end
|
||||
|
||||
-- Function Define
|
||||
function AdminGui.add_button(name,caption,tooltip,callback)
|
||||
AdminGui.buttons[name] = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-gui-'..name,
|
||||
caption=caption,
|
||||
tooltip=tooltip
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local pre_select_player = parent.player and parent.player.caption or nil
|
||||
callback(pre_select_player,event.player_index)
|
||||
end)
|
||||
end
|
||||
|
||||
function AdminGui.draw(frame,filter_buttons)
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
name='admin'
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='',
|
||||
name='player'
|
||||
}.style.visible = false
|
||||
local function format(btn)
|
||||
btn.style.height = 30
|
||||
btn.style.width = 30
|
||||
end
|
||||
for name,button in pairs(AdminGui.buttons) do
|
||||
if not filter_buttons or filter_buttons[name] then format(button(frame)) end
|
||||
end
|
||||
return frame.player
|
||||
end
|
||||
|
||||
-- Gui Define
|
||||
local function get_players(_player,root_frame,state)
|
||||
local players = {'Select Player'}
|
||||
local _players = state and game.players or game.connected_players
|
||||
for _,player in pairs(_players) do
|
||||
if player.name ~= _player.name then
|
||||
if not Admin.is_banned or not Admin.is_banned(player) then
|
||||
table.insert(players,player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
local online_check = Gui.inputs.add_checkbox('online-check-admin-commands',false,'Show Offline',false,function(player,element)
|
||||
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,true)
|
||||
element.parent['player-drop-down-admin-commands'].selected_index = 1
|
||||
end,function(player,element)
|
||||
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,false)
|
||||
element.parent['player-drop-down-admin-commands'].selected_index = 1
|
||||
end)
|
||||
|
||||
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',get_players,1,function(player,selected,items,element)
|
||||
element.parent.parent.player.caption = selected
|
||||
local player_info_flow = element.parent.parent.info_flow
|
||||
player_info_flow.clear()
|
||||
if selected == 'Select Player' then return
|
||||
else playerInfo(selected,player_info_flow,true) end
|
||||
local role = Role.get_highest(player)
|
||||
local _role = Role.get_highest(selected)
|
||||
if role.index >= _role.index then element.parent.warning.caption = {'ExpGamingAdmin.warning'}
|
||||
else element.parent.warning.caption = '' end
|
||||
end)
|
||||
|
||||
local reason_input = Gui.inputs.add_text('reason-input-admin-commands',false,'Enter Reason',function(player,text,element)
|
||||
if string.len(text) < 20 or text == 'Enter Reason' then
|
||||
element.parent.warning.caption = {'ExpGamingAdmin.short-reason'}
|
||||
else
|
||||
element.parent.warning.caption = ''
|
||||
end
|
||||
end)
|
||||
|
||||
local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change',function() return {'Select Action',unpack(Admin.action_names)} end,1,function(player,selected,items,element)
|
||||
element.parent.parent.action.caption = selected
|
||||
if selected == 'Jail' or selected == 'Kick' or selected == 'Ban' or selected == 'Temp Ban' then
|
||||
element.parent['reason-input-admin-commands'].style.visible = true
|
||||
else
|
||||
element.parent['reason-input-admin-commands'].style.visible = false
|
||||
end
|
||||
end)
|
||||
|
||||
local take_action = Gui.inputs{
|
||||
type='button',
|
||||
name='admin-commands-take',
|
||||
caption={'ExpGamingAdmin.take-action'}
|
||||
}:on_event('click',function(event)
|
||||
local dropdowns = event.element.parent
|
||||
local role = Role.get_highest(event.player_index)
|
||||
local _action= dropdowns.parent.action.caption ~= 'Select Action' and dropdowns.parent.action.caption or nil
|
||||
local _player = Game.get_player(dropdowns.parent.player.caption)
|
||||
if not _player or not _action then dropdowns.warning.caption = {'ExpGamingAdmin.invalid'} return end
|
||||
local _role = Role.get_highest(_player)
|
||||
if role.index >= _role.index then dropdowns.warning.caption = {'ExpGamingAdmin.rank-high'} return end
|
||||
local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text
|
||||
if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 10) then return end
|
||||
Admin.take_action(_action,_player,event.player_index,_reason)
|
||||
Gui.center.clear(event)
|
||||
end)
|
||||
|
||||
Admin.center = Gui.center{
|
||||
name='admin-commands',
|
||||
caption='utility/danger_icon',
|
||||
tooltip={'ExpGamingAdmin.tooltip'},
|
||||
draw=function(self,frame,pre_select_player,pre_select_action)
|
||||
frame.caption={'ExpGamingAdmin.name'}
|
||||
frame = frame.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local dropdowns = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
local player_info_flow = frame.add{
|
||||
name='info_flow',
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
player_info_flow.style.height = 280
|
||||
player_info_flow.style.width = 200
|
||||
local label = dropdowns.add{
|
||||
type='label',
|
||||
caption={'ExpGamingAdmin.message'}
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
online_check:draw(dropdowns)
|
||||
local _drop = player_drop_down:draw(dropdowns)
|
||||
if pre_select_player then Gui.set_dropdown_index(_drop,pre_select_player.name) end
|
||||
_drop = action_drop_down:draw(dropdowns)
|
||||
Gui.set_dropdown_index(_drop,pre_select_action)
|
||||
local _text = reason_input:draw(dropdowns)
|
||||
if pre_select_action == 'Jail' or pre_select_action == 'Kick' or pre_select_action == 'Ban' then
|
||||
_text.style.visible = true else _text.style.visible = false
|
||||
end
|
||||
if pre_select_player then playerInfo(pre_select_player,player_info_flow,true) end
|
||||
_text.style.width = 200
|
||||
label = dropdowns.add{
|
||||
name='warning',
|
||||
type='label',
|
||||
caption='',
|
||||
style='bold_red_label'
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
take_action:draw(dropdowns)
|
||||
local caption = pre_select_player and pre_select_player.name or ''
|
||||
frame.add{
|
||||
name='player',
|
||||
type='label',
|
||||
caption=caption
|
||||
}.style.visible = false
|
||||
caption = pre_select_action or ''
|
||||
frame.add{
|
||||
name='action',
|
||||
type='label',
|
||||
caption=caption
|
||||
}.style.visible = false
|
||||
end
|
||||
}
|
||||
|
||||
-- Module Return
|
||||
-- calling will draw the admin buttons to that frame
|
||||
return setmetatable(AdminGui,{__call=function(self,...) return self.draw(...) end})
|
||||
23
old/modules/DONE/Guis/ExpGamingAdmin/Gui/softmod.json
Normal file
23
old/modules/DONE/Guis/ExpGamingAdmin/Gui/softmod.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin.Gui",
|
||||
"version": "4.0.0",
|
||||
"description": "Adds a gui that can be used to access all the admin commands.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Commands",
|
||||
"Gui"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Role": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingPlayer": "?^4.0.0",
|
||||
"ExpGamingPlayer.playerInfo": "?^4.0.0",
|
||||
"mod-gui": "*",
|
||||
"ExpGamingAdmin": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingAdmin@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
103
old/modules/DONE/Guis/ExpGamingAdmin/control.lua
Normal file
103
old/modules/DONE/Guis/ExpGamingAdmin/control.lua
Normal file
@@ -0,0 +1,103 @@
|
||||
--- The base functions required to make the others work.
|
||||
-- @module ExpGamingAdmin@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias Admin
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
local Role -- ExpGamingCore.Role@^4.0.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
local Server -- ExpGamingCore.Server@^4.0.0
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local Admin = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||
if loaded_modules['ExpGamingCore.Server'] then
|
||||
Server = require('ExpGamingCore.Server')
|
||||
Server.add_module_to_interface('Admin','ExpGamingAdmin')
|
||||
end
|
||||
end,
|
||||
actions={},
|
||||
action_functions={},
|
||||
action_names={}
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
banned = {}
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
-- Function Define
|
||||
function Admin.valid_players(player,by_player)
|
||||
player = Game.get_player(player)
|
||||
by_player = Game.get_player(by_player) or SERVER
|
||||
return player, by_player
|
||||
end
|
||||
|
||||
function Admin.create_reason(reason,name)
|
||||
reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then reason = reason..' - '..name end
|
||||
if Sync and Sync.info.date ~= '0000/00/00' and not string.find(string.lower(reason),Sync.info.date) then reason = reason..' - '..Sync.info.date end
|
||||
if not string.find(string.lower(reason),'appeal') then reason = reason..' - Visit www.explosivegaming.nl to appeal.' end
|
||||
return reason
|
||||
end
|
||||
|
||||
function Admin.allowed(player)
|
||||
player = Game.get_player(player)
|
||||
if Role then
|
||||
return Role.allowed(player,'admin-commands')
|
||||
else return player.admin end
|
||||
end
|
||||
|
||||
function Admin.set_banned(player,set)
|
||||
player = Game.get_player(player)
|
||||
if not player then return false end
|
||||
global.banned[player.name] = set
|
||||
end
|
||||
|
||||
function Admin.is_banned(player,detail)
|
||||
player = Game.get_player(player)
|
||||
if not player then return false end
|
||||
local banned = global.banned[player.name]
|
||||
if banned == true then return true end
|
||||
if not banned then return false end
|
||||
if detail then return banned
|
||||
else return true end
|
||||
end
|
||||
|
||||
function Admin.add_action(action,callback)
|
||||
verbose('Added admin action: '..action)
|
||||
Admin.actions[string.lower(action)] = table.insert(Admin.action_names,action)
|
||||
Admin.action_functions[string.lower(action)] = callback
|
||||
end
|
||||
|
||||
function Admin.take_action(action,player,by_player,reason)
|
||||
if Admin.action_functions[string.lower(action)] then Admin.action_functions[string.lower(action)](player,by_player,reason) end
|
||||
if Admin[action] then Admin[action](player,by_player,reason) end
|
||||
end
|
||||
|
||||
function Admin.clear_player(player,by_player)
|
||||
player, by_player = Admin.valid_players(player,by_player)
|
||||
if not player then return end
|
||||
if Server and Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player) end
|
||||
if Admin.clear_warnings then Admin.clear_warnings(player,by_player,true) end
|
||||
if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end
|
||||
if Server and Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end
|
||||
if Sync then Sync.emit_embedded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.textcolor.low),
|
||||
description='A player had their reports and warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player.name,
|
||||
} end
|
||||
Admin.set_banned(player,false)
|
||||
end
|
||||
|
||||
-- Module Return
|
||||
return Admin
|
||||
15
old/modules/DONE/Guis/ExpGamingAdmin/locale/de.cfg
Normal file
15
old/modules/DONE/Guis/ExpGamingAdmin/locale/de.cfg
Normal file
@@ -0,0 +1,15 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Admin-Befehle
|
||||
tooltip=Die mächtigsten Befehle sind hier zuhause.
|
||||
no-info-file=Die Informationsdatei wurde nicht gefunden.
|
||||
message=Wähle einen Spieler und eine Aktion. Stell vor dem Ausführen sicher, dass der Richtige ist!
|
||||
warning=Achtung, dieser Spieler hat einen höheren Rang als du selbst, weshalb du seinen Rang nicht ändern kannst.
|
||||
short-reason=Achtung, dies ist ein sehr kurzer Grund. Bitte versuche, mehr Informationen anzugeben. (Warning: The reason is too short. UPDATE)
|
||||
rank-high=Dieser Spieler hat einen hohen Rang. Bitte benutze nur Ingame-Befehle gegen diese Person, wenn du dir sicher bist!
|
||||
invalid=Der Spieler oder die Aktion war ungültig. Bitte versuche es noch einmal!
|
||||
take-action= Ergreife Maßnahme
|
||||
tooltip-ban=Banne Spieler
|
||||
tooltip-kick=Kicke Spieler
|
||||
tooltip-jail=Sperre Spieler ins Gefängnis
|
||||
tooltip-go-to=Gehe zum Spieler
|
||||
tooltip-bring=Bringe den Spieler zu dir
|
||||
21
old/modules/DONE/Guis/ExpGamingAdmin/locale/en.cfg
Normal file
21
old/modules/DONE/Guis/ExpGamingAdmin/locale/en.cfg
Normal file
@@ -0,0 +1,21 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Admin Commands
|
||||
tooltip=Admin commands make their home here
|
||||
no-info-file=No info file was found
|
||||
message=Please select a player and an action to take. Make sure to choose the correct one!
|
||||
warning=Warning: This player outranks you. Therefore, you cannot edit their rank.
|
||||
short-reason=Warning: The reason is too short.
|
||||
rank-high=Warning: This player outranks you. Therefore, you cannot edit their rank.
|
||||
invalid=The player or the action is invalid. Please try again!
|
||||
take-action=Take Action
|
||||
tooltip-ban=Ban Player
|
||||
tooltip-kick=Kick Player
|
||||
tooltip-jail=Jail Player
|
||||
tooltip-go-to=Go To Player
|
||||
tooltip-bring=Bring Player
|
||||
temp-ban=__1__ was temporary banned by __2__ and will remain in jail until next reset
|
||||
report=Report Player
|
||||
cant-report-ban=Invalid player as player is banned; Either unban or use /clear-all <player_name>
|
||||
low-print=__1__ has been reported by a user for: __2__
|
||||
high-print=__1__ has been reported by __2__ for: __3__
|
||||
cant-report=This player can't be reported.
|
||||
15
old/modules/DONE/Guis/ExpGamingAdmin/locale/fr.cfg
Normal file
15
old/modules/DONE/Guis/ExpGamingAdmin/locale/fr.cfg
Normal file
@@ -0,0 +1,15 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Commandes Admin
|
||||
tooltip=Des commandes très puissantes résident ici.
|
||||
no-info-file=Aucun fichier info trouvé
|
||||
message=Veuillez sélectionner un joueur et une action, faites en sorte que ce soit la bonne !
|
||||
warning=Attention, ce joueur est de rang supérieur au vôtre, vous ne pouvez le modifier.
|
||||
short-reason=Attention, la raison indiquée est trop courte. Soyez concis mais aussi précis. (Warning: The reason is too short. UPDATE)
|
||||
rank-high=Ce joueur est de rang supérieur, veuillez utiliser une commande dont vous maîtriser l'utilisation !
|
||||
invalid=Le Joueur ou l'action est invalide, ré-essayez !
|
||||
take-action=Agir
|
||||
tooltip-ban=Bannir un Joueur
|
||||
tooltip-kick=Exclure un Joueur
|
||||
tooltip-jail=Emprisonner un Joueur
|
||||
tooltip-go-to=Aller à la position d'un Joueur
|
||||
tooltip-bring=Amener le Joueur à soi
|
||||
15
old/modules/DONE/Guis/ExpGamingAdmin/locale/nl.cfg
Normal file
15
old/modules/DONE/Guis/ExpGamingAdmin/locale/nl.cfg
Normal file
@@ -0,0 +1,15 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Admin Commands
|
||||
tooltip=Admin Commands kan je hier vinden.
|
||||
no-info-file=Infobestand niet gevonden.
|
||||
message=Selecteer een speler en de bijbehorende actie. Wees er zeker van dat je de correcte actie kiest.
|
||||
warning=Fout: Je kan de rank van deze speler niet aanpassen omdat het jouw rank overtreft.
|
||||
short-reason=Fout: De reden is te kort. (Warning: The reason is too short. UPDATE)
|
||||
rank-high=Fout: Deze speler overtreft jouw rank.
|
||||
invalid=Fout: De speler kan niet gevonden worden en/of de actie is onjuist. Probeer opnieuw!
|
||||
take-action=Actie ondernemen
|
||||
tooltip-ban=Ban speler
|
||||
tooltip-kick=Kick speler
|
||||
tooltip-jail=Jail speler
|
||||
tooltip-go-to=Ga naar speler
|
||||
tooltip-bring=Breng speler
|
||||
19
old/modules/DONE/Guis/ExpGamingAdmin/locale/sv-SE.cfg
Normal file
19
old/modules/DONE/Guis/ExpGamingAdmin/locale/sv-SE.cfg
Normal file
@@ -0,0 +1,19 @@
|
||||
[ExpGamingAdmin]
|
||||
name=Adminkommandon
|
||||
tooltip=Adminkommando gör dit hem här
|
||||
no-info-file=Ingen informationsfil kunde hittas
|
||||
message=Var snäll och välj en spelare och en åtgärd att utfärda, se till att du väljer den rätta!
|
||||
warning=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang.
|
||||
short-reason=Warning: Skälet är för kort.
|
||||
rank-high=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang.
|
||||
invalid=Spelaren eller åtgärden är ogiltig. Var vänlig och försök igen!
|
||||
take-action=Utför åtgärd.
|
||||
tooltip-ban=Bannlys Spelare
|
||||
tooltip-kick=Sparka Spelare
|
||||
tooltip-jail=Fängsla Spelare
|
||||
tooltip-go-to=Gå till Spelare
|
||||
tooltip-bring=Hämta spelare
|
||||
report=Rapportera Spelare
|
||||
low-print=__1__ har blivit rapporterad av __2__ för: __3__
|
||||
high-print=__1__ har blivit rapporterad av __2__ för: __3__
|
||||
cant-report=Den här spelaren kan inte bli rapporterad.
|
||||
37
old/modules/DONE/Guis/ExpGamingAdmin/softmod.json
Normal file
37
old/modules/DONE/Guis/ExpGamingAdmin/softmod.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "ExpGamingAdmin",
|
||||
"version": "4.0.0",
|
||||
"description": "A set of useful admin commands and functions that can be used by other modules.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Admin",
|
||||
"ExpGaming",
|
||||
"Set",
|
||||
"Commands",
|
||||
"Functions",
|
||||
"Scripts",
|
||||
"Useful"
|
||||
],
|
||||
"author": "Cooldude2606",
|
||||
"contact": "Discord: Cooldude2606#5241",
|
||||
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
|
||||
"submodules": {
|
||||
"ExpGamingAdmin": "4.0.0",
|
||||
"ExpGamingAdmin.Ban": "4.0.0",
|
||||
"ExpGamingAdmin.ClearInventory": "4.0.0",
|
||||
"ExpGamingAdmin.Gui": "4.0.0",
|
||||
"ExpGamingAdmin.Jail": "4.0.0",
|
||||
"ExpGamingAdmin.Kick": "4.0.0",
|
||||
"ExpGamingAdmin.Reports": "4.0.0",
|
||||
"ExpGamingAdmin.Teleport": "4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "4.0.0",
|
||||
"ExpGamingAdmin.Commands": "4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingCore.Sync": "?^4.0.0",
|
||||
"ExpGamingCore.Server": "?^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
}
|
||||
}
|
||||
145
old/modules/DONE/Guis/playerList/control.lua
Normal file
145
old/modules/DONE/Guis/playerList/control.lua
Normal file
@@ -0,0 +1,145 @@
|
||||
--- A full ranking system for factorio.
|
||||
-- @module ExpGamingPlayer.playerList@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Admin -- ExpGamingAdmin@^4.0.0
|
||||
local AdminGui -- ExpGamingAdmin.Gui@^4.0.0
|
||||
|
||||
-- Local Variables
|
||||
local playerInfo = function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'ExpGamingPlayer-playerList.no-info-file'}
|
||||
}
|
||||
end
|
||||
|
||||
local getPlayers = function()
|
||||
local rtn = {{{r=233,g=63,b=233},'Admin',{},true},{{r=255,g=159,b=27},'',{},false}}
|
||||
for _,player in pairs(game.connected_players) do
|
||||
if player.admin then table.insert(rtn[2][3],player)
|
||||
else table.insert(rtn[1][3],player) end
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function(self)
|
||||
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
|
||||
if loaded_modules['ExpGamingCore.Role'] then getPlayers = require(module_path..'/src/ranking',{self=self}) end
|
||||
if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end
|
||||
if loaded_modules['ExpGamingAdmin.Gui'] then AdminGui = require('ExpGamingAdmin.Gui') end
|
||||
end
|
||||
}
|
||||
|
||||
-- Global Define
|
||||
local global = {
|
||||
update=0,
|
||||
delay=10,
|
||||
interval=54000
|
||||
}
|
||||
Global.register(global,function(tbl) global = tbl end)
|
||||
|
||||
function ThisModule.update(tick)
|
||||
local tick = is_type(tick,'table') and tick.tick or is_type(tick,'number') and tick or game.tick
|
||||
if tick + global.delay > global.update - global.interval then
|
||||
global.update = tick + global.delay
|
||||
end
|
||||
end
|
||||
|
||||
local back_btn = Gui.inputs{
|
||||
type='button',
|
||||
caption='utility/enter',
|
||||
name='player-list-back'
|
||||
}:on_event('click',function(event)
|
||||
event.element.parent.parent.scroll.style.visible = true
|
||||
event.element.parent.destroy()
|
||||
end)
|
||||
|
||||
ThisModule.Gui = Gui.left{
|
||||
name='player-list',
|
||||
caption='entity/player',
|
||||
tooltip={'ExpGamingPlayer-playerList.tooltip'},
|
||||
draw=function(self,frame)
|
||||
frame.caption = ''
|
||||
local player_list = frame.add{
|
||||
name='scroll',
|
||||
type = 'scroll-pane',
|
||||
direction = 'vertical',
|
||||
vertical_scroll_policy='auto',
|
||||
horizontal_scroll_policy='never'
|
||||
}
|
||||
player_list.vertical_scroll_policy = 'auto'
|
||||
player_list.style.maximal_height=195
|
||||
local done = {}
|
||||
local players = getPlayers() -- list of [colour,shortHand,[playerOne,playerTwo]]
|
||||
for _,rank in pairs(players) do
|
||||
for _,player in pairs(rank[3]) do
|
||||
if not done[player.index] then
|
||||
done[player.index] = true
|
||||
local flow = player_list.add{type='flow'}
|
||||
if rank[2] == '' then
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'ExpGamingPlayer-playerList.format-nil',tick_to_display_format(player.online_time),player.name}
|
||||
}.style.font_color = rank[1]
|
||||
else
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'ExpGamingPlayer-playerList.format',tick_to_display_format(player.online_time),player.name,rank[2]}
|
||||
}.style.font_color = rank[1]
|
||||
end
|
||||
if Admin and Admin.report_btn then
|
||||
if not rank[4] and player.index ~= frame.player_index then
|
||||
local btn = Admin.report_btn(flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
open_on_join=true
|
||||
}
|
||||
|
||||
Event.add(defines.events.on_tick,function(event)
|
||||
if event.tick > global.update then
|
||||
ThisModule.Gui()
|
||||
global.update = event.tick + global.interval
|
||||
end
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_gui_click,function(event)
|
||||
-- lots of checks for it being valid
|
||||
if event.element and event.element.valid
|
||||
and event.element.parent and event.element.parent.parent and event.element.parent.parent.parent
|
||||
and event.element.parent.parent.parent.name == 'player-list' then else return end
|
||||
-- must be a right click
|
||||
if event.button == defines.mouse_button_type.right then else return end
|
||||
local player_list = event.element.parent.parent.parent
|
||||
-- must be a valid player which is clicked
|
||||
if not Game.get_player(event.element.name) then return end
|
||||
-- hides the player list to show the info
|
||||
player_list.scroll.style.visible = false
|
||||
local flow = player_list.add{type='flow',direction='vertical'}
|
||||
back_btn:draw(flow)
|
||||
playerInfo(event.element.name,flow,true)
|
||||
if Game.get_player(event.element.name) and event.player_index == Game.get_player(event.element.name).index then return end
|
||||
if Admin and AdminGui and Admin.allowed(event.player_index) then AdminGui(flow).caption = event.element.name end
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_player_joined_game,function() ThisModule.update() end)
|
||||
Event.add(defines.events.on_player_left_game,function() ThisModule.update() end)
|
||||
|
||||
ThisModule.force_update = function() return ThisModule.Gui() end
|
||||
-- when called it will queue an update to the player list
|
||||
return setmetatable(ThisModule,{__call=function(self,...) self.update(...) end})
|
||||
5
old/modules/DONE/Guis/playerList/locale/de.cfg
Normal file
5
old/modules/DONE/Guis/playerList/locale/de.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Verkleinere die Spielerliste. Rechtsklicke einen Spieler für Informationen über ihn.
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=Es wurden keine Informationen gefunden.
|
||||
5
old/modules/DONE/Guis/playerList/locale/en.cfg
Normal file
5
old/modules/DONE/Guis/playerList/locale/en.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Toggle player list, right click player for more info
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=No info file was found
|
||||
5
old/modules/DONE/Guis/playerList/locale/fr.cfg
Normal file
5
old/modules/DONE/Guis/playerList/locale/fr.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Toogle player list, right click player for info
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=No info file was found
|
||||
5
old/modules/DONE/Guis/playerList/locale/nl.cfg
Normal file
5
old/modules/DONE/Guis/playerList/locale/nl.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Toggle speler lijst. Rechtermuisklik op een speler voor meer info
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=Geen infobestand gevonden.
|
||||
5
old/modules/DONE/Guis/playerList/locale/sv-SE.cfg
Normal file
5
old/modules/DONE/Guis/playerList/locale/sv-SE.cfg
Normal file
@@ -0,0 +1,5 @@
|
||||
[ExpGamingPlayer-playerList]
|
||||
tooltip=Växla spelarlista, högerklicka på spelare för mer information.
|
||||
format-nil=__1__ - __2__
|
||||
format=__1__ - __2__ - __3__
|
||||
no-info-file=Ingen informationsfil kunde hittas
|
||||
24
old/modules/DONE/Guis/playerList/softmod.json
Normal file
24
old/modules/DONE/Guis/playerList/softmod.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "ExpGamingPlayer.playerList",
|
||||
"version": "4.0.0",
|
||||
"description": "Used to display player names and online time on the top left.",
|
||||
"location": "FSM_ARCHIVE",
|
||||
"keywords": [
|
||||
"Player List",
|
||||
"List",
|
||||
"Gui",
|
||||
"Names"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Role": "?^4.0.0",
|
||||
"ExpGamingAdmin": "?^4.0.0",
|
||||
"ExpGamingAdmin.buttonFlow": "?^4.0.0",
|
||||
"ExpGamingAdmin.reports": "?^4.0.0",
|
||||
"ExpGamingPlayer.playerInfo": "?^4.0.0",
|
||||
"ExpGamingAdmin.Gui": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingPlayer@4.0.0",
|
||||
"submodules": {}
|
||||
}
|
||||
15
old/modules/DONE/Guis/playerList/src/ranking.lua
Normal file
15
old/modules/DONE/Guis/playerList/src/ranking.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local Role = require('ExpGamingCore.Role')
|
||||
|
||||
Event.add(defines.events.on_role_change,self.update)
|
||||
|
||||
return function()
|
||||
local rtn = {}
|
||||
local default = {}
|
||||
for _,role_name in pairs(Role.order) do
|
||||
local role = Role.get(role_name,true)
|
||||
if role.is_default then default = {role.colour,role.short_hand,role:get_players(true),role.not_reportable}
|
||||
else table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable}) end
|
||||
end
|
||||
table.insert(rtn,default)
|
||||
return rtn
|
||||
end
|
||||
Reference in New Issue
Block a user