e4s-sdk/gamedata/scripts/ui_si.script
2026-06-17 23:06:51 +03:00

410 lines
11 KiB
Text

local artefacts_table = {
"af_medusa",
"af_cristall_flower",
"af_night_star",
"af_vyvert",
"af_gravi",
"af_gold_fish",
"af_cristall",
"af_fireball",
"af_dummy_glassbeads",
"af_eye",
"af_fire",
"af_blood",
"af_mincer_meat",
"af_soul",
"af_fuzz_kolobok",
"af_baloon",
"af_glass",
"af_electra_sparkler",
"af_electra_flash",
"af_electra_moonlight",
"af_dummy_battery",
"af_dummy_dummy",
"af_ice",
"af_compass",
"af_oasis_heart",
"jup_b1_half_artifact",
"af_quest_b14_twisted",
}
local outfits_table = {
"helm_respirator",
"helm_hardhat",
"helm_protective",
"helm_tactic",
"helm_battle",
"helm_respirator_joker",
"helm_hardhat_snag",
"novice_outfit",
"stalker_outfit",
"svoboda_light_outfit",
"dolg_outfit",
"scientific_outfit",
"cs_heavy_outfit",
"svoboda_heavy_outfit",
"specops_outfit",
"military_outfit",
"dolg_heavy_outfit",
"exo_outfit",
"stalker_outfit_barge",
}
local devices_table = {
"device_torch",
"detector_simple",
"detector_advanced",
"detector_elite",
"detector_scientific",
}
local food_and_drugs_table = {
"bandage",
"antirad",
"medkit",
"medkit_army",
"medkit_scientic",
"drug_booster",
"drug_coagulant",
"drug_psy_blockade",
"drug_antidot",
"drug_radioprotector",
"drug_anabiotic",
"bread",
"kolbasa",
"conserva",
"vodka",
"energy_drink",
}
local wpn_addons_table = {
"wpn_addon_scope",
"wpn_addon_scope_x2.7",
"wpn_addon_scope_detector",
"wpn_addon_scope_night",
"wpn_addon_scope_susat",
"wpn_addon_scope_susat_x1.6",
"wpn_addon_scope_susat_custom",
"wpn_addon_scope_susat_dusk",
"wpn_addon_scope_susat_night",
"wpn_addon_silencer",
"wpn_addon_grenade_launcher",
"wpn_addon_grenade_launcher_m203",
}
local weapons_table = {
"wpn_pm",
"wpn_pb",
"wpn_fort",
"wpn_hpsa",
"wpn_beretta",
"wpn_walther",
"wpn_sig220",
"wpn_colt1911",
"wpn_usp",
"wpn_desert_eagle",
"wpn_bm16",
"wpn_toz34",
"wpn_wincheaster1300",
"wpn_spas12",
"wpn_protecta",
"wpn_ak74u",
"wpn_mp5",
"wpn_ak74",
"wpn_abakan",
"wpn_l85",
"wpn_lr300",
"wpn_sig550",
"wpn_groza",
"wpn_val",
"wpn_vintorez",
"wpn_svu",
"wpn_svd",
"wpn_rg-6",
"wpn_rpg7",
"wpn_g36",
"wpn_fn2000",
"wpn_pkm",
"wpn_gauss",
"wpn_pm_actor",
"wpn_fort_snag",
"wpn_sig220_nimble",
"wpn_usp_nimble",
"wpn_desert_eagle_nimble",
"wpn_wincheaster1300_trapper",
"wpn_spas12_nimble",
"wpn_protecta_nimble",
"wpn_ak74u_snag",
"wpn_mp5_nimble",
"wpn_sig550_luckygun",
"wpn_groza_nimble",
"wpn_vintorez_nimble",
"wpn_svu_nimble",
"wpn_svd_nimble",
"wpn_g36_nimble",
"wpn_fn2000_nimble",
"wpn_pkm_zulus",
"pri_a17_gauss_rifle",
"grenade_f1",
"grenade_rgd5",
"grenade_gd-05",
}
local info_table ={
"jup_a9_conservation_info",
"jup_a9_power_info",
"jup_a9_way_info",
"jup_a9_evacuation_info",
"jup_a9_meeting_info",
"jup_a9_losses_info",
"jup_a9_delivery_info",
"jup_b10_ufo_memory",
"jup_b10_ufo_memory_2",
"jup_b10_notes_01",
"jup_b10_notes_02",
"jup_b10_notes_03",
"jup_b205_sokolov_note",
"jup_b206_plant",
"jup_b209_monster_scanner",
"jup_b200_tech_materials_wire",
"jup_b200_tech_materials_acetone",
"jup_b200_tech_materials_textolite",
"jup_b200_tech_materials_transistor",
"jup_b200_tech_materials_capacitor",
"jup_b202_bandit_pda",
"device_flash_snag",
"jup_b9_blackbox",
"jup_b32_scanner_device",
"jup_b46_duty_founder_pda",
"jup_b207_merc_pda_with_contract",
"jup_b47_jupiter_products_info",
"jup_b47_merc_pda",
"toolkit_1",
"toolkit_2",
"toolkit_3",
"zat_b33_safe_container",
"zat_b57_gas",
"zat_b12_key_1",
"zat_b12_key_2",
"zat_b12_documents_1",
"zat_b12_documents_2",
"device_pda_port_bandit_leader",
"zat_b40_notebook",
"zat_b40_pda_1",
"zat_b40_pda_2",
"device_pda_zat_b5_dealer",
"zat_b20_noah_pda",
"zat_a23_access_card",
"zat_a23_gauss_rifle_docs",
"zat_b44_barge_pda",
"zat_b39_joker_pda",
"zat_b22_medic_pda",
"pri_b35_lab_x8_key",
"pri_b306_envoy_pda",
"pri_b36_monolith_hiding_place_pda",
"pri_a25_explosive_charge_item",
"pri_a19_american_experiment_info",
"pri_a19_lab_x16_info",
"pri_a19_lab_x10_info",
"pri_a19_lab_x7_info",
"pri_a19_lab_x18_info",
"zat_a23_labx8_key",
"lx8_service_instruction"
}
local ammo_table = {
"ammo_9x18_fmj",
"ammo_9x18_pmm",
"ammo_9x19_fmj",
"ammo_9x19_pbp",
"ammo_11.43x23_fmj",
"ammo_11.43x23_hydro",
"ammo_5.45x39_fmj",
"ammo_5.45x39_ap",
"ammo_5.56x45_ss190",
"ammo_5.56x45_ap",
"ammo_pkm_100",
"ammo_7.62x54_7h1",
"ammo_gauss",
"ammo_gauss_cardan",
"ammo_9x39_pab9",
"ammo_9x39_ap",
"ammo_12x70_buck",
"ammo_12x76_zhekan",
"ammo_og-7b",
"ammo_vog-25",
"ammo_m209",
}
class "spawn_item" (CUIListBoxItem)
function spawn_item:__init(height) super(height)
self.text = self:GetTextItem()
self:SetTextColor (GetARGB(255, 210, 210, 210))
self.text:SetFont (GetFontLetterica18Russian())
self.text:SetWndSize (vector2():set(400,height))
self.text:SetEllipsis (true)
end
class "spawn_item_dialog" (CUIScriptWnd)
function spawn_item_dialog:__init() super()
self:InitControls ()
self:InitCallBacks ()
self:FillList (weapons_table)
end
function spawn_item_dialog:__finalize()
end
function spawn_item_dialog:FillList(tbl)
self.list:Clear()
for i = 1, #tbl do
self:AddItemToList(tbl[i])
end
end
function spawn_item_dialog:InitControls()
local xml = CScriptXmlInit()
local ctrl
xml:ParseFile ("ui_spawn_dlg.xml")
ctrl = xml:InitFrame("background",self)
self:SetWndPos (vector2():set(100,100))
self:SetWndSize (vector2():set(ctrl:GetWidth(), ctrl:GetHeight()))
ctrl = xml:Init3tButton("btn_weapons",self)
self:Register (ctrl, "btn_weapons")
ctrl = xml:Init3tButton("btn_addons",self)
self:Register (ctrl, "btn_addons")
ctrl = xml:Init3tButton("btn_outfits",self)
self:Register (ctrl, "btn_outfits")
ctrl = xml:Init3tButton("btn_devices",self)
self:Register (ctrl, "btn_devices")
ctrl = xml:Init3tButton("btn_ammo",self)
self:Register (ctrl, "btn_ammo")
ctrl = xml:Init3tButton("btn_artefacts",self)
self:Register (ctrl, "btn_artefacts")
ctrl = xml:Init3tButton("btn_food",self)
self:Register (ctrl, "btn_food")
ctrl = xml:Init3tButton("btn_info",self)
self:Register (ctrl, "btn_info")
self.list = xml:InitListBox ("list",self)
self.list:ShowSelectedItem (true)
self:Register (self.list, "list_window")
self.check = xml:InitCheck("check_own_to_actor",self)
self.check:SetCheck (true)
ctrl = xml:Init3tButton("btn_create",self)
self:Register (ctrl, "btn_create")
ctrl = xml:Init3tButton ("btn_close",self)
self:Register (ctrl, "btn_close")
end
function spawn_item_dialog:InitCallBacks()
self:AddCallback("btn_create", ui_events.BUTTON_CLICKED, self.OnButton_create_clicked, self)
self:AddCallback("btn_close", ui_events.BUTTON_CLICKED, self.OnButton_close_clicked, self)
self:AddCallback("list_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnButton_create_clicked, self)
self:AddCallback("btn_artefacts", ui_events.BUTTON_CLICKED, self.OnButton_artefacts_clicked, self)
self:AddCallback("btn_outfits", ui_events.BUTTON_CLICKED, self.OnButton_outfits_clicked, self)
self:AddCallback("btn_devices", ui_events.BUTTON_CLICKED, self.OnButton_devices_clicked, self)
self:AddCallback("btn_food", ui_events.BUTTON_CLICKED, self.OnButton_food_clicked, self)
self:AddCallback("btn_weapons", ui_events.BUTTON_CLICKED, self.OnButton_weapons_clicked, self)
self:AddCallback("btn_addons", ui_events.BUTTON_CLICKED, self.OnButton_addons_clicked, self)
self:AddCallback("btn_info", ui_events.BUTTON_CLICKED, self.OnButton_info_clicked, self)
self:AddCallback("btn_ammo", ui_events.BUTTON_CLICKED, self.OnButton_ammo_clicked, self)
end
function spawn_item_dialog:OnButton_artefacts_clicked()
self:FillList(artefacts_table)
end
function spawn_item_dialog:OnButton_outfits_clicked()
self:FillList(outfits_table)
end
function spawn_item_dialog:OnButton_devices_clicked()
self:FillList(devices_table)
end
function spawn_item_dialog:OnButton_food_clicked()
self:FillList(food_and_drugs_table)
end
function spawn_item_dialog:OnButton_weapons_clicked()
self:FillList(weapons_table)
end
function spawn_item_dialog:OnButton_addons_clicked()
self:FillList(wpn_addons_table)
end
function spawn_item_dialog:OnButton_info_clicked()
self:FillList(info_table)
end
function spawn_item_dialog:OnButton_ammo_clicked()
self:FillList(ammo_table)
end
function spawn_item_dialog:OnButton_create_clicked()
if self.list:GetSize()==0 then
return
end
local item
item = self.list:GetSelectedItem()
if not(item) then
return
end
local itmname = item.text:GetText()
local id
if self.check:GetCheck() then
id = db.actor:id()
else
id = -1
end
alife():create(itmname, db.actor:position(), 0, 0, id)
end
function spawn_item_dialog:OnButton_close_clicked()
self:HideDialog()
_G.si_dlg = nil
end
function spawn_item_dialog:OnKeyboard(dik, keyboard_action)
CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
local bind = dik_to_bind(dik)
if bind == key_bindings.kQUIT then
self:OnButton_close_clicked()
else
if dik==28 then
self:OnButton_create_clicked()
end
end
return true
end
function spawn_item_dialog:AddItemToList(item_name)
local _itm = spawn_item(22)
_itm.text:SetText (item_name)
self.list:AddExistingItem (_itm)
end
function main()
if _G.si_dlg==nil then
_G.si_dlg = spawn_item_dialog()
end
_G.si_dlg:ShowDialog(true)
end