-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
d5be513
commit 75cdc40
Showing
11 changed files
with
1,154 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) |
Oops, something went wrong.