LUADOC - Farming Simulator 22

StoreManager

Description
This class handles all store categories and items
Parent
AbstractManager
Functions

addCategory

Description
Adds a new store category
Definition
addCategory(string name, string title, string imageFilename, string baseDir)
Arguments
stringnamecategory index name
stringtitlecategory title
stringimageFilenameimage
stringbaseDirbase directory
Return Values
booleantrueif adding was successful else false
Code
195function StoreManager:addCategory(name, title, imageFilename, type, baseDir, orderId)
196 if name == nil or name == "" then
197 print("Warning: Could not register store category. Name is missing or empty!")
198 return false
199 end
200 if not ClassUtil.getIsValidIndexName(name) then
201 print("Warning: '"..tostring(name).."' is no valid name for a category!")
202 return false
203 end
204 if title == nil or title == "" then
205 print("Warning: Could not register store category. Title is missing or empty!")
206 return false
207 end
208 if imageFilename == nil or imageFilename == "" then
209 print("Warning: Could not register store category. Image is missing or empty!")
210 return false
211 end
212 if baseDir == nil then
213 print("Warning: Could not register store category. Basedirectory not defined!")
214 return false
215 end
216
217 name = name:upper()
218
219 if GS_PLATFORM_SWITCH and name == "COINS" then
220 return false
221 end
222
223 if self.categories[name] == nil then
224 self.numOfCategories = self.numOfCategories + 1
225
226 self.categories[name] = {
227 name = name,
228 title = title,
229 image = Utils.getFilename(imageFilename, baseDir),
230 type = StoreManager.CATEGORY_TYPE[type] ~= nil and type or StoreManager.CATEGORY_TYPE.NONE,
231 orderId = orderId or self.numOfCategories
232 }
233
234 return true
235 end
236
237 return false
238end

addConstructionCategory

Description
Add a new construction category.
Definition
addConstructionCategory()
Code
276function StoreManager:addConstructionCategory(name, title, iconFilename, iconUVs, baseDir)
277 name = name:upper()
278
279 if self.constructionCategoriesByName[name] ~= nil then
280 Logging.warning("Construction category '%s' already exists.", name)
281 return
282 end
283
284 local category = {
285 name = name,
286 title = title,
287 iconFilename = Utils.getFilename(iconFilename, baseDir),
288 iconUVs = iconUVs,
289 tabs = {},
290 index = #self.constructionCategories + 1
291 }
292
293 table.insert(self.constructionCategories, category)
294 self.constructionCategoriesByName[name] = category
295end

addConstructionTab

Description
Add a new construction tab
Definition
addConstructionTab()
Code
308function StoreManager:addConstructionTab(categoryName, name, title, iconFilename, iconUVs, baseDir)
309 local category = self:getConstructionCategoryByName(categoryName)
310 if category == nil then
311 return
312 end
313
314 table.insert(category.tabs, {
315 name = name:upper(),
316 title = title,
317 iconFilename = Utils.getFilename(iconFilename, baseDir),
318 iconUVs = iconUVs,
319 index = #category.tabs + 1
320 })
321end

addItem

Description
Adds a new store item
Definition
addItem(table storeItem)
Arguments
tablestoreItemthe storeitem object
Return Values
booleanwasSuccessfulltrue if added else false
Code
420function StoreManager:addItem(storeItem)
421 local otherItem = self.xmlFilenameToItem[storeItem.xmlFilenameLower]
422 if otherItem ~= nil then
423 -- in case we have added a item already as bundle item, but then afterwards want to add it as regular item as well
424 -- so we copy isBundleItem and showInStore from the regular item
425 if otherItem.isBundleItem and not storeItem.isBundleItem then
426 otherItem.isBundleItem = storeItem.isBundleItem
427 otherItem.showInStore = storeItem.showInStore
428 end
429
430 return false
431 end
432
433 table.insert(self.items, storeItem)
434 storeItem.id = #self.items
435 self.xmlFilenameToItem[storeItem.xmlFilenameLower] = storeItem
436 return true
437end

addModStoreItem

Description
Definition
addModStoreItem()
Code
608function StoreManager:addModStoreItem(xmlFilename, baseDir, customEnvironment, isMod, isBundleItem, dlcTitle)
609 table.insert(self.modStoreItems, {xmlFilename=xmlFilename, baseDir=baseDir, customEnvironment=customEnvironment, isMod=isMod, isBundleItem=isBundleItem, dlcTitle=dlcTitle})
610end

addModStorePack

Description
Definition
addModStorePack()
Code
1026function StoreManager:addModStorePack(name, title, imageFilename, baseDir)
1027 table.insert(self.modStorePacks, {
1028 name=name,
1029 title=title,
1030 imageFilename=imageFilename,
1031 baseDir=baseDir}
1032 )
1033end

addPack

Description
Adds a new store pack
Definition
addPack(string name, string title, string imageFilename, string baseDir)
Arguments
stringnamepack name
stringtitlepack title
stringimageFilenameimage
stringbaseDirbase directory
Return Values
booleantrueif adding was successful else false
Code
982function StoreManager:addPack(name, title, imageFilename, baseDir)
983 if name == nil or name == "" then
984 print("Warning: Could not register store pack. Name is missing or empty!")
985 return false
986 end
987 if not ClassUtil.getIsValidIndexName(name) then
988 print("Warning: '"..tostring(name).."' is no valid name for a store pack!")
989 return false
990 end
991 if title == nil or title == "" then
992 print("Warning: Could not register store pack. Title is missing or empty!")
993 return false
994 end
995 if imageFilename == nil or imageFilename == "" then
996 print("Warning: Could not register store pack. Image is missing or empty!")
997 return false
998 end
999 if baseDir == nil then
1000 print("Warning: Could not register store pack. Basedirectory not defined!")
1001 return false
1002 end
1003
1004 name = name:upper()
1005
1006 if self.packs[name] == nil then
1007 self.numOfPacks = self.numOfPacks + 1
1008
1009 self.packs[name] = {
1010 name = name,
1011 title = title,
1012 image = Utils.getFilename(imageFilename, baseDir),
1013 baseDir = baseDir,
1014 orderId = self.numOfPacks,
1015 items = {}
1016 }
1017
1018 return true
1019 end
1020
1021 return false
1022end

addPackItem

Description
Add a new pack item.
Definition
addPackItem(string name, string itemFilename)
Arguments
stringnameName of the pack
stringitemFilenameXML filename of the vehicle in the pack
Code
1039function StoreManager:addPackItem(name, itemFilename)
1040 if name == nil or name == "" then
1041 Logging.warning("Could not add pack item. Name is missing or empty.")
1042 return
1043 end
1044 if self.packs[name] == nil then
1045 Logging.warning("Could not add pack item. Pack '%s' does not exist.", name)
1046 return
1047 end
1048 if itemFilename == nil or itemFilename == "" then
1049 Logging.warning("Could not add pack item to '%s'. Item filename is missing.", name)
1050 return
1051 end
1052
1053 table.insert(self.packs[name].items, itemFilename)
1054end

addSpecType

Description
Adds a new spec type
Definition
addSpecType(string name, string profile, function loadFunc, function getValueFunc)
Arguments
stringnamespec type index name
stringprofilespec type gui profile
functionloadFuncthe loading function pointer
functiongetValueFuncthe get value function pointer
Code
362function StoreManager:addSpecType(name, profile, loadFunc, getValueFunc, species, relatedConfigurations, configDataFunc)
363 if not ClassUtil.getIsValidIndexName(name) then
364 print("Warning: '"..tostring(name).."' is no valid name for a spec type!")
365 return
366 end
367
368 name = name
369
370 if self.nameToSpecType == nil then
371 printCallstack()
372 end
373
374 if self.nameToSpecType[name] ~= nil then
375 print("Error: spec type name '" ..name.. "' is already in use!")
376 return
377 end
378
379 local specType = {}
380 specType.name = name
381 specType.profile = profile
382 specType.loadFunc = loadFunc
383 specType.getValueFunc = getValueFunc
384 specType.species = species or "vehicle"
385 specType.relatedConfigurations = relatedConfigurations or {}
386 specType.configDataFunc = configDataFunc
387
388 self.nameToSpecType[name] = specType
389 table.insert(self.specTypes, specType)
390end

consoleCommandReloadStoreItems

Description
Definition
consoleCommandReloadStoreItems()
Code
1076function StoreManager:consoleCommandReloadStoreItems()
1077 for i, item in ipairs(self.items) do
1078 self.items[i] = self:loadItem(item.rawXMLFilename, item.baseDir, item.customEnvironment, item.isMod, item.isBundleItem, item.dlcTitle, item.extraContentId, true)
1079 if self.items[i] ~= nil then
1080 self.xmlFilenameToItem[self.items[i].xmlFilenameLower] = self.items[i]
1081 end
1082 end
1083
1084 g_messageCenter:publish(MessageType.STORE_ITEMS_RELOADED)
1085end

getCategoryByName

Description
Gets a store category by name
Definition
getCategoryByName(string name)
Arguments
stringnamecategory index name
Return Values
tablecategorythe category object
Code
263function StoreManager:getCategoryByName(name)
264 if name ~= nil then
265 return self.categories[name:upper()]
266 end
267 return nil
268end

getConstructionCategories

Description
Get categories for construction screen
Definition
getConstructionCategories()
Code
344function StoreManager:getConstructionCategories()
345 return self.constructionCategories
346end

getConstructionCategoryByName

Description
Get construction category by name
Definition
getConstructionCategoryByName()
Code
299function StoreManager:getConstructionCategoryByName(name)
300 if name ~= nil then
301 return self.constructionCategoriesByName[name:upper()]
302 end
303 return nil
304end

getConstructionTabByName

Description
Get a construction tab using its name and category name
Definition
getConstructionTabByName()
Code
325function StoreManager:getConstructionTabByName(name, categoryName)
326 local category = self:getConstructionCategoryByName(categoryName)
327 if category == nil or name == nil then
328 return nil
329 end
330
331 name = name:upper()
332
333 for i, tab in ipairs(category.tabs) do
334 if tab.name == name then
335 return tab
336 end
337 end
338
339 return nil
340end

getIsItemUnlocked

Description
Returns if store item is unlocked
Definition
getIsItemUnlocked(table storeItem)
Arguments
tablestoreItemthe storeitem oject
Return Values
booleanisUnlockedis unlocked
Code
489function StoreManager:getIsItemUnlocked(storeItem)
490 if storeItem ~= nil and (storeItem.extraContentId == nil or g_extraContentSystem:getIsItemIdUnlocked(storeItem.extraContentId)) then
491 return true
492 end
493
494 return false
495end

getItemByCustomEnvironment

Description
Gets a store item xml filename
Definition
getItemByCustomEnvironment(string xmlFilename)
Arguments
stringxmlFilenamestoreitem xml filename
Return Values
tablestoreItemthe storeitem object
Code
595function StoreManager:getItemByCustomEnvironment(customEnvironment)
596 local items = {}
597 for _, item in ipairs(self.items) do
598 if item.customEnvironment == customEnvironment then
599 table.insert(items, item)
600 end
601 end
602
603 return items
604end

getItemByIndex

Description
Gets a store item by index
Definition
getItemByIndex(integer index)
Arguments
integerindexstore item index
Return Values
tablestoreItemthe storeitem oject
Code
468function StoreManager:getItemByIndex(index)
469 if index ~= nil then
470 return self.items[index]
471 end
472 return nil
473end

getItemByXMLFilename

Description
Gets a store item xml filename
Definition
getItemByXMLFilename(string xmlFilename)
Arguments
stringxmlFilenamestoreitem xml filename
Return Values
tablestoreItemthe storeitem object
Code
479function StoreManager:getItemByXMLFilename(xmlFilename)
480 if xmlFilename ~= nil then
481 return self.xmlFilenameToItem[xmlFilename:lower()]
482 end
483end

getItems

Description
Gets all storeitems
Definition
getItems()
Return Values
tableitemsa list of all store items
Code
460function StoreManager:getItems()
461 return self.items
462end

getItemsByCombinationData

Description
Returns store items that match the given combination data
Definition
getItemsByCombinationData(table combinationData)
Arguments
tablecombinationDatacombination data
Return Values
tablestoreItemstable with store items
Code
501function StoreManager:getItemsByCombinationData(combinationData)
502 local items = {}
503 if combinationData.xmlFilename ~= nil then
504 local storeItem = self.xmlFilenameToItem[combinationData.customXMLFilename:lower()]
505 if storeItem == nil then
506 storeItem = self.xmlFilenameToItem[combinationData.xmlFilename:lower()]
507 if storeItem == nil then
508 Logging.warning("Could not find combination vehicle '%s'", combinationData.xmlFilename)
509 end
510 end
511
512 if self:getIsItemUnlocked(storeItem) then
513 table.insert(items, {storeItem=storeItem})
514 end
515 else
516 for _, storeItem in ipairs(self.items) do
517 if self:getIsItemUnlocked(storeItem) then
518 local categoryAllowed = true
519 if combinationData.filterCategories ~= nil then
520 categoryAllowed = false
521 for j=1, #combinationData.filterCategories do
522 if combinationData.filterCategories[j]:upper() == storeItem.categoryName then
523 categoryAllowed = true
524 break
525 end
526 end
527 end
528
529 if categoryAllowed then
530 if combinationData.filterSpec == nil then
531 table.insert(items, {storeItem=storeItem})
532 else
533 local desc = self:getSpecTypeByName(combinationData.filterSpec)
534 if desc ~= nil then
535 if desc.species == storeItem.species then
536 StoreItemUtil.loadSpecsFromXML(storeItem)
537
538 local value, maxValue = desc.getValueFunc(storeItem, nil, nil, nil, true, true)
539 if value ~= nil then
540 local specMin = combinationData.filterSpecMin
541 local specMax = combinationData.filterSpecMax
542 -- special case weight -> in the xml we defined it as kg, but in code we handle it always as tons
543 if combinationData.filterSpec == "weight" then
544 specMin = specMin / 1000
545 specMax = specMax / 1000
546 end
547
548 if value >= specMin and value <= specMax then
549 table.insert(items, {storeItem=storeItem})
550 else
551 if desc.configDataFunc ~= nil then
552 local configDatas = desc.configDataFunc(storeItem)
553 if configDatas ~= nil then
554 for i=1, #configDatas do
555 local configData = configDatas[i]
556 if configData.value >= specMin and configData.value <= specMax then
557 table.insert(items, {storeItem=storeItem, configData={[configData.name] = configData.index}})
558 end
559 end
560 end
561 else
562 if #desc.relatedConfigurations > 0 and storeItem.configurations ~= nil then
563 for i=1, #desc.relatedConfigurations do
564 local configurationName = desc.relatedConfigurations[i]
565 if storeItem.configurations[configurationName] ~= nil then
566 local configItems = storeItem.configurations[configurationName]
567 for configIndex=1, #configItems do
568 local configData = {[configurationName] = configIndex}
569 value = desc.getValueFunc(storeItem, nil, configData, nil, true, true)
570 if value >= specMin and value <= specMax then
571 table.insert(items, {storeItem=storeItem, configData=configData})
572 end
573 end
574 end
575 end
576 end
577 end
578 end
579 end
580 end
581 end
582 end
583 end
584 end
585 end
586 end
587
588 return items
589end

getPackItems

Description
Get the items in the pack.
Definition
getPackItems(string name)
Arguments
stringnamename of the pack.
Code
1065function StoreManager:getPackItems(name)
1066 local pack = self.packs[name]
1067 if pack == nil then
1068 return nil
1069 else
1070 return pack.items
1071 end
1072end

getPacks

Description
Get a list of all packs
Definition
getPacks()
Code
1058function StoreManager:getPacks()
1059 return self.packs
1060end

getSpecTypeByName

Description
Gets a spec type by name
Definition
getSpecTypeByName(string name)
Arguments
stringnamespec type index name
Return Values
tablespecTypethe corresponding spectype
Code
403function StoreManager:getSpecTypeByName(name)
404 if not ClassUtil.getIsValidIndexName(name) then
405 print("Warning: '"..tostring(name).."' is no valid name for a spec type!")
406 return
407 end
408
409 return self.nameToSpecType[name]
410end

getSpecTypes

Description
Gets all spec types
Definition
getSpecTypes()
Return Values
tablespecTypesa list of spec types
Code
395function StoreManager:getSpecTypes()
396 return self.specTypes
397end

initDataStructures

Description
Initialize data structures
Definition
initDataStructures()
Code
33function StoreManager:initDataStructures()
34 self.numOfCategories = 0
35 self.numOfPacks = 0
36 self.categories = {}
37 self.packs = {}
38 self.items = {}
39 self.xmlFilenameToItem = {}
40 self.modStoreItems = {}
41 self.modStorePacks = {}
42
43 self.specTypes = {}
44 self.nameToSpecType = {}
45
46 self.vramUsageFunctions = {}
47
48 self.constructionCategoriesByName = {}
49 self.constructionCategories = {}
50end

loadCategoryFromXML

Description
Load shop category from XML file
Definition
loadCategoryFromXML(table xmlFile, string key, string baseDir)
Arguments
tablexmlFilexml file object
stringkeykey
stringbaseDirbase directory
Code
174function StoreManager:loadCategoryFromXML(xmlFile, key, baseDir, customEnv)
175 local name = xmlFile:getString(key .. "#name")
176 local title = xmlFile:getString(key .. "#title")
177 local imageFilename = xmlFile:getString(key .. "#image")
178 local type = xmlFile:getString(key .. "#type")
179 local orderId = xmlFile:getInt(key .. "#orderId")
180
181 if title ~= nil and title:sub(1, 6) == "$l10n_" then
182 title = g_i18n:getText(title:sub(7), customEnv)
183 end
184
185 self:addCategory(name, title, imageFilename, type, baseDir, orderId)
186end

loadItem

Description
Loads a storeitem from xml file
Definition
loadItem(string xmlFilename, string baseDir, string customEnvironment, boolean isMod, boolean isBundleItem, string dlcTitle)
Arguments
stringxmlFilenamethe storeitem xml filename
stringbaseDirthe base directory
stringcustomEnvironmenta custom environment
booleanisModtrue if item is a mod, else false
booleanisBundleItemtrue if item is bundleItem, else false
stringdlcTitleoptional dlc title
Return Values
tablestoreItemthe storeitem object
Code
621function StoreManager:loadItem(rawXMLFilename, baseDir, customEnvironment, isMod, isBundleItem, dlcTitle, extraContentId, ignoreAdd)
622 local xmlFilename = Utils.getFilename(rawXMLFilename, baseDir)
623 local xmlFile = loadXMLFile("storeItemXML", xmlFilename)
624 if xmlFile == 0 then
625 return nil
626 end
627
628 local baseXMLName = getXMLRootName(xmlFile)
629 local storeDataXMLKey = baseXMLName..".storeData"
630
631 -- just load the species the old way to categorize the file
632 local species = getXMLString(xmlFile, storeDataXMLKey..".species") or "vehicle"
633 local xmlSchema
634 if species == "vehicle" then
635 xmlSchema = Vehicle.xmlSchema
636 elseif species == "handTool" then
637 xmlSchema = HandTool.xmlSchema
638 elseif species == "placeable" then
639 xmlSchema = Placeable.xmlSchema
640 end
641
642 if xmlSchema ~= nil then
643 delete(xmlFile)
644 xmlFile = XMLFile.load("storeManagerLoadItemXml", xmlFilename, xmlSchema)
645 else
646 Logging.xmlError(xmlFile, "Unable to get xml schema for species '%s' in '%s'", species, xmlFilename)
647 return nil
648 end
649
650 -- check if file name matches naming convention
651 local xmlName = Utils.getFilenameInfo(xmlFilename, true)
652 if xmlName:sub(1, 1) ~= xmlName:sub(1, 1):lower() then
653 Logging.xmlDevWarning(xmlFile, "Filename is starting with upper case character. Please follow the lower camel case naming convention.")
654 end
655 if tonumber(xmlName:sub(1, 1)) ~= nil then
656 Logging.xmlDevWarning(xmlFile, "Filename is starting with a number. Please start always with a character.")
657 end
658 local xmlPathPaths = xmlFilename:split("/")
659 local numParts = #xmlPathPaths
660 if numParts >= 4 then
661 if xmlPathPaths[numParts-3] == "vehicles" then
662 if string.startsWith(xmlPathPaths[numParts]:lower(), xmlPathPaths[numParts-2]:lower()) then
663 Logging.xmlDevWarning(xmlFile, "Vehicle filename '%s' starts with brand name '%s'.", xmlName, xmlPathPaths[numParts-2])
664 end
665 end
666 end
667
668 if not xmlFile:hasProperty(storeDataXMLKey) then
669 Logging.xmlError(xmlFile, "No storeData found. StoreItem will be ignored!")
670 xmlFile:delete()
671 return nil
672 end
673
674 local isValid = true
675 local name = xmlFile:getValue(storeDataXMLKey..".name", nil, customEnvironment, true)
676 if name == nil then
677 Logging.xmlWarning(xmlFile, "Name missing for storeitem. Ignoring store item!")
678 isValid = false
679 end
680
681 if name ~= nil then
682 local params = xmlFile:getValue(storeDataXMLKey..".name#params")
683 if params ~= nil then
684 params = params:split("|")
685
686 for i=1, #params do
687 params[i] = g_i18n:convertText(params[i], customEnvironment)
688 end
689
690 name = string.format(name, unpack(params))
691 end
692 end
693
694 local imageFilename = xmlFile:getValue(storeDataXMLKey..".image", "")
695 if imageFilename == "" then
696 imageFilename = nil
697 end
698 if imageFilename == nil and xmlFile:getValue(storeDataXMLKey..".showInStore", true) then
699 Logging.xmlWarning(xmlFile, "Image icon is missing for storeitem. Ignoring store item!")
700 isValid = false
701 end
702
703 if not isValid then
704 xmlFile:delete()
705 return nil
706 end
707
708 local storeItem = {}
709 storeItem.name = name
710 storeItem.extraContentId = extraContentId
711 storeItem.rawXMLFilename = rawXMLFilename
712 storeItem.baseDir = baseDir
713 storeItem.xmlSchema = xmlSchema
714 storeItem.xmlFilename = xmlFilename
715 storeItem.xmlFilenameLower = xmlFilename:lower()
716 storeItem.imageFilename = imageFilename and Utils.getFilename(imageFilename, baseDir)
717 storeItem.species = species
718 storeItem.functions = StoreItemUtil.getFunctionsFromXML(xmlFile, storeDataXMLKey, customEnvironment)
719 storeItem.specs = nil
720 storeItem.brandIndex = StoreItemUtil.getBrandIndexFromXML(xmlFile, storeDataXMLKey)
721 storeItem.brandNameRaw = xmlFile:getValue(storeDataXMLKey..".brand", "")
722 storeItem.customBrandIcon = xmlFile:getValue(storeDataXMLKey..".brand#customIcon")
723 storeItem.customBrandIconOffset = xmlFile:getValue(storeDataXMLKey..".brand#imageOffset")
724 if storeItem.customBrandIcon ~= nil then
725 storeItem.customBrandIcon = Utils.getFilename(storeItem.customBrandIcon, baseDir)
726 end
727 storeItem.canBeSold = xmlFile:getValue(storeDataXMLKey..".canBeSold", true)
728 storeItem.showInStore = xmlFile:getValue(storeDataXMLKey..".showInStore", not isBundleItem)
729 storeItem.isBundleItem = isBundleItem
730 storeItem.allowLeasing = xmlFile:getValue(storeDataXMLKey..".allowLeasing", true)
731 storeItem.maxItemCount = xmlFile:getValue(storeDataXMLKey..".maxItemCount")
732 storeItem.rotation = xmlFile:getValue(storeDataXMLKey..".rotation", 0)
733 storeItem.shopDynamicTitle = xmlFile:getValue(storeDataXMLKey..".shopDynamicTitle", false)
734 storeItem.shopTranslationOffset = xmlFile:getValue(storeDataXMLKey..".shopTranslationOffset", nil, true)
735 storeItem.shopRotationOffset = xmlFile:getValue(storeDataXMLKey..".shopRotationOffset", nil, true)
736 storeItem.shopIgnoreLastComponentPositions = xmlFile:getValue(storeDataXMLKey..".shopIgnoreLastComponentPositions", false)
737 storeItem.shopInitialLoadingDelay = xmlFile:getValue(storeDataXMLKey..".shopLoadingDelay#initial")
738 storeItem.shopConfigLoadingDelay = xmlFile:getValue(storeDataXMLKey..".shopLoadingDelay#config")
739 storeItem.shopHeight = xmlFile:getValue(storeDataXMLKey..".shopHeight", 0)
740 storeItem.financeCategory = xmlFile:getValue(storeDataXMLKey..".financeCategory")
741 storeItem.shopFoldingState = xmlFile:getValue(storeDataXMLKey..".shopFoldingState", 0)
742 storeItem.shopFoldingTime = xmlFile:getValue(storeDataXMLKey..".shopFoldingTime")
743
744 local sharedVramUsage, perInstanceVramUsage, ignoreVramUsage = StoreItemUtil.getVRamUsageFromXML(xmlFile, storeDataXMLKey)
745 for _, func in ipairs(self.vramUsageFunctions) do
746 local customSharedVramUsage, customPerInstanceVramUsage = func(xmlFile)
747
748 sharedVramUsage = sharedVramUsage + customSharedVramUsage
749 perInstanceVramUsage = perInstanceVramUsage + customPerInstanceVramUsage
750 end
751
752 storeItem.sharedVramUsage, storeItem.perInstanceVramUsage, storeItem.ignoreVramUsage = sharedVramUsage, perInstanceVramUsage, ignoreVramUsage
753
754 storeItem.dlcTitle = dlcTitle
755 storeItem.isMod = isMod
756 storeItem.customEnvironment = customEnvironment
757
758 local categoryName = xmlFile:getValue(storeDataXMLKey..".category")
759 local category = self:getCategoryByName(categoryName)
760 if category == nil then
761 Logging.xmlWarning(xmlFile, "Invalid category '%s' in store data! Using 'misc' instead!", tostring(categoryName))
762 category = self:getCategoryByName("misc")
763 end
764 storeItem.categoryName = category.name
765
766 if species == "vehicle" then
767 storeItem.configurations, storeItem.defaultConfigurationIds = StoreItemUtil.getConfigurationsFromXML(xmlFile, baseXMLName, baseDir, customEnvironment, isMod, storeItem)
768 storeItem.subConfigurations = StoreItemUtil.getSubConfigurationsFromXML(storeItem.configurations)
769 storeItem.configurationSets = StoreItemUtil.getConfigurationSetsFromXML(storeItem, xmlFile, baseXMLName, baseDir, customEnvironment, isMod)
770
771 storeItem.hasLicensePlates = xmlFile:hasProperty("vehicle.licensePlates.licensePlate(0)")
772 end
773 storeItem.price = xmlFile:getValue(storeDataXMLKey..".price", 0)
774 if storeItem.price < 0 then
775 Logging.xmlWarning(xmlFile, "Price has to be greater than 0. Using default 10.000 instead!")
776 storeItem.price = 10000
777 end
778 storeItem.dailyUpkeep = xmlFile:getValue(storeDataXMLKey..".dailyUpkeep", 0)
779 storeItem.runningLeasingFactor = xmlFile:getValue(storeDataXMLKey..".runningLeasingFactor", EconomyManager.DEFAULT_RUNNING_LEASING_FACTOR)
780 storeItem.lifetime = xmlFile:getValue(storeDataXMLKey..".lifetime", 600)
781
782 xmlFile:iterate("handTool.storeData.storePacks.storePack", function(_, key)
783 local packName = xmlFile:getValue(key)
784 self:addPackItem(packName, xmlFilename)
785 end)
786
787 xmlFile:iterate("vehicle.storeData.storePacks.storePack", function(_, key)
788 local packName = xmlFile:getValue(key)
789 self:addPackItem(packName, xmlFilename)
790 end)
791
792 local bundleItemsToAdd = {}
793 if xmlFile:hasProperty(storeDataXMLKey..".bundleElements") then
794 local bundleInfo = {bundleItems={}, attacherInfo={}}
795 local price = 0
796 local lifetime = math.huge
797 local dailyUpkeep = 0
798 local runningLeasingFactor = 0
799 local i = 0
800 while true do
801 local bundleKey = string.format(storeDataXMLKey..".bundleElements.bundleElement(%d)", i)
802 if not xmlFile:hasProperty(bundleKey) then
803 break
804 end
805 local bundleXmlFile = xmlFile:getValue(bundleKey..".xmlFilename")
806 local offset = xmlFile:getValue(bundleKey..".offset", "0 0 0", true)
807 local rotationOffset = xmlFile:getValue(bundleKey..".rotationOffset", "0 0 0", true)
808 local rotation = xmlFile:getValue(bundleKey..".yRotation", 0)
809 rotationOffset[2] = rotationOffset[2] + rotation
810 if bundleXmlFile ~= nil then
811 local completePath = Utils.getFilename(bundleXmlFile, baseDir)
812 local item = self:getItemByXMLFilename(completePath)
813 if item == nil then
814 item = self:loadItem(bundleXmlFile, baseDir, customEnvironment, isMod, true, dlcTitle, nil, true)
815 table.insert(bundleItemsToAdd, item)
816 end
817 if item ~= nil then
818 price = price + item.price
819 dailyUpkeep = dailyUpkeep + item.dailyUpkeep
820 runningLeasingFactor = runningLeasingFactor + item.runningLeasingFactor
821 lifetime = math.min(lifetime, item.lifetime)
822
823 if item.configurations ~= nil then
824 storeItem.configurations = storeItem.configurations or {}
825
826 for configName, configOptions in pairs(item.configurations) do
827 if storeItem.configurations[configName] ~= nil then
828 -- sum the prices of the configurations on multiple items
829 local itemConfigOptions = storeItem.configurations[configName]
830 for j=1, #configOptions do
831 if itemConfigOptions[j] == nil then
832 itemConfigOptions[j] = configOptions[j]
833 else
834 itemConfigOptions[j].price = itemConfigOptions[j].price + configOptions[j].price
835 end
836 end
837 else
838 storeItem.configurations[configName] = table.copy(configOptions, math.huge)
839 end
840 end
841 end
842
843 if item.defaultConfigurationIds ~= nil then
844 storeItem.defaultConfigurationIds = storeItem.defaultConfigurationIds or {}
845 end
846
847 if item.subConfigurations ~= nil then
848 storeItem.subConfigurations = storeItem.subConfigurations or {}
849 for configName, configOptions in pairs(item.subConfigurations) do
850 storeItem.subConfigurations[configName] = configOptions
851 end
852 end
853
854 if item.configurationSets ~= nil then
855 storeItem.configurationSets = storeItem.configurationSets or {}
856 for configName, configOptions in pairs(item.configurationSets) do
857 storeItem.configurationSets[configName] = configOptions
858 end
859 end
860
861 local preSelectedConfigurations = {}
862 xmlFile:iterate(bundleKey .. ".configurations.configuration", function(_, configKey)
863 local configName = xmlFile:getValue(configKey.."#name")
864 local configValue = xmlFile:getValue(configKey.."#value")
865 if configName ~= nil and configValue ~= nil then
866 local allowChange = xmlFile:getValue(configKey.."#allowChange", false)
867 local hideOption = xmlFile:getValue(configKey.."#hideOption", false)
868 local disableOption = xmlFile:getValue(configKey.."#disableOption", false)
869 if not disableOption then
870 preSelectedConfigurations[configName] = {configValue=configValue, allowChange=allowChange, hideOption=hideOption}
871 else
872 local configElements = storeItem.configurations[configName]
873 if configElements ~= nil then
874 for j=1, #configElements do
875 if j == configValue then
876 configElements[j].isSelectable = not configElements[j].isSelectable
877 end
878 end
879 end
880 end
881 end
882 end)
883
884 storeItem.hasLicensePlates = storeItem.hasLicensePlates or item.hasLicensePlates
885
886 table.insert(bundleInfo.bundleItems, {item=item, xmlFilename=item.xmlFilename, offset=offset, rotationOffset=rotationOffset, rotation=0, price=item.price, preSelectedConfigurations=preSelectedConfigurations})
887 end
888 end
889 i = i + 1
890 end
891
892 i = 0
893 while true do
894 local attachKey = string.format(storeDataXMLKey..".attacherInfo.attach(%d)", i)
895 if not xmlFile:hasProperty(attachKey) then
896 break
897 end
898 local bundleElement0 = xmlFile:getValue(attachKey.."#bundleElement0")
899 local bundleElement1 = xmlFile:getValue(attachKey.."#bundleElement1")
900 local attacherJointIndex = xmlFile:getValue(attachKey.."#attacherJointIndex")
901 local inputAttacherJointIndex = xmlFile:getValue(attachKey.."#inputAttacherJointIndex")
902 if bundleElement0 ~= nil and bundleElement1 ~= nil and attacherJointIndex ~= nil and inputAttacherJointIndex ~= nil then
903 table.insert(bundleInfo.attacherInfo, {bundleElement0=bundleElement0, bundleElement1=bundleElement1, attacherJointIndex=attacherJointIndex, inputAttacherJointIndex=inputAttacherJointIndex})
904 end
905 i = i + 1
906 end
907
908 storeItem.price = price
909 storeItem.dailyUpkeep = dailyUpkeep
910 storeItem.runningLeasingFactor = runningLeasingFactor
911 storeItem.lifetime = lifetime
912 storeItem.bundleInfo = bundleInfo
913 end
914
915 -- Construction brush
916 if xmlFile:hasProperty(storeDataXMLKey..".brush") and storeItem.showInStore then
917 local brushType = xmlFile:getValue(storeDataXMLKey..".brush.type")
918
919 if brushType ~= nil and brushType ~= "none" then
920 local parameters = {}
921 xmlFile:iterate(storeDataXMLKey..".brush.parameters.parameter", function(index, key)
922 local value = xmlFile:getValue(key)
923 if xmlFile:getValue(key .. "#isFilename", false) then
924 value = Utils.getFilename(value, baseDir)
925 end
926
927 parameters[index] = value
928 end)
929
930 local brushCategory = self:getConstructionCategoryByName(xmlFile:getValue(storeDataXMLKey..".brush.category"))
931 if brushCategory ~= nil then
932 local tab = self:getConstructionTabByName(xmlFile:getValue(storeDataXMLKey..".brush.tab"), brushCategory.name)
933 if tab ~= nil then
934 storeItem.brush = {
935 type = brushType,
936 parameters = parameters,
937 category = brushCategory,
938 tab = tab,
939 }
940 else
941 Logging.xmlWarning(xmlFile, "Missing brush tab")
942 end
943 else
944 Logging.xmlWarning(xmlFile, "Missing brush category")
945 end
946 end
947
948 -- Placeables without brush just get the default placeable brush
949 elseif storeItem.species == "placeable" and storeItem.showInStore then
950 storeItem.brush = {
951 type = "placeable",
952 parameters = {},
953 category = self.constructionCategories[1],
954 tab = self.constructionCategories[1].tabs[1],
955 }
956 end
957
958 if not ignoreAdd then
959 self:addItem(storeItem)
960
961 for i=1, #bundleItemsToAdd do
962 self:addItem(bundleItemsToAdd[i])
963 end
964 end
965
966 xmlFile:delete()
967
968 return storeItem
969end

loadItemsFromXML

Description
Definition
loadItemsFromXML()
Code
151function StoreManager:loadItemsFromXML(filename, baseDirectory, customEnvironment)
152 local xmlFile = XMLFile.load("storeItemsXML", filename)
153
154 xmlFile:iterate("storeItems.storeItem", function(_, key)
155 local xmlFilename = xmlFile:getString(key.."#xmlFilename")
156 local extraContentId = xmlFile:getString(key.."#extraContentId")
157 g_asyncTaskManager:addSubtask(function()
158 self:loadItem(xmlFilename, baseDirectory, customEnvironment, false, false, "", extraContentId)
159 end)
160 end)
161
162 xmlFile:delete()
163end

loadMapData

Description
Load manager data on map load
Definition
loadMapData()
Return Values
booleantrueif loading was successful else false
Code
55function StoreManager:loadMapData(xmlFile, missionInfo, baseDirectory)
56 StoreManager:superClass().loadMapData(self)
57
58 -- local all store categories
59 local categoryXMLFile = XMLFile.load("storeCategoriesXML", "dataS/storeCategories.xml")
60 categoryXMLFile:iterate("categories.category", function(_, key)
61 self:loadCategoryFromXML(categoryXMLFile, key, "")
62 end)
63 categoryXMLFile:delete()
64
65 -- load store pack definitions
66 local packsXMLFile = XMLFile.load("storePacksXML", "dataS/storePacks.xml")
67 packsXMLFile:iterate("storePacks.storePack", function(_, key)
68 local name = packsXMLFile:getString(key .. "#name")
69 local title = packsXMLFile:getString(key .. "#title")
70 local imageFilename = packsXMLFile:getString(key .. "#image")
71
72 if title ~= nil and title:sub(1, 6) == "$l10n_" then
73 title = g_i18n:getText(title:sub(7))
74 end
75
76 self:addPack(name, title, imageFilename, "")
77 end)
78 packsXMLFile:delete()
79
80 -- also for mods
81 for _, item in ipairs(self.modStorePacks) do
82 self:addPack(item.name, item.title, item.imageFilename, item.baseDir)
83 end
84
85 -- Load categories for the construction system
86 local constructionXMLFile = XMLFile.load("constructionXML", "dataS/constructionCategories.xml")
87 if constructionXMLFile ~= nil then
88 local defaultIconFilename = constructionXMLFile:getString("constructionCategories#defaultIconFilename")
89 local defaultRefSize = constructionXMLFile:getVector("constructionCategories#refSize", {1024, 1024}, 2)
90
91 constructionXMLFile:iterate("constructionCategories.category", function(_, key)
92 local categoryName = constructionXMLFile:getString(key .. "#name")
93 local title = g_i18n:convertText(constructionXMLFile:getString(key .. "#title"))
94 local iconFilename = constructionXMLFile:getString(key .. "#iconFilename") or defaultIconFilename
95 local refSize = constructionXMLFile:getVector(key .. "#refSize", defaultRefSize, 2)
96 local iconUVs = GuiUtils.getUVs(constructionXMLFile:getString(key .. "#iconUVs", "0 0 1 1"), refSize)
97
98 self:addConstructionCategory(categoryName, title, iconFilename, iconUVs, "")
99
100 constructionXMLFile:iterate(key .. ".tab", function(_, tKey)
101 local tabName = constructionXMLFile:getString(tKey .. "#name")
102 local tabTitle = g_i18n:convertText(constructionXMLFile:getString(tKey .. "#title"))
103 local tabIconFilename = constructionXMLFile:getString(tKey .. "#iconFilename") or defaultIconFilename
104 local tabRefSize = constructionXMLFile:getVector(tKey .. "#refSize", defaultRefSize, 2)
105 local tabIconUVs = GuiUtils.getUVs(constructionXMLFile:getString(tKey .. "#iconUVs", "0 0 1 1"), tabRefSize)
106
107 self:addConstructionTab(categoryName, tabName, tabTitle, tabIconFilename, tabIconUVs, "")
108 end)
109 end)
110 constructionXMLFile:delete()
111 end
112
113 -- now load all storeitems
114
115 local storeItemsFilename = self:getDefaultStoreItemsFilename()
116 self:loadItemsFromXML(storeItemsFilename, "", nil)
117
118 if xmlFile ~= nil then
119 local mapStoreItemsFilename = getXMLString(xmlFile, "map.storeItems#filename")
120 if mapStoreItemsFilename ~= nil then
121 mapStoreItemsFilename = Utils.getFilename(mapStoreItemsFilename, baseDirectory)
122 self:loadItemsFromXML(mapStoreItemsFilename, baseDirectory, missionInfo.customEnvironment)
123 end
124 end
125
126 for _, item in ipairs(self.modStoreItems) do
127 g_asyncTaskManager:addSubtask(function()
128 self:loadItem(item.xmlFilename, item.baseDir, item.customEnvironment, item.isMod, item.isBundleItem, item.dlcTitle, item.extraContentId)
129 end)
130 end
131
132 addConsoleCommand("gsStoreItemsReload", "Reloads storeItem data", "consoleCommandReloadStoreItems", self)
133
134 return true
135end

new

Description
Creating manager
Definition
new()
Return Values
tableinstanceinstance of object
Code
25function StoreManager.new(customMt)
26 local self = AbstractManager.new(customMt or StoreManager_mt)
27
28 return self
29end

registerStoreDataXMLPaths

Description
Definition
registerStoreDataXMLPaths()
Code
1089function StoreManager.registerStoreDataXMLPaths(schema, basePath)
1090 schema:register(XMLValueType.L10N_STRING, basePath .. ".storeData.name", "Name of store item", nil, true)
1091 schema:register(XMLValueType.STRING, basePath .. ".storeData.name#params", "Parameters to add to name")
1092 schema:register(XMLValueType.STRING, basePath .. ".storeData.species", "Store species", "vehicle")
1093 schema:register(XMLValueType.STRING, basePath .. ".storeData.image", "Path to store icon", nil, true)
1094 schema:register(XMLValueType.STRING, basePath .. ".storeData.brand", "Brand identifier", "LIZARD")
1095 schema:register(XMLValueType.STRING, basePath .. ".storeData.brand#customIcon", "Custom brand icon to display in the shop config screen")
1096 schema:register(XMLValueType.STRING, basePath .. ".storeData.brand#imageOffset", "Offset of custom brand icon")
1097
1098 schema:register(XMLValueType.BOOL, basePath .. ".storeData.canBeSold", "Defines of the vehicle can be sold", true)
1099 schema:register(XMLValueType.BOOL, basePath .. ".storeData.showInStore", "Defines of the vehicle is shown in shop", true)
1100 schema:register(XMLValueType.BOOL, basePath .. ".storeData.allowLeasing", "Defines of the vehicle can be leased", true)
1101 schema:register(XMLValueType.INT, basePath .. ".storeData.maxItemCount", "Defines the max. amount vehicle of this type")
1102 schema:register(XMLValueType.ANGLE, basePath .. ".storeData.rotation", "Y rotation of the vehicle", 0)
1103
1104 schema:register(XMLValueType.STRING, basePath .. ".storeData.category", "Store category", "misc")
1105 schema:register(XMLValueType.STRING, basePath .. ".storeData.storePacks.storePack(?)", "Store pack")
1106 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.price", "Store price", 10000)
1107 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.dailyUpkeep", "Daily up keep", 0)
1108 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.runningLeasingFactor", "Running leasing factor", EconomyManager.DEFAULT_RUNNING_LEASING_FACTOR)
1109 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.lifetime", "Lifetime of vehicle used to calculate price drop, in months", 600)
1110
1111 schema:register(XMLValueType.BOOL, basePath .. ".storeData.shopDynamicTitle", "Vehicle brand icon and vehicle name is dynamically updated based on the selected configuration in the shop", false)
1112 schema:register(XMLValueType.VECTOR_TRANS, basePath .. ".storeData.shopTranslationOffset", "Translation offset for shop spawning and store icon", 0)
1113 schema:register(XMLValueType.VECTOR_ROT, basePath .. ".storeData.shopRotationOffset", "Rotation offset for shop spawning and store icon", 0)
1114 schema:register(XMLValueType.BOOL, basePath .. ".storeData.shopIgnoreLastComponentPositions", "If set to true the component positions from last spawning are now reused", false)
1115 schema:register(XMLValueType.TIME, basePath .. ".storeData.shopLoadingDelay#initial", "Delay of initial shop loading until the vehicle is displayed. (Used e.g. to hide vehicle while components still moving)")
1116 schema:register(XMLValueType.TIME, basePath .. ".storeData.shopLoadingDelay#config", "Delay of shop loading after config change until the vehicle is displayed. (Used e.g. to hide vehicle while components still moving)")
1117
1118 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.shopHeight", "Height of vehicle for shop placement", 0)
1119 schema:register(XMLValueType.STRING, basePath .. ".storeData.financeCategory", "Finance category name")
1120 schema:register(XMLValueType.INT, basePath .. ".storeData.shopFoldingState", "Inverts the shop folding state if set to '1'", 0)
1121 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.shopFoldingTime", "Defines a custom folding time for the shop")
1122
1123 schema:register(XMLValueType.INT, basePath .. ".storeData.vertexBufferMemoryUsage", "Vertex buffer memory usage", 0)
1124 schema:register(XMLValueType.INT, basePath .. ".storeData.indexBufferMemoryUsage", "Index buffer memory usage", 0)
1125 schema:register(XMLValueType.INT, basePath .. ".storeData.textureMemoryUsage", "Texture memory usage", 0)
1126 schema:register(XMLValueType.INT, basePath .. ".storeData.instanceVertexBufferMemoryUsage", "Instance vertex buffer memory usage", 0)
1127 schema:register(XMLValueType.INT, basePath .. ".storeData.instanceIndexBufferMemoryUsage", "Instance index buffer memory usage", 0)
1128 schema:register(XMLValueType.BOOL, basePath .. ".storeData.ignoreVramUsage", "Ignore VRAM usage", false)
1129 schema:register(XMLValueType.INT, basePath .. ".storeData.audioMemoryUsage", "Audio memory usage", 0)
1130
1131 schema:register(XMLValueType.STRING, basePath .. ".storeData.bundleElements.bundleElement(?).xmlFilename", "XML filename")
1132 schema:register(XMLValueType.VECTOR_TRANS, basePath .. ".storeData.bundleElements.bundleElement(?).offset", "Translation offset of vehicle")
1133 schema:register(XMLValueType.VECTOR_ROT, basePath .. ".storeData.bundleElements.bundleElement(?).rotationOffset", "Rotation offset of vehicle")
1134 schema:register(XMLValueType.ANGLE, basePath .. ".storeData.bundleElements.bundleElement(?).yRotation", "Y rotation of vehicle")
1135
1136 schema:register(XMLValueType.STRING, basePath .. ".storeData.bundleElements.bundleElement(?).configurations.configuration(?)#name", "Name of configuration")
1137 schema:register(XMLValueType.INT, basePath .. ".storeData.bundleElements.bundleElement(?).configurations.configuration(?)#value", "Configuration index that is forced for this config")
1138 schema:register(XMLValueType.BOOL, basePath .. ".storeData.bundleElements.bundleElement(?).configurations.configuration(?)#allowChange", "Allow change of option", false)
1139 schema:register(XMLValueType.BOOL, basePath .. ".storeData.bundleElements.bundleElement(?).configurations.configuration(?)#hideOption", "Hide the option completely", false)
1140 schema:register(XMLValueType.BOOL, basePath .. ".storeData.bundleElements.bundleElement(?).configurations.configuration(?)#disableOption", "Disabled this particular config option", false)
1141
1142 schema:register(XMLValueType.INT, basePath .. ".storeData.attacherInfo.attach(?)#bundleElement0", "First bundle element")
1143 schema:register(XMLValueType.INT, basePath .. ".storeData.attacherInfo.attach(?)#bundleElement1", "Second bundle element")
1144 schema:register(XMLValueType.INT, basePath .. ".storeData.attacherInfo.attach(?)#attacherJointIndex", "Attacher joint index")
1145 schema:register(XMLValueType.INT, basePath .. ".storeData.attacherInfo.attach(?)#inputAttacherJointIndex", "Input attacher joint index")
1146
1147 schema:register(XMLValueType.L10N_STRING, basePath .. ".storeData.functions.function(?)", "Function description text")
1148
1149 schema:register(XMLValueType.STRING, basePath .. ".storeData.brush.type", "Brush type")
1150 schema:register(XMLValueType.STRING, basePath .. ".storeData.brush.category", "Brush category")
1151 schema:register(XMLValueType.STRING, basePath .. ".storeData.brush.tab", "Brush tab")
1152 schema:register(XMLValueType.STRING, basePath .. ".storeData.brush.parameters.parameter(?)", "Brush parameter value")
1153 schema:register(XMLValueType.STRING, basePath .. ".storeData.brush.parameters.parameter(?)#isFilename", "Whether the parameter is a filename")
1154
1155 -- Store Icon Generator - Not used in the game
1156 schema:register(XMLValueType.ANGLE, basePath .. ".storeData.storeIconRendering.settings#cameraYRot", "Y Rot of camera", "Setting from Icon Generator")
1157 schema:register(XMLValueType.ANGLE, basePath .. ".storeData.storeIconRendering.settings#cameraXRot", "X Rot of camera", "Setting from Icon Generator")
1158 schema:register(XMLValueType.BOOL, basePath .. ".storeData.storeIconRendering.settings#advancedBoundingBox", "Advanced BB is used for icon placement", "Setting from Icon Generator")
1159 schema:register(XMLValueType.BOOL, basePath .. ".storeData.storeIconRendering.settings#centerIcon", "Center item on icon", "Setting from Icon Generator")
1160 schema:register(XMLValueType.FLOAT, basePath .. ".storeData.storeIconRendering.settings#lightIntensity", "Intensity of light sources", "Setting from Icon Generator")
1161 schema:register(XMLValueType.BOOL, basePath .. ".storeData.storeIconRendering.settings#showTriggerMarkers", "Show trigger markers on icon (for placeables)", false)
1162
1163 schema:register(XMLValueType.BOOL, basePath .. ".storeData.storeIconRendering.objectBundle#useClipPlane", "Clip plane is used")
1164 schema:register(XMLValueType.STRING, basePath .. ".storeData.storeIconRendering.objectBundle.object(?)#filename", "Path to i3d file")
1165 schema:register(XMLValueType.NODE_INDEX, basePath .. ".storeData.storeIconRendering.objectBundle.object(?).node(?)#node", "Index Path of node to load")
1166 schema:register(XMLValueType.VECTOR_TRANS, basePath .. ".storeData.storeIconRendering.objectBundle.object(?).node(?)#translation", "Translation", "0 0 0")
1167 schema:register(XMLValueType.VECTOR_ROT, basePath .. ".storeData.storeIconRendering.objectBundle.object(?).node(?)#rotation", "Rotation", "0 0 0")
1168 schema:register(XMLValueType.VECTOR_SCALE, basePath .. ".storeData.storeIconRendering.objectBundle.object(?).node(?)#scale", "Scale", "1 1 1")
1169
1170 schema:register(XMLValueType.STRING, basePath .. ".storeData.storeIconRendering.shaderParameter(?)#name", "Name if shader parameter")
1171 schema:register(XMLValueType.STRING, basePath .. ".storeData.storeIconRendering.shaderParameter(?)#values", "Values of shader parameter")
1172
1173end

removeCategory

Description
Removes a store category
Definition
removeCategory(string name)
Arguments
stringnamecategory index name
Code
243function StoreManager:removeCategory(name)
244 if not ClassUtil.getIsValidIndexName(name) then
245 print("Warning: '"..tostring(name).."' is no valid name for a category!")
246 return
247 end
248
249 name = name:upper()
250
251 for _, item in pairs(self.items) do
252 if item.category == name then
253 item.category = "MISC"
254 end
255 end
256 self.categories[name] = nil
257end

removeItemByIndex

Description
Removes a storeitem by index
Definition
removeItemByIndex(integer index)
Arguments
integerindexstoreitem index
Code
442function StoreManager:removeItemByIndex(index)
443 local item = self.items[index]
444 if item ~= nil then
445 self.xmlFilenameToItem[item.xmlFilenameLower] = nil
446
447 -- item.id must always match the index in the arry, thus swap the last to the removed position and reduce size
448 local numItems = table.getn(self.items)
449 if index < numItems then
450 self.items[index] = self.items[numItems]
451 self.items[index].id = index
452 end
453 table.remove(self.items, numItems)
454 end
455end

unloadMapData

Description
Unload data on mission delete
Definition
unloadMapData()
Code
139function StoreManager:unloadMapData()
140 StoreManager:superClass().unloadMapData(self)
141
142 removeConsoleCommand("gsStoreItemsReload")
143end