Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 91fdacc

Browse files
committed
Merge branch 'dev'
2 parents e71f5fb + 52e0c86 commit 91fdacc

File tree

14 files changed

+173
-944
lines changed

14 files changed

+173
-944
lines changed

changelog.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
return {
2+
{
3+
name = "2.0.0",
4+
date = "1. 2. 2018",
5+
Features = {
6+
{
7+
"Added an option to automatically sort containers when opened",
8+
more = {["5a5f1b0dadcc441024d76d79"] = "https://mods.factorio.com/mod/manual-inventory-sort/discussion/5a5f1b0dadcc441024d76d79"},
9+
},
10+
{
11+
"Added an option to automatically sort player's inventory when opened",
12+
},
13+
},
14+
Changes = {
15+
{
16+
"Used the new API features to replace the old sorting mechanism",
17+
more = {["0.16.21"] = "https://forums.factorio.com/viewtopic.php?f=3&t=57372#p339957"},
18+
},
19+
"Autosort is now much faster and sorts on each inventory change",
20+
"Settings have been moved to the mod options (autosort is only togglable via the hotkey)",
21+
"Removed part inventory sorting as it's not possible with the new system",
22+
},
23+
},
224
{
325
name = "1.8.1",
426
date = "16. 12. 2017",

manual-inventory-sort/changelog.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 2.0.0
3+
Date: 1. 2. 2018
4+
Features:
5+
- Added an option to automatically sort containers when opened (https://mods.factorio.com/mod/manual-inventory-sort/discussion/5a5f1b0dadcc441024d76d79)
6+
- Added an option to automatically sort player's inventory when opened
7+
Changes:
8+
- Used the new API features to replace the old sorting mechanism (https://forums.factorio.com/viewtopic.php?f=3&t=57372#p339957)
9+
- Autosort is now much faster and sorts on each inventory change
10+
- Settings have been moved to the mod options (autosort is only togglable via the hotkey)
11+
- Removed part inventory sorting as it's not possible with the new system
12+
---------------------------------------------------------------------------------------------------
213
Version: 1.8.1
314
Date: 16. 12. 2017
415
Bugfixes:
516
- Fixed filters in the main inventory weren't taken into account
617
---------------------------------------------------------------------------------------------------
718
Version: 1.8.0
819
Date: 16. 12. 2017
9-
Changes:
10-
- Updated for 0.16
1120
Bugfixes:
1221
- Fixed that opened blueprint books and similar items would close when the inventory was sorted (https://github.com/theRustyKnife/ManualInventorySorting/issues/4)
22+
Changes:
23+
- Updated for 0.16
1324
---------------------------------------------------------------------------------------------------
1425
Version: 1.7.0
1526
Date: 15. 07. 2017
@@ -61,11 +72,11 @@ Date: 19. 09. 2016
6172
---------------------------------------------------------------------------------------------------
6273
Version: 1.4.5
6374
Date: 06. 09. 2016
75+
Bugfixes:
76+
- Fixed GUI buttons would not appear when opened a logistic chest
6477
Features:
6578
- Added car and wagon sorting
6679
- Added Russian translation (by Apriori)
67-
Bugfixes:
68-
- Fixed GUI buttons would not appear when opened a logistic chest
6980
---------------------------------------------------------------------------------------------------
7081
Version: 1.4.4
7182
Date: 26. 08. 2016
@@ -89,10 +100,10 @@ Date: 30. 07. 2016
89100
---------------------------------------------------------------------------------------------------
90101
Version: 1.4.0
91102
Date: 30. 07. 2016
92-
Features:
93-
- Added sorting GUI
94103
Bugfixes:
95104
- Fixed broken migration script (hopefully), apologies to anyone who had problems with this - it should be safe now to migrate from any version to 1.4
105+
Features:
106+
- Added sorting GUI
96107
---------------------------------------------------------------------------------------------------
97108
Version: 1.3.0
98109
Date: 30. 07. 2016
@@ -119,10 +130,10 @@ Date: 28. 07. 2016
119130
---------------------------------------------------------------------------------------------------
120131
Version: 1.1.0
121132
Date: 27. 07. 2016
122-
Features:
123-
- Added the auto-sort feature. It has performance problems to be solved though.
124133
Bugfixes:
125134
- Fixed a bug making it possible to duplicate items with durability in certain cases
135+
Features:
136+
- Added the auto-sort feature. It has performance problems to be solved though.
126137
---------------------------------------------------------------------------------------------------
127138
Version: 1.0.1
128139
Date: 27. 07. 2016

manual-inventory-sort/control.lua

Lines changed: 93 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,95 @@
1-
migration = require "script.migration"
1+
--TODO: Autosort containers while open?
2+
--TODO: Stop autosort while open?
3+
--TODO: Autosort state indicator?
24

3-
script.on_configuration_changed(migration.migrate)
4-
script.on_init(migration.init)
55

6-
require("script.events")
6+
local SORTABLE = {
7+
['container'] = true,
8+
['logistic-container'] = true,
9+
['car'] = true,
10+
['cargo-wagon'] = true,
11+
}
12+
13+
14+
local function init()
15+
global.auto_sort = global.auto_sort or {}
16+
end
17+
18+
19+
local function sort_player(index)
20+
game.players[index].get_main_inventory().sort_and_merge()
21+
end
22+
23+
local function sort_opened(index)
24+
local player = game.players[index]
25+
if player.opened and SORTABLE[player.opened.type] then
26+
(
27+
player.opened.get_inventory(defines.inventory.car_trunk) or
28+
player.opened.get_inventory(defines.inventory.chest) or
29+
player.opened.get_inventory(defines.inventory.cargo_wagon)
30+
).sort_and_merge()
31+
end
32+
end
33+
34+
35+
local function sort_buttons_gui(index)
36+
local player = game.players[index]
37+
if player.opened or player.opened_self then
38+
if not player.gui.left['manual-inventory-sort-buttons'] then
39+
local frame = player.gui.left.add{
40+
type='frame',
41+
name='manual-inventory-sort-buttons',
42+
direction='vertical',
43+
caption={'manual-inventory-gui-sort-title'},
44+
}
45+
frame.add{type='button', name='manual-inventory-sort-player', caption={'manual-inventory-gui-sort_player'}}
46+
if player.opened and SORTABLE[player.opened.type] then
47+
frame.add{type='button', name='manual-inventory-sort-opened', caption={'manual-inventory-gui-sort_chest'}}
48+
end
49+
end
50+
elseif player.gui.left['manual-inventory-sort-buttons'] then
51+
player.gui.left['manual-inventory-sort-buttons'].destroy()
52+
end
53+
end
54+
55+
56+
script.on_init(init)
57+
script.on_configuration_changed(init) --TODO: Empty the global table if migrating from an older version
58+
59+
60+
script.on_event('manual-inventory-sort', function(event) sort_player(event.player_index); end)
61+
62+
script.on_event('manual-inventory-sort-opened', function(event) sort_opened(event.player_index); end)
63+
64+
script.on_event('manual-inventory-auto-sort-toggle', function(event)
65+
local player = game.players[event.player_index]
66+
global.auto_sort[player.index] = not global.auto_sort[player.index]
67+
if global.auto_sort[player.index] then
68+
player.print{"manual-inventory-auto-sort-on"}
69+
sort_player(player.index)
70+
else player.print{"manual-inventory-auto-sort-off"}; end
71+
end)
72+
73+
74+
script.on_event(defines.events.on_player_main_inventory_changed, function(event)
75+
if global.auto_sort[event.player_index] then sort_player(event.player_index); end
76+
end)
77+
78+
79+
script.on_event(defines.events.on_gui_opened, function(event)
80+
local player = game.players[event.player_index]
81+
local options = settings.get_player_settings(player)
82+
83+
if options['manual-inventory-sort-buttons'].value then sort_buttons_gui(player.index); end
84+
if options['manual-inventory-sort-on-open'].value then sort_opened(player.index); end
85+
if options['manual-inventory-sort-self-on-open'].value then sort_player(player.index); end
86+
end)
87+
script.on_event(defines.events.on_gui_closed, function(event) sort_buttons_gui(event.player_index); end)
88+
89+
script.on_event(defines.events.on_gui_click, function(event)
90+
if event.element.name == 'manual-inventory-sort-player' then
91+
sort_player(event.player_index)
92+
elseif event.element.name == 'manual-inventory-sort-opened' then
93+
sort_opened(event.player_index)
94+
end
95+
end)

manual-inventory-sort/data-updates.lua

Lines changed: 0 additions & 14 deletions
This file was deleted.

manual-inventory-sort/data.lua

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,20 @@
1-
data:extend({
1+
data:extend{
22
{
3-
type = "custom-input",
4-
name = "manual-inventory-sort",
5-
key_sequence = "SHIFT + Q",
6-
consuming = "all"
3+
type = 'custom-input',
4+
name = 'manual-inventory-sort',
5+
key_sequence = 'SHIFT + Q',
6+
consuming = 'all',
77
},
88
{
9-
type = "custom-input",
10-
name = "manual-inventory-sort-opened",
11-
key_sequence = "CONTROL + Q",
12-
consuming = "all"
9+
type = 'custom-input',
10+
name = 'manual-inventory-sort-opened',
11+
key_sequence = 'CONTROL + Q',
12+
consuming = 'all',
1313
},
1414
{
15-
type = "custom-input",
16-
name = "manual-inventory-auto-sort-toggle",
17-
key_sequence = "SHIFT + Y",
18-
consuming = "all"
19-
},
20-
{
21-
type = "custom-input",
22-
name = "manual-inventory-options",
23-
key_sequence = "SHIFT + X",
24-
consuming = "all"
25-
},
26-
{
27-
type = "container",
28-
name = "manual-inventory-sort-tmp-chest",
29-
icon = "__manual-inventory-sort__/graphics/trans.png",
30-
icon_size = 32,
31-
flags = {"placeable-neutral", "placeable-off-grid"},
32-
max_health = 10000,
33-
selectable_in_game = false,
34-
corpse = "small-remnants",
35-
collision_mask = {},
36-
collision_box = {{0, 0}, {0, 0}},
37-
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
38-
inventory_size = 1000,
39-
order = "none",
40-
open_sound = { filename = "__base__/sound/wooden-chest-open.ogg" },
41-
close_sound = { filename = "__base__/sound/wooden-chest-close.ogg" },
42-
vehicle_impact_sound = { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
43-
picture =
44-
{
45-
filename = "__manual-inventory-sort__/graphics/trans.png",
46-
priority = "extra-high",
47-
width = 0,
48-
height = 0
49-
},
50-
circuit_wire_connection_point = circuit_connector_definitions["chest"].points,
51-
circuit_connector_sprites = circuit_connector_definitions["chest"].sprites,
52-
circuit_wire_max_distance = 0
53-
},
54-
})
15+
type = 'custom-input',
16+
name = 'manual-inventory-auto-sort-toggle',
17+
key_sequence = 'SHIFT + Y',
18+
consuming = 'all',
19+
}
20+
}
-182 Bytes
Binary file not shown.

manual-inventory-sort/info.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "manual-inventory-sort",
3-
"version": "1.8.1",
3+
"version": "2.0.0",
44
"factorio_version": "0.16",
55
"title": "Manual Inventory Sorting",
6+
"description": "Makes some tweaks to the way inventory sorting works.\nYou can sort your inventory on demand or toggle auto-sort. Auto-sort can be configured to work for just a part of your inventory. \nIt's also possible to sort chests, cars and cargo wagons.",
67
"author": "TheRustyKnife",
78
"contact": "[email protected]",
8-
"description": "Makes some tweaks to the way inventory sorting works.\nYou can sort your inventory on demand or toggle auto-sort. Auto-sort can be configured to work for just a part of your inventory. \nIt's also possible to sort chests, cars and cargo wagons.",
9-
"homepage": "http://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort",
10-
"date": "2017-12-16",
11-
"dependencies": ["base"]
9+
"homepage": "https://mods.factorio.com/mod/manual-inventory-sort",
10+
"dependencies": ["base >= 0.16.21"]
1211
}

0 commit comments

Comments
 (0)