-
Notifications
You must be signed in to change notification settings - Fork 1
/
APalletAutoLoaderShopConfigScreenExtension.lua
132 lines (112 loc) · 3.02 KB
/
APalletAutoLoaderShopConfigScreenExtension.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
-- test im Shop daten an zu zeigen
APalletAutoLoaderShopConfigScreenExtension = {}
function APalletAutoLoaderShopConfigScreenExtension:registerCustomSpecValues(superFunc, values, storeItems, vehicle, saleItem)
-- print("APalletAutoLoaderShopConfigScreenExtension:registerCustomSpecValues")
superFunc(self, values, storeItems, vehicle, saleItem)
local spec = vehicle.spec_aPalletAutoLoader
if spec == nil or spec.loadArea["baseNode"] == nil then
return false;
end
-- Ballen einfach nur die erste Zeile
local text = "AL: ";
local usedItems = 0;
for index, shopText in ipairs(spec.squareBaleShopText) do
if text ~= "AL: " then
text = text .. " - ";
end
text = text .. shopText;
usedItems = usedItems + 1;
-- zwischenschritte ausgeben
if string.len(text) >= 60 then
break;
end
end
if usedItems ~= #spec.squareBaleShopText then
text = text .. " - ...";
end
-- ausgeben
if text ~= "AL: " then
table.insert(values, {
profile = ShopConfigScreen.GUI_PROFILE.BALE_SIZE_SQUARE,
value = text
})
text = "AL: ";
usedItems = 0
end
for index, shopText in ipairs(spec.roundBaleShopText) do
if text ~= "AL: " then
text = text .. " - ";
end
text = text .. shopText;
usedItems = usedItems + 1;
-- zwischenschritte ausgeben
if string.len(text) >= 60 then
break;
end
end
if usedItems ~= #spec.roundBaleShopText then
text = text .. " - ...";
end
-- rest ausgeben
if text ~= "AL: " then
table.insert(values, {
profile = ShopConfigScreen.GUI_PROFILE.BALE_SIZE_ROUND,
value = text
})
text = "AL: ";
usedItems = 0
end
-- Paletten so viele Zeilen bis es dann 9 sind
local text = "AL: ";
local usedItems = 0;
local currentLineLength = 4;
local currentLines = 1;
local profileToUse = ShopConfigScreen.GUI_PROFILE.CAPACITY;
local maxInnerLines = 2;
for index, shopText in ipairs(spec.palletShopText) do
if currentLineLength >= 60 then
if currentLines == maxInnerLines then
if #values == 8 then
break;
end
-- neues Element einfügen
table.insert(values, {
profile = profileToUse,
value = text
})
text = "";
currentLineLength = 4;
currentLines = 1;
profileToUse = "";
if maxInnerLines == 2 then
maxInnerLines = 3;
else
maxInnerLines = 2;
end
else
text = text .. "\n";
currentLineLength = 0
currentLines = currentLines + 1
end
end
if text ~= "AL: " and text ~= "" and currentLineLength ~= 0 then
text = text .. " - "
end
text = text .. shopText;
usedItems = usedItems + 1;
currentLineLength = currentLineLength + string.len(shopText) + 3
end
if usedItems ~= #spec.palletShopText then
text = text .. " - ...";
end
-- ausgeben
if text ~= "AL: " and text ~= "" then
table.insert(values, {
profile = profileToUse,
value = text
})
text = "AL: ";
usedItems = 0
end
end
ShopConfigScreen.registerCustomSpecValues = Utils.overwrittenFunction(ShopConfigScreen.registerCustomSpecValues, APalletAutoLoaderShopConfigScreenExtension.registerCustomSpecValues)