Skip to content

Commit

Permalink
feat: NpcSaleData (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokekanon authored Oct 29, 2024
1 parent 75f0240 commit 130d909
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 4,985 deletions.
6 changes: 1 addition & 5 deletions modules/game_cyclopedia/cyclopedia_widgets.otui
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ CharacterGridItem < UIWidget
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
image-source: /images/ui/item
UIWidget
id: rarity
margin: 1
anchors.fill: ItemBackground
UIItem
Item
id: item
anchors.fill: ItemBackground
Label
Expand Down
2 changes: 2 additions & 0 deletions modules/game_cyclopedia/tab/character/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ function Cyclopedia.reloadCharacterItems()
local gridItem = g_ui.createWidget("CharacterGridItem", UI.CharacterItems.gridBase.grid)
gridItem.item:setItemId(itemId)
gridItem.amount:setText(data.amount)
ItemsDatabase.setRarityItem(gridItem.item, gridItem.item:getItem())
ItemsDatabase.setTier(gridItem.item, item.tier)
colorIndex = 3 - colorIndex
end
end
Expand Down
4 changes: 2 additions & 2 deletions modules/game_cyclopedia/tab/character/character.otui
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ UIWidget
id: gridBase
size: 494 340
anchors.bottom: parent.bottom
anchors.left: parentl.left
anchors.left: parent.left
visible: false
UIScrollArea
id: grid
Expand Down Expand Up @@ -1297,7 +1297,7 @@ UIWidget
height: 55
anchors.top: parent.top
anchors.left: parent.left
anchors.right: ListBase.right
anchors.right: parent.right
image-source: /images/game/actionbar/2pixel-up-frame-borderimage
image-border: 5
CheckBox
Expand Down
24 changes: 18 additions & 6 deletions modules/game_cyclopedia/tab/items/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,29 @@ function Cyclopedia.internalCreateItem(data)
item:setId(data:getId())
item.Sprite:setItemId(data:getId())
item.Name:setText(marketData.name)

local price, rarity = ItemsDatabase.getSellValueAndColor(data:getId())
local function getColorForValue(value)
if value >= 1000000 then
return "yellow"
elseif value >= 100000 then
return "purple"
elseif value >= 10000 then
return "blue"
elseif value >= 1000 then
return "green"
elseif value >= 50 then
return "grey"
end
return "white"
end
local price = data:getMeanPrice()
local rarity = getColorForValue(price)
item.Value = price
item.Vocation = marketData.restrictVocation

if price > 0 then
item.Rarity:setImageSource("/images/ui/rarity_" .. rarity)
end

ItemsDatabase.setRarityItem(item.Sprite, item)

function item.onClick(widget)
UI.InfoBase.SellBase.List:destroyChildren()
UI.InfoBase.BuyBase.List:destroyChildren()
Expand Down Expand Up @@ -277,7 +289,7 @@ function Cyclopedia.internalCreateItem(data)
end
end

--[[ local buy, sell = Cyclopedia.formatSaleData(internalData:getNpcSaleData())
local buy, sell = Cyclopedia.formatSaleData(internalData:getNpcSaleData())
local sellColor = "#484848"

for index, value in ipairs(sell) do
Expand Down Expand Up @@ -318,7 +330,7 @@ function Cyclopedia.internalCreateItem(data)
end

buyColor = buyColor == "#484848" and "#414141" or "#484848"
end ]]
end

UI.selectItem = widget
end
Expand Down
10 changes: 5 additions & 5 deletions modules/game_cyclopedia/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ end
function Cyclopedia.formatSaleData(data)
local s, sell, b, buy = {}, {}, {}, {}

for i = 0, #data do
for i = 1, #data do
local value = data[i]

if value then
Expand Down Expand Up @@ -1569,18 +1569,18 @@ function Cyclopedia.formatSaleData(data)
for name, value in pairs(s) do
if value.various then
table.insert(sell,
string.format("%s gp, %s\nResidence: %s", formatGold(value.price), name, "Various Locations"))
string.format("%s gp, %s\nResidence: %s", Cyclopedia.formatGold(value.price), name, "Various Locations"))
else
table.insert(sell, string.format("%s gp, %s\nResidence: %s", formatGold(value.price), name, value.location))
table.insert(sell, string.format("%s gp, %s\nResidence: %s", Cyclopedia.formatGold(value.price), name, value.location))
end
end

for name, value in pairs(b) do
if value.various then
table.insert(buy,
string.format("%s gp, %s\nResidence: %s", formatGold(value.price), name, "Various Locations"))
string.format("%s gp, %s\nResidence: %s", Cyclopedia.formatGold(value.price), name, "Various Locations"))
else
table.insert(buy, string.format("%s gp, %s\nResidence: %s", formatGold(value.price), name, value.location))
table.insert(buy, string.format("%s gp, %s\nResidence: %s", Cyclopedia.formatGold(value.price), name, value.location))
end
end

Expand Down
8 changes: 6 additions & 2 deletions modules/game_textmessage/textmessage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ function displayMessage(mode, text)
if msgtype.screenTarget then
local label = messagesPanel:recursiveGetChildById(msgtype.screenTarget)
if msgtype == MessageSettings.loot then
label:setColoredText(ItemsDatabase.setColorLootMessage(text)) -- temp. TODO assets search
else
local coloredText = ItemsDatabase.setColorLootMessage(text)
label:setColoredText(coloredText)
local console = modules.game_console
local consoleBuffer = console.consoleTabBar:getTabPanel(console.getTab("Server Log")):getChildById('consoleBuffer')
consoleBuffer:getLastChild():setColoredText(coloredText)
else
label:setText(text)
label:setColor(msgtype.color)
end
Expand Down
3 changes: 2 additions & 1 deletion modules/gamelib/const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ TextColors = {
-- blue1 = '#6e50dc',
-- blue2 = '#3264c8',
-- blue3 = '#0096c8',
white = '#ffffff' -- '#bebebe'
white = '#ffffff', -- '#bebebe'
grey = '#AAAAAA'
}

MessageModes = {
Expand Down
Loading

0 comments on commit 130d909

Please sign in to comment.