mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 12:16:37 +09:00
Added Data tab
This commit is contained in:
@@ -56,6 +56,11 @@ local DataSavingPreference = PlayerData:combine('DataSavingPreference')
|
|||||||
local PreferenceEnum = { 'All', 'Statistics', 'Settings', 'Required' }
|
local PreferenceEnum = { 'All', 'Statistics', 'Settings', 'Required' }
|
||||||
for k,v in ipairs(PreferenceEnum) do PreferenceEnum[v] = k end
|
for k,v in ipairs(PreferenceEnum) do PreferenceEnum[v] = k end
|
||||||
DataSavingPreference:set_default('All')
|
DataSavingPreference:set_default('All')
|
||||||
|
DataSavingPreference:set_metadata{
|
||||||
|
name = {'expcore-data.preference'},
|
||||||
|
tooltip = {'expcore-data.preference-tooltip'},
|
||||||
|
value_tooltip ={'expcore-data.preference-value-tooltip'}
|
||||||
|
}
|
||||||
|
|
||||||
--- Sets your data saving preference
|
--- Sets your data saving preference
|
||||||
-- @command set-data-preference
|
-- @command set-data-preference
|
||||||
|
|||||||
@@ -42,4 +42,7 @@ set-preference=You data saving preference has been set to __1__. Existing data w
|
|||||||
get-preference=You data saving preference is __1__. Use /set-preference to change this. Use /save-data to get a local copy of your data.
|
get-preference=You data saving preference is __1__. Use /set-preference to change this. Use /save-data to get a local copy of your data.
|
||||||
get-data=Your player data has been writen to file, location: factorio/script_output/expgaming_player_data.json
|
get-data=Your player data has been writen to file, location: factorio/script_output/expgaming_player_data.json
|
||||||
data-failed=Your player data has failed to load. Any changes to your data will not be saved.
|
data-failed=Your player data has failed to load. Any changes to your data will not be saved.
|
||||||
data-restore=Your player data has been restored and changes will now save when you leave.
|
data-restore=Your player data has been restored and changes will now save when you leave.
|
||||||
|
preference=Saving Preference
|
||||||
|
preference-tooltip=Which areas will be saved when you leave the game
|
||||||
|
preference-value-tooltip=Use /set-preference to change your preference
|
||||||
@@ -155,4 +155,11 @@ backers-management=Administrators
|
|||||||
backers-board=Board Members and Senior Backers
|
backers-board=Board Members and Senior Backers
|
||||||
backers-staff=Staff Members
|
backers-staff=Staff Members
|
||||||
backers-backers=Sponsors and Supporters
|
backers-backers=Sponsors and Supporters
|
||||||
backers-active=Active Players
|
backers-active=Active Players
|
||||||
|
data-tab=Data
|
||||||
|
data-tooltip=All of your stored player data
|
||||||
|
data-general=Our servers will save your player data externaly so that we can sync it between servers. All of your data can be found below, if you wish to save a copy localy then use /save-data. If you want to change what data is saved then use /set-preference.
|
||||||
|
data-settings=Settings
|
||||||
|
data-statistics=Statistics
|
||||||
|
data-required=Required
|
||||||
|
data-misc=Miscellaneous
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
local Gui = require 'expcore.gui' --- @dep expcore.gui
|
||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||||
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local Event = require 'utils.event' --- @dep utils.event
|
local Event = require 'utils.event' --- @dep utils.event
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
local Game = require 'utils.game' --- @dep utils.game
|
||||||
local format_time = _C.format_time --- @dep expcore.common
|
local format_time = _C.format_time --- @dep expcore.common
|
||||||
@@ -259,6 +260,95 @@ Gui.element(function(_, parent)
|
|||||||
return container
|
return container
|
||||||
end))
|
end))
|
||||||
|
|
||||||
|
--- Content area for the player data tab
|
||||||
|
-- @element commands_content
|
||||||
|
Tab({'readme.data-tab'}, {'readme.data-tooltip'},
|
||||||
|
Gui.element(function(_, parent)
|
||||||
|
local container = parent.add{ type='flow', direction='vertical' }
|
||||||
|
local player = Gui.get_player_from_element(parent)
|
||||||
|
local player_name = player.name
|
||||||
|
|
||||||
|
local enum = PlayerData.PreferenceEnum
|
||||||
|
local preference = PlayerData.DataSavingPreference:get(player_name)
|
||||||
|
local preference_meta = PlayerData.DataSavingPreference.metadata
|
||||||
|
preference = enum[preference]
|
||||||
|
|
||||||
|
-- Add the title and description to the content
|
||||||
|
Gui.title_label(container, title_width, {'readme.data-tab'})
|
||||||
|
Gui.centered_label(container, frame_width, {'readme.data-general'})
|
||||||
|
Gui.bar(container)
|
||||||
|
container.add{ type='flow' }
|
||||||
|
local scroll_pane = title_table_scroll(container)
|
||||||
|
|
||||||
|
-- Add the required area
|
||||||
|
local required = title_table(scroll_pane, 250, {'readme.data-required'}, 2)
|
||||||
|
Gui.centered_label(required, 140, preference_meta.name, preference_meta.tooltip)
|
||||||
|
Gui.centered_label(required, 430, enum[preference], preference_meta.value_tooltip)
|
||||||
|
|
||||||
|
for name, child in pairs(PlayerData.Required.children) do
|
||||||
|
local metadata = child.metadata
|
||||||
|
local value = child:get(player_name)
|
||||||
|
if value ~= nil or metadata.show_always then
|
||||||
|
if metadata.stringify then value = metadata.stringify(value) end
|
||||||
|
Gui.centered_label(required, 140, metadata.name or name, metadata.tooltip)
|
||||||
|
Gui.centered_label(required, 430, tostring(value), metadata.value_tooltip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add the settings area
|
||||||
|
if preference <= enum.Settings then
|
||||||
|
local settings = title_table(scroll_pane, 255, {'readme.data-settings'}, 2)
|
||||||
|
for name, child in pairs(PlayerData.Settings.children) do
|
||||||
|
local metadata = child.metadata
|
||||||
|
local value = child:get(player_name)
|
||||||
|
if value ~= nil or metadata.show_always then
|
||||||
|
if metadata.stringify then value = metadata.stringify(value) end
|
||||||
|
Gui.centered_label(settings, 140, metadata.name or name, metadata.tooltip)
|
||||||
|
Gui.centered_label(settings, 430, tostring(value), metadata.value_tooltip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add the statistics area
|
||||||
|
if preference <= enum.Statistics then
|
||||||
|
local count = 4
|
||||||
|
local statistics = title_table(scroll_pane, 250, {'readme.data-statistics'}, 4)
|
||||||
|
for name, child in pairs(PlayerData.Statistics.children) do
|
||||||
|
local metadata = child.metadata
|
||||||
|
local value = child:get(player_name)
|
||||||
|
if value ~= nil or metadata.show_always then
|
||||||
|
count = count - 2
|
||||||
|
Gui.centered_label(statistics, 140, metadata.name or name, metadata.tooltip)
|
||||||
|
Gui.centered_label(statistics, 140, tostring(value), metadata.value_tooltip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if count > 0 then
|
||||||
|
for i = 1, count do Gui.centered_label(statistics, 140) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add the misc area
|
||||||
|
local skip = {DataSavingPreference=true, Settings=true, Statistics=true, Required=true}
|
||||||
|
local count = 0; for _ in pairs(PlayerData.All.children) do count = count + 1 end
|
||||||
|
if preference <= enum.All and count > 4 then
|
||||||
|
local misc = title_table(scroll_pane, 232, {'readme.data-misc'}, 2)
|
||||||
|
for name, child in pairs(PlayerData.All.children) do
|
||||||
|
if not skip[name] then
|
||||||
|
local metadata = child.metadata
|
||||||
|
local value = child:get(player_name)
|
||||||
|
if value ~= nil or metadata.show_always then
|
||||||
|
if metadata.stringify then value = metadata.stringify(value) end
|
||||||
|
Gui.centered_label(misc, 140, metadata.name or name, metadata.tooltip)
|
||||||
|
Gui.centered_label(misc, 430, tostring(value), metadata.value_tooltip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return container
|
||||||
|
end))
|
||||||
|
|
||||||
|
|
||||||
--- Main readme container for the center flow
|
--- Main readme container for the center flow
|
||||||
-- @element readme
|
-- @element readme
|
||||||
local readme_toggle
|
local readme_toggle
|
||||||
|
|||||||
Reference in New Issue
Block a user