mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Add Colours to Research Tracker (#315)
* Update commands.cfg * Update research.lua * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update research.lua * Update research.lua * Update commands.cfg * Update commands.cfg * Update research.lua * Update research.lua * Update research.lua * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update research.lua * Update research.lua
This commit is contained in:
@@ -133,9 +133,14 @@ ff=__1__ set friendly fire to __2__
|
|||||||
|
|
||||||
[expcom-res]
|
[expcom-res]
|
||||||
res=__1__ set auto research to __2__
|
res=__1__ set auto research to __2__
|
||||||
msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color]
|
msg=[color=255, 255, 255] Research completed at __1__ - [technology=__2__][/color]
|
||||||
inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color]
|
inf=[color=255, 255, 255] Research completed at __1__ - [technology=__2__] - __3__[/color]
|
||||||
inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color]
|
inf-q=[color=255, 255, 255] Research added to queue - [technology=__1__] - __2__[/color]
|
||||||
|
res-name=[technology=__1__] __2__
|
||||||
|
name=Name
|
||||||
|
target=Target
|
||||||
|
attempt=Attempt
|
||||||
|
difference=Diff
|
||||||
main-tooltip=Research GUI
|
main-tooltip=Research GUI
|
||||||
|
|
||||||
[expcom-waterfill]
|
[expcom-waterfill]
|
||||||
|
|||||||
@@ -132,7 +132,12 @@ res=__1__ 把自動研究設置為 __2__ 。
|
|||||||
msg=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__][/color]
|
msg=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__][/color]
|
||||||
inf=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__] - __3__[/color]
|
inf=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__] - __3__[/color]
|
||||||
inf-q=[color=255, 255, 255] 研究已加入隊列 - [technology=__1__] - __2__[/color]
|
inf-q=[color=255, 255, 255] 研究已加入隊列 - [technology=__1__] - __2__[/color]
|
||||||
main-tooltip=研究 GUI
|
res-name=[technology=__1__] __2__
|
||||||
|
name=名稱
|
||||||
|
target=目標
|
||||||
|
attempt=用時
|
||||||
|
difference=差距
|
||||||
|
main-tooltip=研究介面
|
||||||
|
|
||||||
[expcom-waterfill]
|
[expcom-waterfill]
|
||||||
waterfill-distance=位置太近。
|
waterfill-distance=位置太近。
|
||||||
|
|||||||
@@ -132,7 +132,12 @@ res=__1__ 把自動研究設置為 __2__ 。
|
|||||||
msg=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__][/color]
|
msg=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__][/color]
|
||||||
inf=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__] - __3__[/color]
|
inf=[color=255, 255, 255] 研究完成在 __1__ - [technology=__2__] - __3__[/color]
|
||||||
inf-q=[color=255, 255, 255] 研究已加入隊列 - [technology=__1__] - __2__[/color]
|
inf-q=[color=255, 255, 255] 研究已加入隊列 - [technology=__1__] - __2__[/color]
|
||||||
main-tooltip=研究 GUI
|
res-name=[technology=__1__] __2__
|
||||||
|
name=名稱
|
||||||
|
target=目標
|
||||||
|
attempt=用時
|
||||||
|
difference=差距
|
||||||
|
main-tooltip=研究介面
|
||||||
|
|
||||||
[expcom-waterfill]
|
[expcom-waterfill]
|
||||||
waterfill-distance=位置太近。
|
waterfill-distance=位置太近。
|
||||||
|
|||||||
@@ -33,30 +33,38 @@ local empty_time = format_time(0, {
|
|||||||
null=true
|
null=true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local font_color = {
|
||||||
|
-- positive
|
||||||
|
[1] = {r = 0.3, g = 1, b = 0.3},
|
||||||
|
-- negative
|
||||||
|
[2] = {r = 1, g = 0.3, b = 0.3}
|
||||||
|
}
|
||||||
|
|
||||||
local res = {
|
local res = {
|
||||||
['lookup_name'] = {},
|
['lookup_name'] = {},
|
||||||
['disp'] = {}
|
['disp'] = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do
|
||||||
local res_total = 0
|
local res_total = 0
|
||||||
local mi = 1
|
local i = 1
|
||||||
|
|
||||||
for k, v in pairs(config.milestone) do
|
for k, v in pairs(config.milestone) do
|
||||||
research.time[mi] = 0
|
research.time[i] = 0
|
||||||
res['lookup_name'][k] = mi
|
res['lookup_name'][k] = i
|
||||||
res_total = res_total + v * 60
|
res_total = res_total + v * 60
|
||||||
|
|
||||||
res['disp'][mi] = {
|
res['disp'][i] = {
|
||||||
name = '[technology=' .. k .. '] ' .. k:gsub('-', ' '),
|
|
||||||
raw_name = k,
|
raw_name = k,
|
||||||
prev = res_total,
|
target = res_total,
|
||||||
prev_disp = format_time(res_total, research_time_format),
|
target_disp = format_time(res_total, research_time_format),
|
||||||
}
|
}
|
||||||
|
|
||||||
mi = mi + 1
|
i = i + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_log()
|
local function research_add_log()
|
||||||
local result_data = {}
|
local result_data = {}
|
||||||
|
|
||||||
for i=1, #research.time, 1 do
|
for i=1, #research.time, 1 do
|
||||||
@@ -76,7 +84,7 @@ local function research_res_n(res_)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if research.time[#res_] > 0 then
|
if research.time[#res_] and research.time[#res_] > 0 then
|
||||||
if res_n == 1 then
|
if res_n == 1 then
|
||||||
res_n = #res_
|
res_n = #res_
|
||||||
end
|
end
|
||||||
@@ -93,21 +101,13 @@ local function research_res_n(res_)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function research_notification(event)
|
local function research_notification(event)
|
||||||
local is_inf_res = false
|
|
||||||
|
|
||||||
if config.inf_res[event.research.name] then
|
if config.inf_res[event.research.name] then
|
||||||
if event.research.name == 'mining-productivity-4' and event.research.level == 5 then
|
|
||||||
-- Add run result to log
|
|
||||||
add_log()
|
|
||||||
end
|
|
||||||
|
|
||||||
if event.research.level >= config.inf_res[event.research.name] then
|
|
||||||
is_inf_res = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_inf_res then
|
|
||||||
if event.research.name == 'mining-productivity-4' then
|
if event.research.name == 'mining-productivity-4' then
|
||||||
|
if event.research.level == 5 then
|
||||||
|
-- Add run result to log
|
||||||
|
research_add_log()
|
||||||
|
end
|
||||||
|
|
||||||
if config.bonus_inventory.enabled then
|
if config.bonus_inventory.enabled then
|
||||||
if (event.research.level - 1) <= math.ceil(config.bonus_inventory.limit / config.bonus_inventory.rate) then
|
if (event.research.level - 1) <= math.ceil(config.bonus_inventory.limit / config.bonus_inventory.rate) then
|
||||||
event.research.force[config.bonus_inventory.name] = math.max((event.research.level - 1) * config.bonus_inventory.rate, config.bonus_inventory.limit)
|
event.research.force[config.bonus_inventory.name] = math.max((event.research.level - 1) * config.bonus_inventory.rate, config.bonus_inventory.limit)
|
||||||
@@ -117,25 +117,69 @@ local function research_notification(event)
|
|||||||
if config.pollution_ageing_by_research then
|
if config.pollution_ageing_by_research then
|
||||||
game.map_settings.pollution.ageing = math.min(10, event.research.level / 5)
|
game.map_settings.pollution.ageing = math.min(10, event.research.level / 5)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
else
|
||||||
if not (event.by_script) then
|
if not (event.by_script) then
|
||||||
game.print{'expcom-res.inf', format_time(game.tick, research_time_format), event.research.name, event.research.level - 1}
|
game.print{'expcom-res.inf', format_time(game.tick, research_time_format), event.research.name, event.research.level - 1}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
if not (event.by_script) then
|
if not (event.by_script) then
|
||||||
game.print{'expcom-res.msg', format_time(game.tick, research_time_format), event.research.name}
|
game.print{'expcom-res.msg', format_time(game.tick, research_time_format), event.research.name}
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.research.name == 'mining-productivity-1' or event.research.name == 'mining-productivity-2' or event.research.name == 'mining-productivity-3' then
|
|
||||||
if config.bonus_inventory.enabled then
|
if config.bonus_inventory.enabled then
|
||||||
|
if event.research.name == 'mining-productivity-1' or event.research.name == 'mining-productivity-2' or event.research.name == 'mining-productivity-3' then
|
||||||
event.research.force[config.bonus_inventory.name] = event.research.level * config.bonus_inventory.rate
|
event.research.force[config.bonus_inventory.name] = event.research.level * config.bonus_inventory.rate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function research_gui_update()
|
||||||
|
local res_disp = {}
|
||||||
|
local res_n = research_res_n(res['disp'])
|
||||||
|
|
||||||
|
for i=1, 8, 1 do
|
||||||
|
res_disp[i] = {
|
||||||
|
['name'] = '',
|
||||||
|
['target'] = '',
|
||||||
|
['attempt'] = '',
|
||||||
|
['difference'] = '',
|
||||||
|
['difference_color'] = font_color[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
local res_i = res_n + i - 3
|
||||||
|
|
||||||
|
if res['disp'][res_i] then
|
||||||
|
res_disp[i]['name'] = {'expcom-res.res-name', res['disp'][res_i]['raw_name'], game.technology_prototypes[res['disp'][res_i]['raw_name']].localised_name}
|
||||||
|
|
||||||
|
if research.time[res_i] == 0 then
|
||||||
|
res_disp[i]['target'] = res['disp'][res_i].target_disp
|
||||||
|
res_disp[i]['attempt'] = empty_time
|
||||||
|
res_disp[i]['difference'] = empty_time
|
||||||
|
res_disp[i]['difference_color'] = font_color[1]
|
||||||
|
|
||||||
|
else
|
||||||
|
res_disp[i]['target'] = res['disp'][res_i].target_disp
|
||||||
|
res_disp[i]['attempt'] = format_time(research.time[res_i], research_time_format)
|
||||||
|
|
||||||
|
if research.time[res_i] < res['disp'][res_i].target then
|
||||||
|
res_disp[i]['difference'] = '-' .. format_time(res['disp'][res_i].target - research.time[res_i], research_time_format)
|
||||||
|
res_disp[i]['difference_color'] = font_color[1]
|
||||||
|
|
||||||
|
else
|
||||||
|
res_disp[i]['difference'] = format_time(research.time[res_i] - res['disp'][res_i].target, research_time_format)
|
||||||
|
res_disp[i]['difference_color'] = font_color[2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return res_disp
|
||||||
|
end
|
||||||
|
|
||||||
--- Display label for the clock display
|
--- Display label for the clock display
|
||||||
-- @element research_gui_clock_display
|
-- @element research_gui_clock_display
|
||||||
local research_gui_clock =
|
local research_gui_clock =
|
||||||
@@ -143,7 +187,7 @@ Gui.element{
|
|||||||
type = 'label',
|
type = 'label',
|
||||||
name = Gui.unique_static_name,
|
name = Gui.unique_static_name,
|
||||||
caption = empty_time,
|
caption = empty_time,
|
||||||
style = 'heading_1_label'
|
style = 'heading_2_label'
|
||||||
}
|
}
|
||||||
|
|
||||||
--- A vertical flow containing the clock
|
--- A vertical flow containing the clock
|
||||||
@@ -151,82 +195,79 @@ Gui.element{
|
|||||||
local research_clock_set =
|
local research_clock_set =
|
||||||
Gui.element(function(_, parent, name)
|
Gui.element(function(_, parent, name)
|
||||||
local research_set = parent.add{type='flow', direction='vertical', name=name}
|
local research_set = parent.add{type='flow', direction='vertical', name=name}
|
||||||
local disp = Gui.scroll_table(research_set, 360, 1, 'disp')
|
local disp = Gui.scroll_table(research_set, 390, 1, 'disp')
|
||||||
|
|
||||||
research_gui_clock(disp)
|
research_gui_clock(disp)
|
||||||
|
|
||||||
return research_set
|
return research_set
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--- Display group
|
||||||
|
-- @element research_data_group
|
||||||
|
local research_data_group =
|
||||||
|
Gui.element(function(_definition, parent, i)
|
||||||
|
local name = parent.add{
|
||||||
|
type = 'label',
|
||||||
|
name = 'research_' .. i .. '_name',
|
||||||
|
caption = '',
|
||||||
|
style = 'heading_2_label'
|
||||||
|
}
|
||||||
|
name.style.width = 180
|
||||||
|
name.style.horizontal_align = 'left'
|
||||||
|
|
||||||
|
local target = parent.add{
|
||||||
|
type = 'label',
|
||||||
|
name = 'research_' .. i .. '_target',
|
||||||
|
caption = '',
|
||||||
|
style = 'heading_2_label'
|
||||||
|
}
|
||||||
|
target.style.width = 70
|
||||||
|
target.style.horizontal_align = 'right'
|
||||||
|
|
||||||
|
local attempt = parent.add{
|
||||||
|
type = 'label',
|
||||||
|
name = 'research_' .. i .. '_attempt',
|
||||||
|
caption = '',
|
||||||
|
style = 'heading_2_label'
|
||||||
|
}
|
||||||
|
attempt.style.width = 70
|
||||||
|
attempt.style.horizontal_align = 'right'
|
||||||
|
|
||||||
|
local difference = parent.add{
|
||||||
|
type = 'label',
|
||||||
|
name = 'research_' .. i .. '_difference',
|
||||||
|
caption = '',
|
||||||
|
style = 'heading_2_label'
|
||||||
|
}
|
||||||
|
difference.style.width = 70
|
||||||
|
difference.style.horizontal_align = 'right'
|
||||||
|
difference.style.font_color = font_color[1]
|
||||||
|
end)
|
||||||
|
|
||||||
--- A vertical flow containing the data
|
--- A vertical flow containing the data
|
||||||
-- @element research_data_set
|
-- @element research_data_set
|
||||||
local research_data_set =
|
local research_data_set =
|
||||||
Gui.element(function(_, parent, name)
|
Gui.element(function(_, parent, name)
|
||||||
local research_set = parent.add{type='flow', direction='vertical', name=name}
|
local research_set = parent.add{type='flow', direction='vertical', name=name}
|
||||||
local disp = Gui.scroll_table(research_set, 360, 4, 'disp')
|
local disp = Gui.scroll_table(research_set, 390, 4, 'disp')
|
||||||
|
local res_disp = research_gui_update()
|
||||||
|
|
||||||
|
research_data_group(disp, 0)
|
||||||
|
disp['research_0_name'].caption = {'expcom-res.name'}
|
||||||
|
disp['research_0_target'].caption = {'expcom-res.target'}
|
||||||
|
disp['research_0_attempt'].caption = {'expcom-res.attempt'}
|
||||||
|
disp['research_0_difference'].caption = {'expcom-res.difference'}
|
||||||
|
|
||||||
for i=1, 8, 1 do
|
for i=1, 8, 1 do
|
||||||
disp.add{
|
research_data_group(disp, i)
|
||||||
type = 'label',
|
|
||||||
name = 'research_display_n_' .. i,
|
|
||||||
caption = '',
|
|
||||||
style = 'heading_1_label'
|
|
||||||
}
|
|
||||||
|
|
||||||
disp.add{
|
local research_name_i = 'research_' .. i
|
||||||
type = 'label',
|
|
||||||
name = 'research_display_d_' .. i,
|
|
||||||
caption = empty_time,
|
|
||||||
style = 'heading_1_label'
|
|
||||||
}
|
|
||||||
|
|
||||||
disp.add{
|
disp[research_name_i .. '_name'].caption = res_disp[i]['name']
|
||||||
type = 'label',
|
disp[research_name_i .. '_target'].caption = res_disp[i]['target']
|
||||||
name = 'research_display_p_' .. i,
|
disp[research_name_i .. '_attempt'].caption = res_disp[i]['attempt']
|
||||||
caption = '',
|
disp[research_name_i .. '_difference'].caption = res_disp[i]['difference']
|
||||||
style = 'heading_1_label'
|
disp[research_name_i .. '_difference'].style.font_color = res_disp[i]['difference_color']
|
||||||
}
|
|
||||||
|
|
||||||
disp.add{
|
|
||||||
type = 'label',
|
|
||||||
name = 'research_display_t_' .. i,
|
|
||||||
caption = empty_time,
|
|
||||||
style = 'heading_1_label'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local res_n = research_res_n(res['disp'])
|
|
||||||
|
|
||||||
for j=1, 8, 1 do
|
|
||||||
local res_j = res_n + j - 3
|
|
||||||
|
|
||||||
if res['disp'][res_j] then
|
|
||||||
local res_r = res['disp'][res_j]
|
|
||||||
disp['research_display_n_' .. j].caption = res_r.name
|
|
||||||
|
|
||||||
if research.time[res_j] == 0 then
|
|
||||||
disp['research_display_d_' .. j].caption = empty_time
|
|
||||||
disp['research_display_p_' .. j].caption = res_r.prev_disp
|
|
||||||
disp['research_display_t_' .. j].caption = empty_time
|
|
||||||
|
|
||||||
else
|
|
||||||
if research.time[res_j] < res['disp'][res_j].prev then
|
|
||||||
disp['research_display_d_' .. j].caption = '-' .. format_time(res['disp'][res_j].prev - research.time[res_j], research_time_format)
|
|
||||||
|
|
||||||
else
|
|
||||||
disp['research_display_d_' .. j].caption = format_time(research.time[res_j] - res['disp'][res_j].prev, research_time_format)
|
|
||||||
end
|
|
||||||
|
|
||||||
disp['research_display_p_' .. j].caption = res_r.prev_disp
|
|
||||||
disp['research_display_t_' .. j].caption = format_time(research.time[res_j], research_time_format)
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
disp['research_display_n_' .. j].caption = ''
|
|
||||||
disp['research_display_d_' .. j].caption = ''
|
|
||||||
disp['research_display_p_' .. j].caption = ''
|
|
||||||
disp['research_display_t_' .. j].caption = ''
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return research_set
|
return research_set
|
||||||
@@ -234,7 +275,7 @@ end)
|
|||||||
|
|
||||||
local research_container =
|
local research_container =
|
||||||
Gui.element(function(definition, parent)
|
Gui.element(function(definition, parent)
|
||||||
local container = Gui.container(parent, definition.name, 320)
|
local container = Gui.container(parent, definition.name, 390)
|
||||||
|
|
||||||
research_clock_set(container, 'research_st_1')
|
research_clock_set(container, 'research_st_1')
|
||||||
research_data_set(container, 'research_st_2')
|
research_data_set(container, 'research_st_2')
|
||||||
@@ -258,51 +299,20 @@ Event.add(defines.events.on_research_finished, function(event)
|
|||||||
local n_i = res['lookup_name'][event.research.name]
|
local n_i = res['lookup_name'][event.research.name]
|
||||||
research.time[n_i] = game.tick
|
research.time[n_i] = game.tick
|
||||||
|
|
||||||
local res_n = research_res_n(res['disp'])
|
local res_disp = research_gui_update()
|
||||||
local res_disp = {}
|
|
||||||
|
|
||||||
for j=1, 8, 1 do
|
|
||||||
local res_j = res_n + j - 3
|
|
||||||
res_disp[j] = {}
|
|
||||||
|
|
||||||
if res['disp'][res_j] then
|
|
||||||
local res_r = res['disp'][res_j]
|
|
||||||
res_disp[j]['n'] = res_r.name
|
|
||||||
|
|
||||||
if research.time[res_j] == 0 then
|
|
||||||
res_disp[j]['d'] = empty_time
|
|
||||||
res_disp[j]['p']= res_r.prev_disp
|
|
||||||
res_disp[j]['t'] = empty_time
|
|
||||||
|
|
||||||
else
|
|
||||||
if research.time[res_j] < res['disp'][res_j].prev then
|
|
||||||
res_disp[j]['d'] = '-' .. format_time(res['disp'][res_j].prev - research.time[res_j], research_time_format)
|
|
||||||
|
|
||||||
else
|
|
||||||
res_disp[j]['d'] = format_time(research.time[res_j] - res['disp'][res_j].prev, research_time_format)
|
|
||||||
end
|
|
||||||
|
|
||||||
res_disp[j]['p'] = res_r.prev_disp
|
|
||||||
res_disp[j]['t'] = format_time(research.time[res_j], research_time_format)
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
res_disp[j]['n'] = ''
|
|
||||||
res_disp[j]['d'] = ''
|
|
||||||
res_disp[j]['p'] = ''
|
|
||||||
res_disp[j]['t'] = ''
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, player in pairs(game.connected_players) do
|
for _, player in pairs(game.connected_players) do
|
||||||
local frame = Gui.get_left_element(player, research_container)
|
local frame = Gui.get_left_element(player, research_container)
|
||||||
local disp = frame.container['research_st_2'].disp.table
|
local disp = frame.container['research_st_2'].disp.table
|
||||||
|
|
||||||
for j=1, 8, 1 do
|
for i=1, 8, 1 do
|
||||||
disp['research_display_n_' .. j].caption = res_disp[j]['n']
|
local research_name_i = 'research_' .. i
|
||||||
disp['research_display_d_' .. j].caption = res_disp[j]['d']
|
|
||||||
disp['research_display_p_' .. j].caption = res_disp[j]['p']
|
disp[research_name_i .. '_name'].caption = res_disp[i]['name']
|
||||||
disp['research_display_t_' .. j].caption = res_disp[j]['t']
|
disp[research_name_i .. '_target'].caption = res_disp[i]['target']
|
||||||
|
disp[research_name_i .. '_attempt'].caption = res_disp[i]['attempt']
|
||||||
|
disp[research_name_i .. '_difference'].caption = res_disp[i]['difference']
|
||||||
|
disp[research_name_i .. '_difference'].style.font_color = res_disp[i]['difference_color']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user