mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-04 00:15:45 +02:00
map info integration into new panel
This commit is contained in:
parent
b4d15b3f1d
commit
f02425c2a5
@ -31,13 +31,14 @@ local function top_button(player)
|
||||
end
|
||||
|
||||
local function main_frame(player)
|
||||
if player.gui.left["comfy_panel"] then return end
|
||||
if player.gui.left.comfy_panel then player.gui.left.comfy_panel.destroy() end
|
||||
|
||||
local frame = player.gui.left.add({type = "frame", name = "comfy_panel"})
|
||||
frame.style.margin = 8
|
||||
frame.style.margin = 6
|
||||
|
||||
local tabbed_pane = frame.add({type = "tabbed-pane", name = "tabbed_pane"})
|
||||
|
||||
for name, func in pairs(comfy_panel_tabs) do
|
||||
|
||||
for name, func in pairs(comfy_panel_tabs) do
|
||||
if name == "Admin" then
|
||||
if player.admin then
|
||||
local tab = tabbed_pane.add({type = "tab", caption = name})
|
||||
@ -58,6 +59,19 @@ local function main_frame(player)
|
||||
end
|
||||
|
||||
comfy_panel_refresh_active_tab(player)
|
||||
|
||||
return tabs
|
||||
end
|
||||
|
||||
function comfy_panel_call_tab(player, name)
|
||||
main_frame(player)
|
||||
local tabbed_pane = player.gui.left.comfy_panel.tabbed_pane
|
||||
for key, v in pairs(tabbed_pane.tabs) do
|
||||
if v.tab.caption == name then
|
||||
tabbed_pane.selected_tab_index = key
|
||||
comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
|
@ -68,7 +68,7 @@ require "modules.floaty_chat"
|
||||
--require "maps.fish_defender.main"
|
||||
--require "maps.fish_defender_v1.fish_defender"
|
||||
--require "maps.biter_battles_v2.main"
|
||||
--require "maps.mountain_fortress_v2.main"
|
||||
require "maps.mountain_fortress_v2.main"
|
||||
--require "maps.mountain_fortress"
|
||||
--require "maps.island_troopers.main"
|
||||
--require "maps.tank_conquest.tank_conquest"
|
||||
|
@ -16,6 +16,26 @@ require "modules.rocks_heal_over_time"
|
||||
require "modules.rocks_yield_ore_veins"
|
||||
require "modules.spawners_contain_biters"
|
||||
require "modules.map_info"
|
||||
map_info = {}
|
||||
map_info.main_caption = "M O U N T A I N F O R T R E S S"
|
||||
map_info.sub_caption = " ..diggy diggy choo choo.."
|
||||
map_info.text = table.concat({
|
||||
"The biters have catched the scent of fish in the cargo wagon.\n",
|
||||
"Guide the choo into the mountain and protect it as long as possible!\n",
|
||||
"This however will not be an easy task,\n",
|
||||
"since their strength and resistance increases constantly over time.\n",
|
||||
"\n",
|
||||
"Delve deep for greater treasures, but also face increased dangers.\n",
|
||||
"Mining productivity research, will overhaul your mining equipment,\n",
|
||||
"reinforcing your pickaxe as well as increasing the size of your backpack.\n",
|
||||
"\n",
|
||||
"As you dig, you will encounter impassable dark chasms or rivers.\n",
|
||||
"Some explosives may cause parts of the ceiling to crumble, filling the void, creating new ways.\n",
|
||||
"All they need is a container and a well aimed shot.\n",
|
||||
})
|
||||
map_info.main_caption_color = {r = 150, g = 150, b = 0}
|
||||
map_info.sub_caption_color = {r = 0, g = 150, b = 0}
|
||||
|
||||
require "modules.rpg"
|
||||
|
||||
require "maps.mountain_fortress_v2.market"
|
||||
@ -265,25 +285,6 @@ local function on_init(surface)
|
||||
global.rocks_yield_ore_base_amount = 50
|
||||
global.rocks_yield_ore_distance_modifier = 0.03
|
||||
|
||||
global.map_info = {}
|
||||
global.map_info.main_caption = "Mountain Fortress"
|
||||
global.map_info.sub_caption = " ..diggy diggy choo choo.."
|
||||
global.map_info.text = table.concat({
|
||||
"The biters have catched the scent of fish in the cargo wagon.\n",
|
||||
"Guide the choo into the mountain and protect it as long as possible!\n",
|
||||
"This however will not be an easy task,\n",
|
||||
"since their strength and resistance increases constantly over time.\n",
|
||||
"\n",
|
||||
"Delve deep for greater treasures, but also face increased dangers.\n",
|
||||
"Mining productivity research, will overhaul your mining equipment,\n",
|
||||
"reinforcing your pickaxe as well as increasing the size of your backpack.\n",
|
||||
"\n",
|
||||
"As you dig, you will encounter impassable dark chasms or rivers.\n",
|
||||
"Some explosives may cause parts of the ceiling to crumble,\n",
|
||||
"filling the void, creating new ways.\n",
|
||||
"All they need is a container and a well aimed shot.\n",
|
||||
})
|
||||
|
||||
global.explosion_cells_destructible_tiles = {
|
||||
["out-of-map"] = 2000,
|
||||
["water"] = 1500,
|
||||
|
@ -1,80 +1,76 @@
|
||||
global.map_info = {}
|
||||
global.map_info.main_caption = "Insert Main Caption"
|
||||
global.map_info.sub_caption = "Insert Sub Caption"
|
||||
global.map_info.text = [[
|
||||
Add info text to global.map_info.
|
||||
map_info = {}
|
||||
map_info.main_caption = "Insert Main Caption"
|
||||
map_info.main_caption_color = {r=0.6, g=0.3, b=0.99}
|
||||
map_info.sub_caption = "Insert Sub Caption"
|
||||
map_info.sub_caption_color = {r=0.2, g=0.9, b=0.2}
|
||||
map_info.text = [[
|
||||
Add info text to map_info.
|
||||
]]
|
||||
|
||||
local function create_map_intro_button(player)
|
||||
if player.gui.top["map_intro_button"] then return end
|
||||
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
|
||||
b.style.font_color = {r = 0.1, g = 0.8, b = 0.1}
|
||||
b.style.font = "heading-1"
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 38
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
end
|
||||
|
||||
local function create_map_intro(player)
|
||||
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
|
||||
local t = frame.add {type = "table", column_count = 1}
|
||||
local function create_map_intro(player, frame)
|
||||
frame.clear()
|
||||
frame.style.padding = 4
|
||||
frame.style.margin = 0
|
||||
|
||||
local tt = t.add {type = "table", column_count = 3}
|
||||
local l = tt.add {type = "label", caption = global.map_info.main_caption}
|
||||
local t = frame.add {type = "table", column_count = 1}
|
||||
|
||||
local line = t.add { type = "line"}
|
||||
line.style.top_margin = 4
|
||||
line.style.bottom_margin = 4
|
||||
|
||||
local l = t.add {type = "label", caption = map_info.main_caption}
|
||||
l.style.font = "heading-1"
|
||||
l.style.font_color = {r=0.6, g=0.3, b=0.99}
|
||||
l.style.top_padding = 6
|
||||
l.style.bottom_padding = 6
|
||||
l.style.font_color = map_info.main_caption_color
|
||||
l.style.minimal_width = 780
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.vertical_align = "center"
|
||||
|
||||
local l = tt.add {type = "label", caption = global.map_info.sub_caption}
|
||||
l.style.font = "default"
|
||||
l.style.font_color = {r=0.2, g=0.9, b=0.2}
|
||||
l.style.minimal_width = 280
|
||||
local l = t.add {type = "label", caption = map_info.sub_caption}
|
||||
l.style.font = "heading-2"
|
||||
l.style.font_color = map_info.sub_caption_color
|
||||
l.style.minimal_width = 780
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.vertical_align = "center"
|
||||
|
||||
local b = tt.add {type = "button", caption = "X", name = "close_map_intro_frame", align = "right"}
|
||||
b.style.font = "default"
|
||||
b.style.minimal_height = 30
|
||||
b.style.minimal_width = 30
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
local line = t.add { type = "line"}
|
||||
line.style.top_margin = 4
|
||||
line.style.bottom_margin = 4
|
||||
|
||||
local tt = t.add {type = "table", column_count = 1}
|
||||
local frame = t.add {type = "frame"}
|
||||
local l = frame.add {type = "label", caption = global.map_info.text}
|
||||
l.style.font = "heading-3"
|
||||
local scroll_pane = frame.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
|
||||
scroll_pane.style.maximal_height = 320
|
||||
scroll_pane.style.minimal_height = 320
|
||||
|
||||
local l = scroll_pane.add {type = "label", caption = map_info.text}
|
||||
l.style.font = "heading-2"
|
||||
l.style.single_line = false
|
||||
l.style.font_color = {r=0.95, g=0.95, b=0.95}
|
||||
l.style.font_color = {r=0.85, g=0.85, b=0.88}
|
||||
l.style.minimal_width = 780
|
||||
l.style.horizontal_align = "center"
|
||||
l.style.vertical_align = "center"
|
||||
|
||||
local b = frame.add {type = "button", caption = "CLOSE", name = "close_map_intro"}
|
||||
b.style.font = "heading-2"
|
||||
b.style.padding = 2
|
||||
b.style.top_margin = 3
|
||||
b.style.left_margin = 333
|
||||
b.style.horizontal_align = "center"
|
||||
b.style.vertical_align = "center"
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
create_map_intro_button(player)
|
||||
if player.online_time == 0 then
|
||||
create_map_intro(player)
|
||||
end
|
||||
if player.online_time == 0 then comfy_panel_call_tab(player, "Map Info") end
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then return end
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() return end
|
||||
if event.element.name == "map_intro_button" then
|
||||
if player.gui.left["map_intro_frame"] then
|
||||
player.gui.left["map_intro_frame"].destroy()
|
||||
else
|
||||
create_map_intro(player)
|
||||
end
|
||||
return
|
||||
end
|
||||
if event.element.name == "close_map_intro" then game.players[event.player_index].gui.left.comfy_panel.destroy() return end
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Map Info"] = create_map_intro
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
Loading…
Reference in New Issue
Block a user