-- Extensions to Game Options --- IMPORTANT! SEE opt_menu_on_init to add a new game options (new as of 5/28/2016) function opt_menu_on_init(menu) -- simply add new line and a ui_mm_ in ui_st_mm.xml to create a new option. Script automatically does the rest for you -- debug_hud menu.gameplay_options["debug_hud"] = {default=false, debug_only=true, typ="check", on_accept=function(handler,optMgr,ctrl) if (level.present() and xrs_debug_tools) then if (ctrl:GetCheck()) then xrs_debug_tools.activate_feature() else xrs_debug_tools.deactivate_feature() end end end } -- localization local localization_list = {} local flist = getFS():file_list_open("$game_text$",bit_or(FS.FS_ListFolders,FS.FS_RootOnly)) local f_cnt = flist:Size() for it=0, f_cnt-1 do localization_list[#localization_list+1] = flist:GetAt(it):sub(1,-2) end menu.gameplay_options["localization"] = {default="rus", debug_only=false, typ="list", list=localization_list, on_accept=function(handler,optMgr,ctrl) local language = ctrl:GetText() if (language and language ~= "") then local loc_ini = ini_file_ex("localization.ltx",true) if (loc_ini:r_value("string_table","language") ~= language) then loc_ini:w_value("string_table","language",language) loc_ini:save() menu.b__require_restart = true -- reload_system_ini() -- game.reload_language() end end end } -- slot Hud if (slot_hud) then menu.gameplay_ui_options["slot_hud"] = {default=false, debug_only=false, typ="check", on_accept=function(handler,optMgr,ctrl) if (level.present() and slot_hud) then if (ctrl:GetCheck()) then slot_hud.activate_hud() else slot_hud.deactivate_hud() end end end} end -- enable_actor_hit menu.gameplay_options["actor_hit"] = {default=true, debug_only=false, typ="check"} -- enable_actor_bleeding menu.gameplay_options["actor_bleeding"] = {default=true, debug_only=false, typ="check"} -- enable_actor_effects -- menu.gameplay_options["actor_effects"] = {default=true, debug_only=false, typ="check"} -- show_enemy_health menu.gameplay_ui_options["show_enemy_health"] = {default=true, debug_only=true, typ="check"} -- release dropped items menu.gameplay_options["release_dropped_items"] = {default=true, debug_only=false, typ="check"} -- radio_mod menu.gameplay_options["radio_mod"] = {default=true, debug_only=false, typ="check"} -- mechanic_feature menu.gameplay_options["mechanic_feature"] = {default=false, debug_only=false, typ="check"} -- heli_engine_sound menu.gameplay_options["heli_engine_sound"] = {default=true, debug_only=false, typ="check"} -- heli_spawn menu.gameplay_options["heli_spawn"] = {default=true, debug_only=false, typ="check"} -- dynamic_news menu.gameplay_ui_options["dynamic_news"] = {default=true, debug_only=false, typ="check", on_accept=function(handler,optMgr,ctrl) if (level.present() and dynamic_news_manager) then if (ctrl:GetCheck()) then dynamic_news_manager.get_dynamic_news() else dynamic_news_manager.destroy_dynamic_news() end end end } -- art_degrade menu.gameplay_options["art_degrade"] = {default=false, debug_only=false, typ="check", on_accept=function(handler,optMgr,ctrl) if (level.present() and artefact_degradation) then if (ctrl:GetCheck()) then artefact_degradation.activate_feature() else artefact_degradation.deactivate_feature() end end end } -- I do not recommend allowing a factor greater than 1.0 because there are not enough smart terrain jobs menu.gameplay_options["alife_mutant_pop"] = {default=0.50, debug_only=false, typ="list", list={0.25,0.50,1.0,1.5}} menu.gameplay_options["alife_stalker_pop"] = {default=0.50, debug_only=false, typ="list", list={0.25,0.50,1.0,1.5}} -- excl_dist -- note: shouldn't be greater than switch distance or no simulation squads will come online. Instead it should create a border zone between excl_dist and switch_distance where stuff can come online -- so that when actor walks stuff will naturally come online but if squad teleports very close to actor it will stay offline until player walks far enough away. menu.gameplay_options["excl_dist"] = {default=25, debug_only=false, typ="list", list={0,25,50,100}} -- number of rotating quicksaves menu.gameplay_options["quicksave_cnt"] = {default=5, debug_only=false, typ="list", list={1,5,10,20}} -- character portraits if (db.actor) then -- Options will only show while in-game local l = get_character_icon_list() local selected = nil menu.gameplay_ui_options["char_portrait"] = {default=db.actor_binder.character_icon or "ui_inGame2_Strelok", debug_only=false, typ="list", list=l, on_accept=function(handler,optMgr,ctrl) if (selected) then db.actor_binder.character_icon = ctrl:GetText() if (axr_main.config:r_value("mm_options","enable_outfit_portrait",1,false)) then local outfit = db.actor:item_in_slot(7) if (outfit == nil) then db.actor:set_character_icon(db.actor_binder.character_icon) end else db.actor:set_character_icon(db.actor_binder.character_icon) end end end, on_list_item_select=function(handler,ctrl) selected = ctrl:GetText() if (handler.char_icon) then handler.char_icon:InitTexture(selected) end end } menu.gameplay_ui_options["outfit_portrait"] = {default=true, debug_only=false, typ="check", on_accept=function(handler,optMgr,ctrl) if (ctrl:GetCheck()) then local outfit = db.actor:item_in_slot(7) if (outfit) then local icon = system_ini():r_string_ex(outfit:section(),"character_portrait") if (icon) then db.actor:set_character_icon(icon) end end else db.actor:set_character_icon(db.actor_binder.character_icon or "ui_inGame2_Strelok") end end } end write_default_config(menu.gameplay_options) write_default_config(menu.gameplay_ui_options) end function opt_menu_on_accept(menu,optMgr,console) on_accept(menu.gameplay_options,menu,optMgr,console) on_accept(menu.gameplay_ui_options,menu,optMgr,console) end function opt_menu_on_set_values(menu,optMgr) on_set_values(menu.gameplay_options,menu,optMgr) on_set_values(menu.gameplay_ui_options,menu,optMgr) end function write_default_config(tab_table) local need_save = false for k,v in pairs(tab_table) do if (v.default ~= nil) then if (v.typ=="check") then if not (axr_main.config:line_exist("mm_options","enable_"..k)) then axr_main.config:w_value("mm_options","enable_"..k,v.default) need_save = true end elseif not (axr_main.config:line_exist("mm_options",k)) then axr_main.config:w_value("mm_options",k,v.default) need_save = true end end end if (need_save) then axr_main.config:save() end end function on_accept(tab_table,menu,optMgr,console) for name,v in pairs(tab_table) do if (v.default ~= nil) then if (v.typ=="check") then axr_main.config:w_value("mm_options","enable_"..name,v.ctrl:GetCheck()) elseif (v.typ=="list") then if (type(v.default) == "boolean") then axr_main.config:w_value("mm_options",name,v.ctrl:GetText()=="true" or false) elseif (type(v.default) == "number") then axr_main.config:w_value("mm_options",name,tonumber(v.ctrl:GetText()) or v.default) else axr_main.config:w_value("mm_options",name,v.ctrl:GetText()) end end if (v.on_accept) then v.on_accept(menu,optMgr,v.ctrl) end end end axr_main.config:save() end function on_set_values(tab_table,menu,optMgr) for name,v in pairs(tab_table) do if (v.default ~= nil) then if (v.typ=="check") then v.ctrl:SetCheck(axr_main.config:r_value("mm_options","enable_"..name,1,v.default)) elseif (v.typ=="list") then -- so proper type is cached when reading if (type(v.default) == "boolean") then v.ctrl:SetText(axr_main.config:r_value("mm_options",name,1,v.default)) elseif (type(v.default) == "number") then v.ctrl:SetText(axr_main.config:r_value("mm_options",name,2,v.default)) else v.ctrl:SetText(axr_main.config:r_value("mm_options",name,0,v.default)) end end if (v.on_set_values) then v.on_set_values(menu,optMgr,v.ctrl) end end end end function get_character_icon_list() local t = {"ui_inGame2_Strelok"} local faction = character_community(db.actor):sub(7) local ini = ini_file("plugins\\faction_portraits.ltx") local section = faction.."_portraits" local n = ini:section_exist(section) and ini:line_count(section) or 0 for i=0, n-1 do local result, id, value = ini:r_line(section,i,"","" ) table.insert(t,id) end return t end