1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-16 02:47:48 +02:00

mtn - requested changes

This commit is contained in:
Gerkiz 2021-01-11 15:58:12 +01:00
parent a2011ded58
commit 507ad4e65e
4 changed files with 53 additions and 24 deletions

View File

@ -1049,12 +1049,12 @@ local function show_mvps(player)
wave_defense_text.style.font = 'default-bold'
wave_defense_text.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local defender_label = t.add({type = 'label', caption = 'Defender >> '})
defender_label.style.font = 'default-listbox'
defender_label.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local defender_label_text = t.add({type = 'label', caption = mvp.killscore.name .. ' with a killing score of ' .. mvp.killscore.score .. ' kills!'})
defender_label_text.style.font = 'default-bold'
defender_label_text.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local fighter_label = t.add({type = 'label', caption = 'Fighter >> '})
fighter_label.style.font = 'default-listbox'
fighter_label.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
local fighter_label_text = t.add({type = 'label', caption = mvp.killscore.name .. ' with a killing score of ' .. mvp.killscore.score .. ' kills!'})
fighter_label_text.style.font = 'default-bold'
fighter_label_text.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local builder_label = t.add({type = 'label', caption = 'Builder >> '})
builder_label.style.font = 'default-listbox'
@ -1077,7 +1077,7 @@ local function show_mvps(player)
table.insert(result, 'HIGHEST WAVE: \\n')
table.insert(result, wave_defense_table.wave_number .. '\\n')
table.insert(result, '\\n')
table.insert(result, 'MVP Defender: \\n')
table.insert(result, 'MVP Fighter: \\n')
table.insert(result, mvp.killscore.name .. ' with a killing score of ' .. mvp.killscore.score .. ' kills!\\n')
table.insert(result, '\\n')
table.insert(result, 'MVP Builder: \\n')

View File

@ -169,6 +169,22 @@ local function on_init()
Public.reset()
end
local function on_gui_switch_state_changed(event)
local element = event.element
local player = game.players[event.player_index]
if not (player and player.valid) then
return
end
if not element.valid then
return
end
if element.name == 'ic_auto_switch' then
Minimap.toggle_auto(player)
end
end
local changed_surface = Minimap.changed_surface
Event.on_init(on_init)
@ -183,4 +199,6 @@ Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity)
Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(defines.events.on_player_changed_surface, changed_surface)
Event.add(IC.events.on_player_kicked_from_surface, trigger_on_player_kicked_from_surface)
Event.add(defines.events.on_gui_switch_state_changed, on_gui_switch_state_changed)
return Public

View File

@ -57,25 +57,23 @@ local function get_player_data(player)
end
ic.minimap[player.index] = {
surface = ic.allowed_surface,
zoom = 0.30,
map_size = 360,
auto_map = true
auto = true,
state = 'left'
}
return ic.minimap[player.index]
end
function Public.toggle_auto(player)
local ic = ICT.get()
local switch = player.gui.left.minimap_toggle_frame['switch_auto_map']
if not switch or not switch.valid then
return
end
local player_data = get_player_data(player)
local switch = player.gui.left.minimap_toggle_frame['ic_auto_switch']
if switch.switch_state == 'left' then
ic.minimap[player.index].auto_map = true
player_data.auto = true
player_data.state = 'left'
elseif switch.switch_state == 'right' then
ic.minimap[player.index].auto_map = false
player_data.auto = false
player_data.state = 'right'
end
end
@ -120,12 +118,21 @@ local function draw_minimap(player, surface, position)
local player_data = get_player_data(player)
local frame = player.gui.left.minimap_toggle_frame
if not frame then
frame =
player.gui.left.add(
{type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Minimap'}
)
frame = player.gui.left.add({type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Minimap'})
end
frame.visible = true
if not frame.ic_auto_switch then
frame.add(
{
type = 'switch',
name = 'ic_auto_switch',
switch_state = player_data.state,
allow_none_state = false,
left_label_caption = {'gui.map_on'},
right_label_caption = {'gui.map_off'}
}
)
end
local element = frame['minimap_frame']
if not element then
element =
@ -164,7 +171,8 @@ end
function Public.update_minimap()
local ic = ICT.get()
for k, player in pairs(game.connected_players) do
if Functions.get_player_surface(ic, player) and player.gui.left.minimap_toggle_frame then
local player_data = get_player_data(player)
if Functions.get_player_surface(ic, player) and player.gui.left.minimap_toggle_frame and player_data.auto then
kill_frame(player)
draw_minimap(player)
end
@ -226,10 +234,13 @@ function Public.changed_surface(event)
end
local wd = player.gui.top['wave_defense']
local diff = player.gui.top['difficulty_gui']
local player_data = get_player_data(player)
if Functions.get_player_surface(ic, player) then
Public.toggle_button(player)
Public.minimap(player, surface)
if player_data.auto then
Public.minimap(player, surface)
end
if wd and wd.visible then
wd.visible = false
end

View File

@ -983,7 +983,7 @@ function Public.draw_minimap(icw, player, surface, position)
local player_data = get_player_data(icw, player)
local frame = player.gui.left.icw_main_frame
if not frame then
frame = player.gui.left.add({type = 'frame', direction = 'vertical', name = 'icw_main_frame', caption = 'Minimap'})
frame = player.gui.left.add({type = 'frame', direction = 'vertical', name = 'icw_main_frame', caption = 'Minimap'})
end
local element = frame['icw_sub_frame']
if not frame.icw_auto_switch then