Skip to content

Commit

Permalink
Upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverfeelin committed Aug 11, 2017
1 parent e6c471e commit ae09193
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ SpawnableItemFetcher/.vs
SpawnableItemFetcher/SpawnableItemFetcher/bin/*
SpawnableItemFetcher/SpawnableItemFetcher/obj/*
SpawnableItemFetcher/SpawnableItemFetcher/SpawnableItemFetcher.csproj.user

.tags
2 changes: 1 addition & 1 deletion .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"QuickbarMini",
"StardustLib"
],
"version" : "1.3.2.3",
"version" : "1.3.2.4",
"link" : "steam://url/CommunityFilePage/733665104",
"steamContentId" : "733665104"
}
Binary file modified interface/sip/print.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interface/sip/recipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 16 additions & 3 deletions interface/sip/sip.config
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"hover": "/interface/sip/print.png?brightness=30",
"zlevel": 20,
"pressedOffset": [0, -1],
"position": [202, 25],
"position": [222, 25],
"callback": "sip.callback.print"
},
"sipImagePrintAmount": {
Expand Down Expand Up @@ -165,10 +165,21 @@
"zlevel": 20,
"pressedOffset": [0, -1],
"disabled": true,
"position": [287, 25],
"position": [200, 25],
"callback": "sip.callback.printBlueprint"
},

"buttonPrintUpgrade":{
"type": "button",
"base": "/interface/sip/upgrade.png",
"hover": "/interface/sip/upgrade.png?brightness=30",
"zlevel": 20,
"pressedOffset": [0, -1],
"disabled": true,
"position": [288, 25],
"callback": "sip.callback.printUpgrade"
},

"sipImageSearch": {
"type": "image",
"file": "/interface/sip/search.png",
Expand Down Expand Up @@ -1122,6 +1133,7 @@
"sip.callback.selectItem",
"sip.callback.print",
"sip.callback.printBlueprint",
"sip.callback.printUpgrade",
"sip.callback.changeQuantity",
"sip.callback.selectCategory",
"sip.callback.changeWeaponLevel",
Expand Down Expand Up @@ -1183,7 +1195,8 @@
"electric": 4
},
"labelClothingColor": "paneClothing.labelColor",
"blueprint": "buttonPrintBlueprint"
"blueprint": "buttonPrintBlueprint",
"upgrade": "buttonPrintUpgrade"
},
"knownCategories": {
"items": [
Expand Down
Binary file added interface/sip/upgrade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
349 changes: 349 additions & 0 deletions readme/sip.pdn

Large diffs are not rendered by default.

Binary file modified readme/sip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions scripts/sip_callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ function sip.callback.selectItem()
local rarity = sip.item.rarity and sip.item.rarity:lower() or "common"
widget.setImage(sip.widgets.itemRarity, sip.rarityImages.flags[rarity])

-- Blueprint
widget.setButtonEnabled(sip.widgets.blueprint, sip_util.hasBlueprint(sip.item.name))

-- Item slot
sip.randomizeItem()
sip.showSpecifications(config)
Expand Down Expand Up @@ -134,6 +131,17 @@ function sip.callback.print()
sip.spawnItem(cfg.config, q)
end

--- Spawns the upgraded version of the item.
function sip.callback.printUpgrade()
local item, q = sip.item, sip.getQuantity()
if not item or not item.name then return end

local cfg = root.itemConfig(item.name)
if not sip_util.isUpgradeable(cfg.config) then return end

sip.spawnItem(cfg.config, q, true)
end

--- Spawns a recipe for the current item, if the item supports a recipe.
function sip.callback.printBlueprint()
local item = sip.item
Expand Down
33 changes: 33 additions & 0 deletions scripts/sip_util.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "/scripts/util.lua"

sip_util = {}

--- Returns a value indicating whether an item has color options.
Expand Down Expand Up @@ -32,11 +34,42 @@ function sip_util.isLevelableWeapon(itemConfig)
end

--- Returns a value indicating whether the item has an unlockable blueprint
-- @param itemName Name of the item.
-- @return True if the
function sip_util.hasBlueprint(itemName)
if type(itemName) ~= "string" then return false end
return not not root.itemConfig(itemName .. "-recipe")
end

--- Returns a value indicating whether the item can be upgraded.
-- @param itemConfig Item configuration(root.itemConfig().config).
-- @return True if the item can be upgraded.
function sip_util.isUpgradeable(itemConfig)
if not itemConfig then return false end
return not not itemConfig.upgradeParameters
end


--- Upgrades item by merging the upgrade parameters from the item config.
-- If the item can't be upgraded, only the level will be upgraded.
-- @param item Item descriptor to upgrade. Object is directly modified.
-- @param itemConfig Item configuration (root.itemConfig().config).
-- @param[opt=6] level Item level.
function sip_util.upgradeItem(item, itemConfig, level)
if not item or not itemConfig then return end
level = type(level) == "number" and level or 6
item.parameters = item.parameters or {}

-- Merge upgrade
local u = itemConfig.upgradeParameters
if u then
item.parameters = util.mergeTable(item.parameters, u)
end

-- Force level
item.parameters.level = level
end

--- Filters the item list by categories.
-- Categories are identified by name, and are case insensitive.
-- @param list Item table, as stored in the item dump.
Expand Down
14 changes: 13 additions & 1 deletion scripts/spawnableItemPack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sip = spawnableItemPack

-- Utility methods
require "/scripts/sip_util.lua"
require "/scripts/util.lua"

-- Define callbacks
require "/scripts/sip_callback.lua"
Expand Down Expand Up @@ -290,11 +291,17 @@ end
--- Spawns the selected item in the given quantity.
-- The item in the item slot is used.
-- @param[opt] itemConfig Item configuration (root.itemConfig().config).
-- Used for max stack and upgrade parameters.
-- @param[opt=1] quantity Amount of items to spawn. If maxStack = 1, then 1.
function sip.spawnItem(itemConfig, quantity)
-- @param[opt=false] upgrade If true, merges the upgrade parameters on top of the item.
function sip.spawnItem(itemConfig, quantity, upgrade)
quantity = quantity or 1
local item = widget.itemSlotItem(sip.widgets.itemSlot)

if upgrade then
sip_util.upgradeItem(item, itemConfig, sip.getWeaponLevel())
end

if not itemConfig then
itemConfig = root.itemConfig(item.name)
itemConfig = itemConfig and itemConfig.config or {}
Expand Down Expand Up @@ -414,6 +421,11 @@ function sip.showSpecifications(itemConfig)
sip.weaponLevel = sip.getWeaponLevel()
end

-- Blueprint
widget.setButtonEnabled(sip.widgets.blueprint, itemConfig and sip_util.hasBlueprint(sip.item.name))
-- Upgrade
widget.setButtonEnabled(sip.widgets.upgrade, itemConfig and sip_util.isUpgradeable(itemConfig))

-- Show the proper pane and hide other panes.
for _,v in pairs(sip.widgets.specificationPanes) do
widget.setVisible(v, pane == v)
Expand Down

0 comments on commit ae09193

Please sign in to comment.