Added, Updated and Removed Mods; Removed Backups
This commit is contained in:
@@ -42,7 +42,17 @@ function get_desc(name)
|
||||
end
|
||||
|
||||
function npc_has_barter(npc)
|
||||
local name = npc and npc:section() or ""
|
||||
local name = ""
|
||||
if type(npc) == "string" then
|
||||
-- two cases for sid and forester
|
||||
if npc == "esc_2_12_stalker_trader" then name = "m_trader"
|
||||
elseif npc == "red_forester_tech" then name = "m_lesnik"
|
||||
else
|
||||
name = npc
|
||||
end
|
||||
else
|
||||
name = npc and npc:section() or ""
|
||||
end
|
||||
return trader_to_barter[name] and not is_empty(trader_to_barter[name])
|
||||
end
|
||||
|
||||
@@ -112,6 +122,7 @@ end
|
||||
|
||||
-- get barter list with data on each barter
|
||||
function get_barter_list(npc, random)
|
||||
printf("Checking barters for %s", npc:section())
|
||||
if not npc_has_barter(npc) then return {} end
|
||||
local name = npc:section()
|
||||
print_dbg("Fetching list for %s", npc:character_name())
|
||||
@@ -641,13 +652,11 @@ local function load_state(mdata)
|
||||
end
|
||||
|
||||
|
||||
function actor_on_first_update()
|
||||
validate_barters()
|
||||
end
|
||||
|
||||
function on_game_start()
|
||||
RegisterScriptCallback("save_state",save_state)
|
||||
RegisterScriptCallback("load_state",load_state)
|
||||
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
|
||||
RegisterScriptCallback("trader_on_restock", trader_on_restock)
|
||||
validate_barters()
|
||||
end
|
||||
@@ -30,48 +30,50 @@ function start()
|
||||
end
|
||||
end
|
||||
|
||||
function ui_inventory.UIInventory:InitBarterButton()
|
||||
self.npc_barter_btn = self.xml:Init3tButton("npc:trade_delimiter:trade_buy_button", self.npc_trade)
|
||||
local weight = self.npc_trade_weight:GetWndPos()
|
||||
-- printf("trade button at %s %s, delimter at %s %s", pos.x, pos.y, rcoord.x, rcoord.y)
|
||||
local pos = self.npc_barter_btn:GetWndPos()
|
||||
|
||||
self.npc_barter_btn:SetWndPos(vector2():set(
|
||||
weight.x + 20 , -- TODO: Add sliders in MCM to adjust button position
|
||||
pos.y
|
||||
))
|
||||
|
||||
self.npc_barter_btn:TextControl():SetText(game.translate_string("st_ui_mm_barter"))
|
||||
|
||||
self:Register(self.npc_barter_btn, "barter")
|
||||
|
||||
self:InitBarterButtonCallback()
|
||||
|
||||
local npc = mob_trade.GetTalkingNpc()
|
||||
local enable = npc_has_barter(npc)
|
||||
self.npc_barter_btn:Enable(enable)
|
||||
|
||||
end
|
||||
|
||||
function ui_inventory.UIInventory:InitBarterButtonCallback()
|
||||
self:AddCallback("barter", ui_events.BUTTON_CLICKED, start, self)
|
||||
end
|
||||
|
||||
function GUI_on_show(name, path)
|
||||
local instance = ui_inventory.GUI
|
||||
if name ~= "UIInventory" or (not instance ) then return end
|
||||
|
||||
if (not instance.npc_barter_btn) then
|
||||
instance:InitBarterButton()
|
||||
end
|
||||
local partner = instance:GetPartner()
|
||||
instance.npc_barter_btn:Show(partner and npc_has_barter(partner))
|
||||
end
|
||||
|
||||
function on_game_start()
|
||||
RegisterScriptCallback("GUI_on_show", GUI_on_show)
|
||||
RegisterScriptCallback("on_specific_character_dialog_list", function(character_id, dialog_list)
|
||||
if npc_has_barter(character_id) then
|
||||
local res = dialog_list:add("dm_init_barter", 2)
|
||||
end
|
||||
end)
|
||||
end
|
||||
-- function ui_inventory.UIInventory:InitBarterButton()
|
||||
-- self.npc_barter_btn = self.xml:Init3tButton("npc:trade_delimiter:trade_buy_button", self.npc_trade)
|
||||
-- local weight = self.npc_trade_weight:GetWndPos()
|
||||
-- -- printf("trade button at %s %s, delimter at %s %s", pos.x, pos.y, rcoord.x, rcoord.y)
|
||||
-- local pos = self.npc_barter_btn:GetWndPos()
|
||||
|
||||
-- self.npc_barter_btn:SetWndPos(vector2():set(
|
||||
-- weight.x + 20 , -- TODO: Add sliders in MCM to adjust button position
|
||||
-- pos.y
|
||||
-- ))
|
||||
|
||||
-- self.npc_barter_btn:TextControl():SetText(game.translate_string("st_ui_mm_barter"))
|
||||
|
||||
-- self:Register(self.npc_barter_btn, "barter")
|
||||
|
||||
-- self:InitBarterButtonCallback()
|
||||
|
||||
-- local npc = mob_trade.GetTalkingNpc()
|
||||
-- local enable = npc_has_barter(npc)
|
||||
-- self.npc_barter_btn:Enable(enable)
|
||||
|
||||
-- end
|
||||
|
||||
-- function ui_inventory.UIInventory:InitBarterButtonCallback()
|
||||
-- self:AddCallback("barter", ui_events.BUTTON_CLICKED, start, self)
|
||||
-- end
|
||||
|
||||
-- function GUI_on_show(name, path)
|
||||
-- local instance = ui_inventory.GUI
|
||||
-- if name ~= "UIInventory" or (not instance ) then return end
|
||||
|
||||
-- if (not instance.npc_barter_btn) then
|
||||
-- instance:InitBarterButton()
|
||||
-- end
|
||||
-- local partner = instance:GetPartner()
|
||||
-- instance.npc_barter_btn:Show(partner and npc_has_barter(partner))
|
||||
-- end
|
||||
----------------------------------------------------------------------
|
||||
-- UI
|
||||
----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
function on_xml_read()
|
||||
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
|
||||
-- XML file i want to change
|
||||
local xml_to_change = [[gameplay\dialogs.xml]]
|
||||
|
||||
-- Check if its the file i want to change
|
||||
if xml_file_name == xml_to_change then
|
||||
-- Here is my code to change XML
|
||||
local barter_dialog =
|
||||
[[
|
||||
|
||||
<dialog id="dm_init_barter">
|
||||
<phrase_list>
|
||||
<phrase id="0">
|
||||
<text>st_barter_init</text>
|
||||
<next>1</next>
|
||||
</phrase>
|
||||
<phrase id="1"> <!-- npc -->
|
||||
<script_text>dialogs.st_trader_dialog_reply</script_text>
|
||||
<action>barter_ui.start</action>
|
||||
</phrase>
|
||||
</phrase_list>
|
||||
</dialog>
|
||||
]]
|
||||
xml_obj:insertFromXMLString(barter_dialog)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user