1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00

minimap view

This commit is contained in:
hanakocz 2020-05-22 17:35:14 +02:00
parent 7337e8a8ec
commit 221506d8d0
8 changed files with 172 additions and 7 deletions

View File

@ -101,6 +101,14 @@ message_quest6=Comfylatron: And, I've got the last part of the CPU brain done. N
message_game_won1=Comfylatron: Thank you all for helping me with fish delivery. It was tough ride. And now that the biters are dead, the fish will be safe here forever...
message_comfylatron_desync=Comfylatron: I got you that time! Back to work, __1__!
difficulty1=Too easy!Low pollution, less enemies, etc...
difficulty2=Still easy!Low pollution, less enemies, etc...
difficulty3=Nearly easy!Low pollution, less enemies, etc...
difficulty4=Normal. Everything just about right...
difficulty5=A bit hard. More pollution, more enemies, etc...
difficulty6=Just about hard. More pollution, more enemies, etc...
difficulty7=Perfectly playable. Maybe. More pollution, more enemies, etc...
map_1=Terra Ferrata
map_2=Malachite Hills
map_3=Granite Plains
@ -207,6 +215,8 @@ gui_planet_6=Overstay in: __1__ min, __2__s
gui_planet_7=Overstay applies after jump __1__
gui_overstayed=Overstayed!
gui_not_overstayed=Avoided overstay.
minimap=Outside View
minimap_tooltip=LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.\nMap button on top to hide/show
[rocks_yield_ore_veins]

View File

@ -102,6 +102,14 @@ message_quest6=Компилатрон: И это была последняя ч
message_game_won1=Компилатрон: Спасибо, что помогли мне с этой доставкой. Это было очень тяжело. Я надеюсь, что теперь, когда все кусачие мертвы, рыба будет в безопасности здесь навсегда...
message_comfylatron_desync=Компилатрон: I got you that time! Back to work, __1__!
difficulty1=Too easy!Low pollution, less enemies, etc...
difficulty2=Still easy!Low pollution, less enemies, etc...
difficulty3=Nearly easy!Low pollution, less enemies, etc...
difficulty4=Normal. Everything just about right...
difficulty5=A bit hard. More pollution, more enemies, etc...
difficulty6=Just about hard. More pollution, more enemies, etc...
difficulty7=Perfectly playable. Maybe. More pollution, more enemies, etc...
map_1=Феррата Земли
map_2=Малахитовые холмы
map_3=Гранитные Равнины
@ -208,6 +216,8 @@ gui_planet_6=засидеться в: __1__ min, __2__s
gui_planet_7=засидеться активен после прыжка __1__
gui_overstayed=засидеться!
gui_not_overstayed=засидеться niet.
minimap=Outside View
minimap_tooltip=LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.\nMap button on top to hide/show
train_market=Рынок
train_repair_chest=Ремонтный сундук

View File

@ -125,9 +125,13 @@ Public.wagon_starting_items = {{name = 'firearm-magazine', count = 16},{name = '
function Public.jumps_until_overstay_is_on(difficulty) --both overstay penalties, and evoramp
local objective = Chrono_table.get_table()
if not objective.config.overstay_penalty then return 999 end
if difficulty > 1 then return 2
elseif difficulty == 1 then return 3
else return 5
if not difficulty then return 3 end
if difficulty > 1 then
return 2
elseif difficulty == 1 then
return 3
else
return 5
end
end

View File

@ -141,7 +141,7 @@ function Public_event.choppy_loot(event)
if choppy_entity_yield[entity.name] then
if event.buffer then event.buffer.clear() end
if not event.player_index then return end
local amount = math_ceil(get_ore_amount(false))
local amount = math_ceil(get_ore_amount(false) / 2)
local second_item_amount = math_random(1,3)
local second_item = "wood"
local main_item = choppy_entity_yield[entity.name][math_random(1,#choppy_entity_yield[entity.name])]

View File

@ -8,6 +8,7 @@ local math_min = math.min
local Upgrades = require "maps.chronosphere.upgrade_list"
local Balance = require "maps.chronosphere.balance"
local Difficulty = require 'modules.difficulty_vote'
local Minimap = require "maps.chronosphere.minimap"
local function create_gui(player)
local frame = player.gui.top.add({ type = "frame", name = "chronosphere"})
@ -399,6 +400,10 @@ function Public_gui.on_gui_click(event)
elseif event.element.name == "planet_button" then
planet_gui(player)
return
elseif event.element.name == "minimap_button" then
Minimap.minimap(player)
elseif event.element.name =="icw_map" or event.element.name == "icw_map_frame" then
Minimap.toggle_minimap(event)
end
if event.element.type ~= "button" and event.element.type ~= "sprite-button" then return end

View File

@ -23,6 +23,7 @@ local Rand = require 'maps.chronosphere.random'
local Chrono = require "maps.chronosphere.chrono"
local Chrono_table = require 'maps.chronosphere.table'
local Locomotive = require "maps.chronosphere.locomotive"
local Minimap = require "maps.chronosphere.minimap"
local Gui = require "maps.chronosphere.gui"
local Difficulty = require 'modules.difficulty_vote'
local math_random = math.random
@ -152,6 +153,9 @@ local function reset_map()
local surface = game.surfaces[objective.active_surface_index]
generate_overworld(surface, planet)
Chrono.restart_settings()
for _,player in pairs(game.players) do
Minimap.minimap(player)
end
game.forces.player.set_spawn_position({12, 10}, surface)
Locomotive.locomotive_spawn(surface, {x = 16, y = 10}, Chrono.get_wagons(true))
@ -486,12 +490,25 @@ local function tick() --only even ticks trigger
end
Locomotive.fish_tag()
end
for _, player in pairs(game.connected_players) do Gui.update_gui(player) end
for _, player in pairs(game.connected_players) do
Minimap.toggle_button(player)
Gui.update_gui(player)
end
end
local function on_init()
local objective = Chrono_table.get_table()
local T = Map.Pop_info()
local difficulty_tooltips = {
[1] = {"chronosphere.difficulty1"},
[2] = {"chronosphere.difficulty2"},
[3] = {"chronosphere.difficulty3"},
[4] = {"chronosphere.difficulty4"},
[5] = {"chronosphere.difficulty5"},
[6] = {"chronosphere.difficulty6"},
[7] = {"chronosphere.difficulty7"}
}
Difficulty.set_tooltip(difficulty_tooltips)
T.localised_category = "chronosphere"
T.main_caption_color = {r = 150, g = 150, b = 0}
T.sub_caption_color = {r = 0, g = 150, b = 0}
@ -631,6 +648,7 @@ local function on_player_driving_changed_state(event)
local player = game.players[event.player_index]
local vehicle = event.entity
Locomotive.enter_cargo_wagon(player, vehicle)
Minimap.minimap(player)
end
-- function deny_building(event)
@ -717,8 +735,6 @@ local function on_research_finished(event)
end
local function on_entity_damaged(event)
local difficulty = Difficulty.get().difficulty_vote_value
if not event.entity.valid then return end
protect_entity(event)
if not event.entity.valid then return end

View File

@ -0,0 +1,118 @@
local Public = {}
local Chrono_table = require 'maps.chronosphere.table'
local function create_button(player)
local button = player.gui.top.add({ type = "sprite-button", name = "minimap_button", sprite = "utility/map"})
button.visible = false
end
function Public.toggle_button(player)
if not player.gui.top["minimap_button"] then
create_button(player)
end
local button = player.gui.top["minimap_button"]
if player.surface.name == "cargo_wagon" then
button.visible = true
else
button.visible = false
end
end
local function get_player_data(player)
local objective = Chrono_table.get_table()
local player_data = objective.icw.players[player.index]
if objective.icw.players[player.index] then return player_data end
objective.icw.players[player.index] = {
surface = objective.active_surface_index,
zoom = 0.30,
map_size = 360,
}
return objective.icw.players[player.index]
end
local function kill_minimap(player)
local element = player.gui.screen.icw_map_frame
if element then element.destroy() end
end
local function draw_minimap(player)
local objective = Chrono_table.get_table()
local surface = game.surfaces[objective.active_surface_index]
local position = objective.locomotive.position
local frame = player.gui.screen.icw_map_frame
if not frame then
frame = player.gui.screen.add({ type = "frame", name = "icw_map_frame", caption = {"chronosphere.minimap"}})
frame.location = {x = 10, y = 45}
end
local element = frame["icw_map"]
if not element then
local player_data = get_player_data(player)
element = player.gui.screen.icw_map_frame.add({
type = "camera",
name = "icw_map",
position = position,
surface_index = surface.index,
zoom = player_data.zoom,
tooltip = {"chronosphere.minimap_tooltip"}
})
element.style.margin = 1
element.style.minimal_height = player_data.map_size
element.style.minimal_width = player_data.map_size
return
end
element.position = position
end
function Public.minimap(player)
if player.gui.screen["icw_map_frame"] then
kill_minimap(player)
else
if player.surface.name == "cargo_wagon" then
draw_minimap(player)
end
end
end
function Public.update_minimap()
for k, player in pairs(game.connected_players) do
if player.character and player.character.valid then
if player.surface.name == "cargo_wagon" and player.gui.screen.icw_map then
Public.draw_minimap(player)
end
end
end
end
function Public.toggle_minimap(event)
local element = event.element
if not element then return end
if not element.valid then return end
if element.name ~= "icw_map" then return end
local player = game.players[event.player_index]
local player_data = get_player_data(player)
if event.button == defines.mouse_button_type.right then
player_data.zoom = player_data.zoom - 0.07
if player_data.zoom < 0.07 then player_data.zoom = 0.07 end
element.zoom = player_data.zoom
return
end
if event.button == defines.mouse_button_type.left then
player_data.zoom = player_data.zoom + 0.07
if player_data.zoom > 2 then player_data.zoom = 2 end
element.zoom = player_data.zoom
return
end
if event.button == defines.mouse_button_type.middle then
player_data.map_size = player_data.map_size + 50
if player_data.map_size > 650 then player_data.map_size = 250 end
element.style.minimal_height = player_data.map_size
element.style.minimal_width = player_data.map_size
element.style.maximal_height = player_data.map_size
element.style.maximal_width = player_data.map_size
return
end
end
return Public

View File

@ -53,6 +53,8 @@ function Public.reset_table()
chronosphere.comfychests2 = {}
chronosphere.locomotive_cargo = {}
chronosphere.planet = {}
chronosphere.icw = {}
chronosphere.icw.players = {}
end
function Public.get_table()