Skip to content

Commit

Permalink
Frozen (#242)
Browse files Browse the repository at this point in the history
* Frozen (#240)

* make smart farms flora possitive

* version and changelog

* fix that collectors mk02-mk04 didnt get reset

fixes pyanodon/pybugreports#461

* i blame theros ass

* Smart farm fixes

* pyanodon/pybugreports#458

* TURD balance & migrations

* Fixed that subcritical-water-01 was not localised when pyAE is missing

* Fixed that the alpha dingrits from dingrit turd path 1 could not be used as modules inside the reproductive complex.

* Energy drink qol improvements

* Fixed several bugs involved with biofluid vessel underground pipes

* Fixed several bugs involved with biofluid vessel underground pipes

* remove print statements

* Reduce earlygame manual wood requirement grind.

---------

Co-authored-by: kingarthur91 <[email protected]>

* Fixed returned cages (#235)

* Add files via upload

* Fixed returned cages

* Fixed returned cages

* Fixed returned cages

* Returned cages fixed

* Fixed cage return

* Global Caravan handling GUI (#222)

* list of clickables everything is broken though

* click opens the thing

* moved to a new file-> todo prevent item stealing
list by outpost
scrollpane

* outpost gui

* status icon

* less loc

* new state idle

* pasting untested stuff from chatgpt

* ho

* more stuff that will certainly work nocap

* connected gui works

* lets try this migrations thingy

* fixed the migration

* use the migration

* fixed the close button...

* cleanup code a bit

* fixed the esc key

* localization

* localization

* ship it

* new rule I like open better

* wuuups

* I broke esc again...

* Apply pyanodon code formatting standard

* Remove references to stdlib functions as part of an ongoing effort to remove stdlib.

* Streamline the amount of code needed to handle GUI closing events

* Make the GUI expand to the container instead of having a hardcoded size

* Improve the relative GUI type guessing algorithm

* Move hotkey based GUI to pycodex and add a camera

* Add more buttons and finalize styling

---------

Co-authored-by: notnotmelon <[email protected]>

* Add a rename button to the original caravan GUI

* Add some randomly generated placeholder names for caravans.

---------

Co-authored-by: kingarthur91 <[email protected]>
Co-authored-by: Wisey <[email protected]>
Co-authored-by: TheGoesen <[email protected]>
  • Loading branch information
4 people authored Apr 15, 2024
1 parent d5be513 commit 75cdc40
Show file tree
Hide file tree
Showing 11 changed files with 1,154 additions and 43 deletions.
1 change: 1 addition & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ script.on_event(defines.events.on_player_removed_equipment, function(event)
end)

script.on_event(defines.events.on_gui_opened, function(event)
Caravan.events.on_gui_opened_connected(event)
Oculua.events.on_gui_opened(event)
Digosaurus.events.on_gui_opened(event)
Slaughterhouse.events.on_gui_opened(event)
Expand Down
14 changes: 14 additions & 0 deletions locale/en/caravan.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ outpost-aerial=Item and food storage for aerial caravans.
healthy=Healthy
starved=Starved
wounded=Wounded
idle=Idle

[caravan-shared]
open=Open __1__
view-on-map=View on map
current-action=Current action: __1__
current-destination=__1__m from __2__

[caravan-global-gui]
caption=Caravan manager
empty=This is the caravan manager. It will display all placed caravans and their current status.
empty-2=Currently you have no caravans.

[caravan-gui]
add-outpost=+ Add destination
Expand All @@ -26,6 +38,7 @@ refocus=Refocus
favorite-foods-main=Favorite foods:\n__1__
favorite-foods-sub=__1__ __2__ → __3__ actions
wait=Wait until fulfilled
hello-my-name-is=[font=default-bold]Hello, my name is: [color=255,210,73]__1__[/color][/font]

[caravan-actions]
time-passed=Wait
Expand All @@ -37,6 +50,7 @@ inverse-item-count=Until target has exactly N items
detonate=Detonate
circuit-condition=Circuit condition
empty-autotrash=Collect all autotrash
traveling=Traveling

[item-name]
caravan-control=Caravan control
Expand Down
1 change: 1 addition & 0 deletions locale/en/tips.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
alienlife=Alien life
farming=[item=native-flora] Farming
caravans=[item=caravan] Caravans
caravan-manager=[item=caravan-control] Caravan manager
mounts=[item=crawdad] Mounts
digosaurus=[item=digosaurus] Dig-o-saurus
mega-farm=[item=replicator-bioreserve] Automated smart farms
Expand Down
8 changes: 8 additions & 0 deletions migrations/caravan_gui.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
for _,player in pairs(game.players) do
local gui = player.gui.relative.caravan_gui
if gui then
gui.destroy()
end --it lives in a flow now
end


72 changes: 72 additions & 0 deletions scripts/caravan/caravan-connected-gui.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require 'caravan-gui-shared'

local relative_gui_types = {
['electric-pole'] = 'electric_network_gui',
['character'] = 'other_player_gui',
['unit'] = 'script_inventory_gui'
}

local function guess(entity)
local entity_type = entity.type
local relative_gui_type = relative_gui_types[entity_type] or entity_type:gsub('%-', '_') .. '_gui'
return defines.relative_gui_type[relative_gui_type] or defines.relative_gui_type.generic_on_off_entity_gui
end

--anchor is optional
local function instantiate_main_frame(gui, anchor)
if anchor then
return gui.relative.add{
type = 'frame',
name = 'py_global_caravan_gui',
caption = {'caravan-global-gui.caption'},
direction = 'vertical',
anchor = anchor
}
end
if not gui.relative.caravan_flow then return end
return gui.relative.caravan_flow.add{
type = 'frame',
name = 'py_global_caravan_gui',
caption = {'caravan-global-gui.caption'},
direction = 'vertical',
}
end

function Caravan.has_any_caravan(entity)
for _, caravan_data in pairs(global.caravans) do
if has_schedule(caravan_data, entity) then return true end
end
return false
end

--anchor is optional
Caravan.build_gui_connected = function(player, entity, anchor)
if not entity then return end
if not Caravan.has_any_caravan(entity) then return end
local main_frame = instantiate_main_frame(player.gui, anchor)
if not main_frame then return end
main_frame.style.minimal_width = 300
main_frame.tags = {unit_number = entity.unit_number}

local scroll_pane = main_frame.add{type = 'scroll-pane'}
scroll_pane.style.top_margin = -6

for key, caravan_data in pairs(global.caravans) do
if has_schedule(caravan_data, entity) then
scroll_pane.add{type = 'empty-widget'}.style.height = 3
Caravan.add_gui_row(caravan_data, key, scroll_pane)
end
end
end

Caravan.events.on_gui_opened_connected = function(event)
local player = game.get_player(event.player_index)
local entity = event.entity
if not entity then return end
if player.gui.relative.connected_caravan_gui then return end
local anchor = {
gui = guess(entity),
position = defines.relative_gui_position.right
}
Caravan.build_gui_connected(player, entity, anchor)
end
33 changes: 33 additions & 0 deletions scripts/caravan/caravan-global-gui.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'caravan-gui-shared'

function Caravan.has_any_caravan_at_all()
for _, caravan in pairs(global.caravans) do
if Caravan.validity_check(caravan) then return true end
end
return false
end

local function create_gui(gui, player)
if not Caravan.has_any_caravan_at_all() then
gui = gui.add{type = 'flow', direction = 'vertical'}
gui.style.horizontal_align = 'center'
gui.style.horizontally_stretchable = true
gui.add{type = 'label', caption = ''}
gui.add{type = 'label', caption = {'caravan-global-gui.empty'}}.style.single_line = false
gui.add{type = 'label', caption = {'caravan-global-gui.empty-2'}}.style.single_line = false
return
end
local table = gui.add{
type = 'table',
column_count = 4
}
for key, caravan_data in pairs(global.caravans) do
if Caravan.validity_check(caravan_data) and caravan_data.entity.force_index == player.force_index then
Caravan.add_gui_row(caravan_data, key, table)
end
end
end

remote.add_interface('pywiki_caravan_manager', {
create_gui = create_gui
})
Loading

0 comments on commit 75cdc40

Please sign in to comment.