Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class "main_menu"(CUIScriptWnd)
- function main_menu:__init() super()
- self.mbox_mode = 0
- _G.g_menu = self
- self:InitControls()
- wprintf("[~T].~CF0 #DBG: main_menu created, namespace =~CF2 %s~C07", script_namespace or 'nil')
- self:InitCallBacks()
- self:InitGameSetupMenu()
- local yn = {}
- yn[false] = "~C0C No~C07"
- yn[true] = "~C0A Yes~C07"
- if db.actor then
- local inv_show = yn [db.actor:has_info("ui_inventory")] or 'nil'
- local inv_hide = yn [db.actor:has_info("ui_inventory_hide")] or 'nil'
- local gadget = yn [used_items.can_use_gadget()] or 'nil'
- local wpn_hide = yn [bind_stalker.self_weapon_hide] or 'nil'
- wprintf("[~T]. #DBG: last binder update =~C0F %s~C07, inventory { show = %s, hide = %s }, can use gadget = %s, weapon hide = %s ",
- last_upd_time or 'nil', inv_show, inv_hide, gadget, wpn_hide)
- end
- end
- function main_menu:__finalize()
- end
- function main_menu:InitControls()
- self:Init(0,0,1024,768)
- local xml = CScriptXmlInit()
- xml:ParseFile("ui_mm_main.xml")
- xml:InitStatic("back_movie", self)
- xml:InitStatic("background", self)
- xml:InitAnimStatic ("anim_00", self)
- xml:InitAnimStatic ("anim_01", self)
- self.shniaga = xml:InitMMShniaga("shniaga_wnd",self);
- self.message_box = CUIMessageBoxEx()
- self:Register(self.message_box, "msg_box")
- local sak_title = game.translate_string("st_mp_voting_failed")
- local sak_version = ""
- if xr_build_id then sak_version = tostring(xr_build_id) end
- local mod_ver = xml:InitStatic("mod_version",self)
- mod_ver:SetText (sak_title .. " (build " .. sak_version .. ")")
- end
- function main_menu:Show(f)
- self.shniaga:SetVisibleMagnifier(f)
- end
- function main_menu:InitCallBacks()
- self:AddCallback( "btn_options", ui_events.BUTTON_CLICKED, self.OnButton_options_clicked, self )
- self:AddCallback( "msg_box", ui_events.MESSAGE_BOX_OK_CLICKED, self.OnMsgOk, self )
- self:AddCallback( "msg_box", ui_events.MESSAGE_BOX_CANCEL_CLICKED, self.OnMsgCancel, self )
- self:AddCallback( "msg_box", ui_events.MESSAGE_BOX_YES_CLICKED, self.OnMsgYes, self )
- self:AddCallback( "msg_box", ui_events.MESSAGE_BOX_NO_CLICKED, self.OnMsgNo, self )
- self:AddCallback( "msg_box", ui_events.MESSAGE_BOX_QUIT_GAME_CLICKED, self.OnMessageQuitGame, self )
- self:AddCallback( "msg_box", ui_events.MESSAGE_BOX_QUIT_WIN_CLICKED, self.OnMessageQuitWin, self )
- self:AddCallback( "msg_box_btn", ui_events.BUTTON_CLICKED, self.OnMessageCheckSave, self )
- self:AddCallback( "btn_quit", ui_events.BUTTON_CLICKED, self.OnButton_quit_clicked, self )
- self:AddCallback( "btn_quit_to_mm", ui_events.BUTTON_CLICKED, self.OnButton_disconnect_clicked, self )
- if not self.err_mod then
- self:AddCallback( "btn_novice", ui_events.BUTTON_CLICKED, self.OnButton_new_novice_game, self )
- self:AddCallback( "btn_stalker", ui_events.BUTTON_CLICKED, self.OnButton_new_stalker_game, self )
- self:AddCallback( "btn_veteran", ui_events.BUTTON_CLICKED, self.OnButton_new_veteran_game, self )
- self:AddCallback( "btn_master", ui_events.BUTTON_CLICKED, self.OnButton_new_master_game, self )
- self:AddCallback( "btn_load", ui_events.BUTTON_CLICKED, self.OnButton_load_clicked, self )
- self:AddCallback( "btn_multiplayer", ui_events.BUTTON_CLICKED, self.OnButton_multiplayer_clicked, self )
- self:AddCallback( "btn_ret", ui_events.BUTTON_CLICKED, self.OnButton_return_game, self )
- -- self:AddCallback( "btn_spawn", ui_events.BUTTON_CLICKED, self.OnButton_load_spawn, self )
- end
- end
- function main_menu:OnMsgOk()
- self.mbox_mode = 0
- end
- function main_menu:OnMsgCancel()
- self.mbox_mode = 0
- end
- function main_menu:OnMsgYes()
- if self.mbox_mode==1 then
- self:LoadLastSave()
- end
- self.mbox_mode = 0
- end
- function main_menu:OnMsgNo()
- self.mbox_mode = 0
- end
- function main_menu:LoadLastSave()
- local console = get_console()
- console:execute ("main_menu off")
- console:execute ("load_last_save")
- end
- function main_menu:OnButton_last_save()
- if (alife()==nil) then
- self:LoadLastSave ()
- return
- end
- self.mbox_mode = 1
- self.message_box:Init ("message_box_confirm_load_save")
- self:GetHolder():start_stop_menu(self.message_box, true)
- end
- function main_menu:OnButton_credits_clicked()
- game.start_tutorial("credits_seq")
- end
- function main_menu:OnButton_quit_clicked()
- self.message_box:Init("message_box_quit_windows")
- self:GetHolder():start_stop_menu(self.message_box, true)
- end
- function main_menu:OnMessageCheckSave()
- self.save_quit = self.message_box_btn:GetCheck()
- end
- function main_menu:OnButton_disconnect_clicked()
- self.message_box:Init("message_box_quit_game")
- if (level.game_id()~=1) then
- self.message_box:SetText("ui_mm_disconnect_message") -- MultiPlayer
- else
- self.message_box:SetText("ui_mm_quit_game_message") -- SinglePlayer
- end
- self:GetHolder():start_stop_menu(self.message_box, true)
- end
- function main_menu:OnMessageQuitGame()
- local console = get_console()
- console:execute("disconnect")
- end
- function main_menu:OnMessageQuitWin()
- xr_statistic.save_gametime()
- ExitProcess()
- end
- function main_menu:OnButton_return_game()
- local console = get_console()
- console:execute("main_menu off")
- end
- function main_menu:StartGame()
- local console = get_console()
- if (alife()~=nil) then
- console:execute ("disconnect")
- end
- SetGlobalVar("new_game", "now") -- in session var
- console:execute("start server(all/single/alife/new) client(localhost)")
- console:execute("main_menu off")
- end
- function main_menu:NewGameStart(hard_level)
- local console = get_console()
- console:execute("g_game_difficulty "..hard_level)
- self:StartGame()
- end
- function main_menu:OnButton_new_novice_game()
- self:NewGameStart("gd_novice")
- end
- function main_menu:OnButton_new_stalker_game()
- self:NewGameStart("gd_stalker")
- end
- function main_menu:OnButton_new_veteran_game()
- self:NewGameStart("gd_veteran")
- end
- function main_menu:OnButton_new_master_game()
- self:NewGameStart("gd_master")
- end
- function main_menu:OnButton_load_spawn()
- if self.spawn_dlg == nil then
- self.spawn_dlg = spawner.spawn_items_dialog()
- self.spawn_dlg.owner = self
- end
- self:GetHolder():start_stop_menu(self.spawn_dlg, true)
- self:GetHolder():start_stop_menu(self, true)
- self:Show(false)
- end
- function main_menu:OnButton_save_clicked()
- if self.save_dlg==nil then
- self.save_dlg = ui_save_dialog.save_dialog()
- self.save_dlg.owner = self
- end
- self:GetHolder():start_stop_menu(self.save_dlg, true)
- self:GetHolder():start_stop_menu(self, true)
- self:Show(false)
- end
- function main_menu:OnButton_options_clicked()
- if self.opt_dlg==nil then
- self.opt_dlg = ui_mm_opt_main.options_dialog()
- self.opt_dlg.owner = self
- end
- self.opt_dlg:UpdateControls()
- self:GetHolder():start_stop_menu(self.opt_dlg, true)
- self:GetHolder():start_stop_menu(self, true)
- self:Show(false)
- end
- function main_menu:OnButton_load_clicked()
- if self.load_dlg ==nil then
- self.load_dlg = ui_load_dialog.load_dialog()
- self.load_dlg.owner = self
- end
- self:GetHolder():start_stop_menu(self.load_dlg, true)
- self:GetHolder():start_stop_menu(self, true)
- self:Show(false)
- end
- function main_menu:OnButton_multiplayer_clicked()
- if self.mp_dlg ==nil then
- self.mp_dlg = ui_mp_main.mp_main()
- self.mp_dlg.owner = self
- end
- self.mp_dlg:UpdateControls()
- self:GetHolder():start_stop_menu(self.mp_dlg, true)
- self:GetHolder():start_stop_menu(self, true)
- self:Show(false)
- local console = get_console()
- console:execute ("check_for_updates 0")
- self.mp_dlg:OnRadio_NetChanged()
- end
- function main_menu:Dispatch(cmd, param)
- if cmd==2 then
- self:OnButton_multiplayer_clicked()
- end
- return true
- end
- function zero(z)
- if z < 10 then z="0"..z end
- return z
- end
- function main_menu:OnKeyboard(dik, keyboard_action)
- CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
- local bind = dik_to_bind(dik)
- local console = get_console()
- if keyboard_action==ui_events.WINDOW_KEY_PRESSED then
- if dik == DIK_keys.DIK_ESCAPE then
- if
- level.present()
- and( db.actor ~= nil )
- and db.actor:alive()
- then
- console:execute( "main_menu off" )
- end
- end
- if dik == DIK_keys.DIK_F4 then
- self:show_position_informer_window()
- elseif dik == DIK_keys.DIK_F3 then
- if level.present() and db.actor ~= nil and db.actor:alive() then
- if not dsh_coordinator.GlobalEnable then
- dsh_coordinator.subscribe()
- else
- dsh_coordinator.unsubscribe()
- end
- -- console:execute( "main_menu off" )
- end
- elseif dik == DIK_keys.DIK_V then
- get_console():execute( "vid_restart" )
- --elseif dik == DIK_keys.DIK_F1 and db.actor:has_info( "cheat" ) then
- elseif dik == DIK_keys.DIK_F1 and game_options.Spawner then
- self:OnButton_load_spawn()
- end
- end
- return true
- end
- --[[ self:collect_info()
- function main_menu:collect_info()
- if self.spawn_dlg == nil then
- self.spawn_dlg = ui_info_menu.CUIInfoMenu()
- self.spawn_dlg.owner = self
- end
- self:GetHolder():start_stop_menu(self.spawn_dlg, true)
- self:GetHolder():start_stop_menu(self, true) --new
- self:Show(false)
- end
- ]]--
- function main_menu:show_position_informer_window()
- if self.cheat_dlg == nil then
- self.cheat_dlg = positioninformer.pi()
- self.cheat_dlg.owner = self
- end
- self:GetHolder():start_stop_menu( self.cheat_dlg, true )
- self:GetHolder():start_stop_menu( self, true )
- self:Show( true )
- end
- function main_menu:ppe_menu_show()
- if self.ppe_dlg == nil then
- self.ppe_dlg = play_ppe.ppe()
- self.ppe_dlg.owner = self
- end
- self:GetHolder():start_stop_menu( self.ppe_dlg, true )
- self:GetHolder():start_stop_menu( self, true )
- self:Show(true)
- end
- function main_menu:Get_Adaptation_SSVersion()
- if self.iGSVer >= 6 and self.iGSVer==self.iSSVer then return true end
- local f = getFS()
- local sConfigDir = "$game_config$"
- local sFileMask = "system_script"
- local sFileSys = sFileMask..".ltx"
- local sFileOld = sFileMask..".bak"
- local sFileVer = "template_script_"..tostring( self.iGSVer ) .. ".src"
- if f:exist( sConfigDir, sFileVer ) then
- local sFullNameFileVer = f:update_path( sConfigDir, sFileVer )
- local sFullNameFileSys = f:update_path( sConfigDir, sFileSys )
- local sFullNameFileOld = f:update_path( sConfigDir, sFileOld )
- if f:exist( sConfigDir, sFileSys ) then
- if f:exist( sConfigDir, sFileOld ) then
- f:file_delete( sFullNameFileOld )
- end
- f:file_rename( sFullNameFileSys, sFullNameFileOld, true )
- end
- f:file_copy( sFullNameFileVer, sFullNameFileSys )
- local iVerLtx = utils.cfg_get_number( ini_file( sFileSys ), "script", "current_server_entity_version", false, -1 )
- return iVerLtx == self.iGSVer
- else
- end
- return false
- end
- function main_menu:InitGameSetupMenu()
- local fs = getFS()
- if fs:exist("$app_data_root$", "game.options") == nil then
- local f1 = fs:update_path("$fs_root$", "fsgame.ltx")
- local f2 = fs:update_path("$app_data_root$", "game.options")
- fs:file_copy(f1, f2)
- save_game_options()
- else
- local file = io.open(fs:update_path("$app_data_root$", "game.options"), "r")
- local opt, val, n = "", "", 0
- local m = _G[script_name()]
- for line in file:lines() do
- opt, val = string.match(line, "([%w_]+)%s*=%s*(.+)")
- -- log("load options: "..tostring(opt).." = "..tostring(val))
- if opt and m[opt]~=nil then
- n = tonumber(val)
- if n then m[opt] = n
- elseif val=='true' then m[opt] = true
- elseif val=='false' then m[opt] = false
- elseif val~="" then m[opt] = val end
- end
- end
- file:close(file)
- end
- end
- xray_dma.init()
- if _g.lua_random then ui_load_tex.RandomUILoadTex() end
- mp_ranks.do_get_rank_patch()
- if list_tools.record_list and windows.CUIScriptDialog then wprintf("~CA0[~T]. #OK: class extensions found ~C07") end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement