Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- File: UI_MAIN_MENU.SCRIPT
- -- Description: Load Dialog for STALKER
- -- Created: 28.10.2004
- -- Lasd edit: 18.01.2006
- -- Copyright: 2004 GSC Game World
- -- Author: Serhiy Vynnychenko (narrator@gsc-game.kiev.ua)
- -- Version: 0.9
- ---------------------->> CoP style load mod
- -- local press_any_key_on_start = false
- -- local sound_volume_eff, sound_volume_music = 1.0, 1.0
- -- local function toggleReadyMenu()
- -- local con = get_console()
- -- if level.present() and press_any_key_on_start then
- -- level.hide_indicators()
- -- self.start_btn = CUIStatic()
- -- self.start_btn:SetWndRect(Frect():set(0, 0, 1024, 768))
- -- self.start_btn:InitTexture("ui\\ui_load")
- -- self.start_btn:SetText("Ready?")
- -- self.start_btn:SetTextAlign(CGameFont.alCenter)
- -- self.start_btn:SetTextY(695)
- -- self.start_btn:SetFont(GetFontGraffiti19Russian())
- -- -- self.alpha = 0
- -- self:AttachChild(self.start_btn)
- -- self:Show(false)
- -- sound_volume_eff = con:get_float("snd_volume_eff")
- -- con:execute("snd_volume_eff 0.0")
- -- sound_volume_music = con:get_float("snd_volume_music")
- -- con:execute("snd_volume_music 1.0")
- -- press_any_key_on_start = false
- -- end
- -- if not press_any_key_on_start and self.start_btn then
- -- level.show_indicators()
- -- console:execute("snd_volume_eff " .. sound_volume_eff)
- -- console:execute("snd_volume_music " .. sound_volume_music)
- -- sound_volume_eff, sound_volume_music = nil, nil
- -- self.start_btn = nil
- -- end
- -- end
- -- local timer = 0
- -- local function f1() return timer < time_global() end
- -- local function f2()
- -- set_inactivate_input_time(1)
- -- get_console():execute("main_menu 1")
- -- timer = time_global() + 200
- -- level.add_call(f1, f3)
- -- end
- -- local function f3()
- -- local console = get_console()
- -- console:hide()
- -- press_any_key_on_start = true
- -- level.show_indicators()
- -- console:execute("snd_volume_eff " .. sound_volume_eff)
- -- console:execute("snd_volume_music " .. sound_volume_music)
- -- sound_volume_eff, sound_volume_music = nil, nil
- -- end
- -- function start()
- -- if has_alife_info("mar_intro_start") then
- -- timer = time_global() + 500
- -- level.add_call(f1, f2)
- -- else
- -- press_any_key_on_start = true
- -- end
- -- return true
- -- end
- ----------------------<< CoP style load mod
- local xs_devmode = false
- local xs_state = {}
- class "main_menu" (CUIScriptWnd)
- function main_menu:__init() super()
- self.mbox_mode = 0
- self:InitControls()
- self:InitCallBacks()
- xr_s.on_main_menu_on()
- end
- function main_menu:InitControls()
- self:SetWndRect (Frect():set(0,0,1024,768))
- local xml = CScriptXmlInit()
- xml:ParseFile ("ui_mm_main.xml")
- xml:InitStatic ("background", self)
- self.shniaga = xml:InitMMShniaga("shniaga_wnd",self);
- self.message_box = CUIMessageBoxEx()
- self:Register (self.message_box, "msg_box")
- local _ver = xml:InitStatic ("static_version",self)
- local mm = _G.main_menu.get_main_menu()
- _ver:SetText ("v" .. mm:GetGSVer())
- end
- function main_menu:Show(f)
- self.shniaga:SetVisibleMagnifier(f)
- end
- function main_menu:InitCallBacks()
- 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_spawn", ui_events.BUTTON_CLICKED, self.OnButton_load_spawn, self)
- self:AddCallback("btn_options", ui_events.BUTTON_CLICKED, self.OnButton_options_clicked, self)
- self:AddCallback("btn_load", ui_events.BUTTON_CLICKED, self.OnButton_load_clicked, self)
- self:AddCallback("btn_save", ui_events.BUTTON_CLICKED, self.OnButton_save_clicked, self)
- self:AddCallback("btn_multiplayer", ui_events.BUTTON_CLICKED, self.OnButton_multiplayer_clicked, 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)
- self:AddCallback("btn_ret", ui_events.BUTTON_CLICKED, self.OnButton_return_game, self)
- self:AddCallback("btn_lastsave", ui_events.BUTTON_CLICKED, self.OnButton_last_save, self)
- self:AddCallback("btn_credits", ui_events.BUTTON_CLICKED, self.OnButton_credits_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)
- 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 c = get_console()
- c:execute("main_menu off")
- c:execute("load_last_save")
- end
- function main_menu:ContinueLastGame(console)
- local fl = getFS():file_list_open_ex(
- '$game_saves$',
- bit_or(FS.FS_ListFiles, FS.FS_RootOnly),
- '*.sav'
- )
- if fl:Size() <= 0 then
- return
- end
- fl:Sort(FS.FS_sort_by_modif_down)
- local name = xs_fs.basename(fl:GetAt(0):NameFull())
- fl = nil
- console:execute('main_menu off')
- console:execute('disconnect')
- console:execute(string.format('start server(%s/single/alife/load) client(localhost)', name))
- end
- function main_menu:OnButton_last_save()
- if ( alife() == nil) or (db.actor~=nil and db.actor:alive()==false) then
- self:LoadLastSave ()
- return
- end
- if ( (db.actor ~= nil) and (db.actor:alive() == false) ) then
- self:LoadLastSave ()
- return
- end
- self.mbox_mode = 1
- self.message_box:InitMessageBox ("message_box_confirm_load_save")
- self:GetHolder():start_stop_menu(self.message_box, true)
- end
- function main_menu:OnButton_credits_clicked()
- -- local console = get_console()
- -- console:execute("main_menu off")
- game.start_tutorial("credits_seq")
- end
- function main_menu:OnButton_quit_clicked()
- self.message_box:InitMessageBox("message_box_quit_windows")
- self:GetHolder():start_stop_menu(self.message_box, true)
- end
- function main_menu:OnButton_disconnect_clicked()
- self.message_box:InitMessageBox("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()
- local console = get_console()
- console:execute("quit")
- end
- function main_menu:OnButton_return_game()
- local console = get_console()
- console:execute("main_menu off")
- xr_s.on_main_menu_off() --' Distemper 03.2008 --
- end
- function main_menu:OnButton_new_novice_game()
- local console = get_console()
- console:execute("g_game_difficulty gd_novice")
- self:StartGame()
- end
- function main_menu:OnButton_new_stalker_game()
- local console = get_console()
- console:execute("g_game_difficulty gd_stalker")
- self:StartGame()
- end
- function main_menu:OnButton_new_veteran_game()
- local console = get_console()
- console:execute("g_game_difficulty gd_veteran")
- self:StartGame()
- end
- function main_menu:OnButton_new_master_game()
- local console = get_console()
- console:execute("g_game_difficulty gd_master")
- self:StartGame()
- end
- function main_menu:StartGame()
- local console = get_console()
- if (alife() ~= nil) then
- console:execute ("disconnect")
- end
- device():pause(false)
- console:execute("start server(all/single/alife/new) client(localhost)")
- console:execute("main_menu off")
- end
- function main_menu:OnButton_load_spawn()
- if self.spawn_dlg == nil then
- self.spawn_dlg = ui_spawn_dialog.spawn_dialog()
- 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:OnButton_save_clicked()
- if self.save_dlg == nil then
- self.save_dlg = ui_save_dialog.save_dialog()
- self.save_dlg.owner = self
- end
- self.save_dlg:FillList()
- self:GetHolder():start_stop_menu(self.save_dlg, true)
- self:GetHolder():start_stop_menu(self, true) --new
- 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) --new
- 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.load_dlg:FillList()
- self:GetHolder():start_stop_menu(self.load_dlg, true)
- self:GetHolder():start_stop_menu(self, true) --new
- 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) --new
- self.mp_dlg:on_show_script()
- self:Show(false)
- -- self.mp_dlg:OnBtn_Refresh()
- local console = get_console()
- console:execute ("check_for_updates 0")
- self.mp_dlg:OnRadio_NetChanged()
- end
- function main_menu:Dispatch(cmd, param) --virtual function
- if cmd == 2 then
- self:OnButton_multiplayer_clicked()
- end
- return true
- end
- ------------------->> CoP style load mod
- function main_menu:Update()
- CUIScriptWnd.Update(self)
- -- if self.tmr then
- -- self.tmr:stop()
- -- if not self.last_time then self.last_time = self.tmr:time() end
- -- if self.tmr:time() - self.last_time > 7000 then
- -- self.last_time = self.tmr:time()
- -- self.start_btn:SetTextColor(self.alpha,159,142,126)
- -- if self.alpha > 250 then self.step = -2 elseif self.alpha < 60 then self.step = 2 end
- -- self.alpha = self.alpha + self.step
- -- end
- -- self.tmr:start()
- -- end
- end
- -------------------<< CoP style load mod
- function main_menu:OnKeyboard(dik, keyboard_action) --virtual function
- CUIScriptWnd.OnKeyboard(self, dik, keyboard_action)
- -- local bind = dik_to_bind(dik)
- local console = get_console()
- local act = db.actor
- ------------------->> CoP style load mod
- -- if self.start_btn and dik ~= DIK_keys.DIK_GRAVE then
- -- self:OnButton_return_game()
- -- return true
- -- end
- -------------------<< CoP style load mod
- if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
- if dik == DIK_keys.DIK_Q then
- self:OnMessageQuitWin()
- elseif dik == DIK_keys.DIK_X then
- xs_devmode = not xs_devmode
- if level.present() and act and act:alive() then
- xs_game.SendMessage(
- 'Xs',
- string.format('DevMove %s', xs_devmode and 'Enabled' or 'Disabled'),
- nil, nil, 4000,
- [[device\pda\pda_tip]]
- )
- end
- elseif dik == DIK_keys.DIK_T then
- do
- -- cache Lua globals as upvalues
- local _G
- = _G
- local table, string, io, math, buffer
- = table, string, io, math, buffer
- local sprintf
- = string.format
- local tostring, select, math_clamp, string_rep, type, pairs, pcall, assert,
- table_sort, table_remove, table_insert, io_open, rawequal, math_huge
- = tostring, select, math.clamp, string.rep, type, pairs, pcall, assert,
- table.sort, table.remove, table.insert, io.open, rawequal, math.huge
- -- cache CS globals as upvalues
- local level, sound_object, abort, vector, user_name, get_console
- = level, sound_object, abort, vector, user_name, get_console
- local level_present, sound_object_s2d
- = level.present, sound_object.s2d
- -- cache Lua lib globals as upvalues
- local xs_fs, xs_extend
- = xs_fs, xs_extend
- local xs_fs_gamePath, xs_extend_export
- = xs_fs.gamePath, xs_extend.export
- local function beep(n)
- if not level_present() then
- return
- end
- local s = sound_object(sprintf([[device\pda\%s]], n or 'pda_tip'))
- s:play_no_feedback(act, sound_object_s2d, 0, vector(), 1.0)
- s = nil
- end
- local __marks = 0
- local __indent = { 0, '' }
- local __logfile, e = io_open(
- xs_fs_gamePath('$logs$', sprintf('Xs_%s.log', user_name():lower())),
- 'wb')
- if not __logfile then
- beep('pda_alarm')
- abort(e)
- end
- --============================================================--
- --=== NOTICE ME ================================ NOTICE ME ===--
- --=== NOTICE ME ================================ NOTICE ME ===--
- --=== NOTICE ME ================================ NOTICE ME ===--
- --============================================================--
- __logfile:setvbuf('no')
- --============================================================--
- --============================================================--
- local function print_impl(count, ...)
- if __logfile and count > 0 then
- for i = 1, count do
- __logfile:write(tostring(select(i, ...)))
- end
- end
- end
- local function adjust_indent(num)
- __indent[1] = math_clamp(num, 0, 100)
- __indent[2] = string_rep(' ', num)
- end
- local function indent()
- adjust_indent(1)
- end
- local function unindent()
- adjust_indent(-1)
- end
- local function print(...)
- local l = select('#', ...)
- if l > 0 then
- print_impl(l, ...)
- end
- end
- local function printf(s, ...)
- if select('#', ...) > 0 then
- print_impl(2, s:format(...))
- else
- print_impl(1, s)
- end
- end
- local function println(...)
- local l = select('#', ...)
- if l > 0 then
- if __indent[1] > 0 then
- print_impl(l + 1, __indent[2], ...)
- else
- print_impl(l, ...)
- end
- end
- print_impl(1, "\n")
- end
- local function print_mark(desc)
- __marks = __marks + 1
- if desc then
- print_impl(5, "MARK #", tostring(__marks), " (", tostring(desc), ")\n")
- else
- print_impl(3, "MARK #", tostring(__marks), "\n")
- end
- __logfile:flush()
- end
- local function printfln(s, ...)
- if select('#', ...) > 0 then
- if __indent[1] > 0 then
- print_impl(3, __indent[2], s:format(...), "\n")
- else
- print_impl(2, s:format(...), "\n")
- end
- else
- println(s)
- end
- end
- local function flush()
- if __logfile then
- __logfile:flush()
- end
- end
- local function begin_region(title)
- print_impl(1, "-------------------------------------------------------------------------------\n")
- println(title, ":")
- adjust_indent(1)
- end
- local function end_region()
- adjust_indent(-1)
- print_impl(1, "\n")
- flush()
- end
- local function exit(exitcode)
- if __logfile then
- __logfile:flush()
- __logfile:close()
- __logfile = nil
- end
- local c = get_console()
- c:execute("disconnect")
- c:execute('quit')
- end
- local function dump(object, max_depth, description)
- assert(type(object) == 'table',
- 'argument #1 must be of type table')
- assert(max_depth == nil or type(max_depth) == 'number',
- 'optional argument #2 must be of type number')
- assert(description == nil or type(description) == 'string',
- 'optional argument #3 must be of type string')
- max_depth = max_depth or math_huge
- local function _dmp(object, depth, k)
- if depth > max_depth then
- return
- end
- local obj_type = type(object)
- local indent = string_rep(" ", depth * 2)
- if obj_type == "table" then
- printfln("%s%s:", indent, tostring(k))
- for k, v in pairs(object) do
- _dmp(v, depth + 1, k)
- end
- elseif obj_type == "userdata" then
- if rawequal(type(object.__tostring), "function") then
- printfln("%s%s: userdata `%s'", indent, tostring(k), tostring(object))
- elseif not rawequal(object.__cls, nil) then
- printfln("%s%s: userdata `%s'", indent, tostring(k), object.__cls)
- else
- printfln("%s%s: userdata *omitted*", indent, tostring(k))
- end
- elseif obj_type == "string" then
- printfln("%s%s: `%s'", indent, tostring(k), object)
- else
- printfln("%s%s: %s", indent, tostring(k), tostring(object))
- end
- end
- _dmp(object, 0, description or "root")
- end
- local function loadlib(name, rethrow)
- assert(rawequal(type(name), 'string'),
- 'argument #1 must be of type string')
- name = name:lower()
- rethrow = rethrow or true
- local status, result = pcall(require, name)
- if status then
- if _G[name] == nil then
- _G[name] = result
- end
- return result
- else
- printfln(" lib `%s' NOT loaded, see error...", name)
- println(" ", result)
- if rethrow == true then
- flush()
- abort(result)
- end
- return {}
- end
- end
- local middleclass = require('middleclass')
- local function_profiler = middleclass('function_profiler')
- function function_profiler:__init(prime_contenders)
- self.contenders = {}
- self.prime_contenders = prime_contenders or false
- xs_extend_export()
- end
- function function_profiler:__tostring()
- if #self.contenders == 0 then
- return ''
- end
- local elapsed_total = 0.0
- local buffer = buffer.new(240 + 80 * #self.contenders)
- buffer:len(0)
- buffer:append('--- sorted results (slowest to fastest) ---------------------------------------\n')
- for i = 1, #self.contenders do
- buffer:append_format(
- "%-2d %-58s %8.2fms %-2d%%\n",
- i, -- rank
- self.contenders[i][1], -- name
- self.contenders[i][3] * 0.001, -- elasped time
- self.contenders[i][4] -- percentage
- )
- elapsed_total = elapsed_total + self.contenders[i][3]
- end
- buffer:rep(79, '=')
- buffer:append_format("\n-- %-58s %8.2fms --%%\n", 'total', elapsed_total)
- return buffer:tostring()
- end
- function function_profiler:_prep_summery(lap_count, elapsed_total)
- for i = 1, #self.contenders do
- self.contenders[i][4] = self.contenders[i][3] / elapsed_total * 100
- end
- table_sort(self.contenders, function (lhs, rhs)
- return lhs[3] > rhs[3] -- slowest to fastest
- end)
- end
- function function_profiler:_add_result(contender_index, elapsed_time)
- self.contenders[contender_index][3] = elapsed_time
- end
- function function_profiler:run(lap_count)
- assert(type(lap_count) == 'number' and lap_count > 0,
- "argument #1 must be a positive number")
- assert(#self.contenders >= 2, "need at least 2 contenders")
- local elapsed_total = 0.0
- for i = 1, #self.contenders do
- do
- local func = self.contenders[i][2]
- if self.prime_contenders then
- func()
- end
- local timer = profile_timer()
- timer:start()
- for i = 1, lap_count do
- func()
- end
- timer:stop()
- elapsed_total = elapsed_total + timer:time()
- self:_add_result(i, timer:time())
- end
- end
- self:_prep_summery(lap_count, elapsed_total)
- end
- function function_profiler:reset(retain_contenders)
- if retain_contenders then
- for i = 1, #self.contenders do
- while #self.contenders[i] > 2 do
- table_remove(self.contenders[i])
- end
- end
- else
- self.contenders = {}
- end
- end
- function function_profiler:add_contenter(name, func)
- assert(type(name) == 'string', 'argument #1 must be of type string')
- assert(type(func) == 'function', 'argument #2 must be of type function')
- for i = 1, #self.contenders do
- if self.contenders[i][1] == name then
- abort("argument #1 must be a unique string")
- end
- end
- table_insert(self.contenders, { name, func })
- end
- local function replace_global(name, repl)
- assert(type(_G[name]) == 'function',
- 'argument #1 must be the name of a global function')
- assert(type(repl) == 'function',
- 'argument #2 must be a function')
- _G[name] = _G['__' .. name]
- _G[name] = repl
- end
- local function restore_global(name)
- assert(type(_G[name]) == 'function',
- 'argument #1 must be the name of a global function')
- local backup = '__' .. name
- if _G[backup] ~= nil then
- _G[name] = _G[backup]
- _G[backup] = nil
- end
- end
- ---------------------------------------------------------------
- -- do
- -- begin_region('marshal CTime')
- -- game.CTime.__size = 4 * 9 -- guess based on ctime.h tm; most likely wrong
- -- function game_CTime___persist(self)
- -- local Y, M, D, h, m, s, ms
- -- = self:get(Y, M, D, h, m, s, ms)
- -- return function ()
- -- local t = game.CTime()
- -- t:set(Y, M, D, h, m, s, ms)
- -- return t
- -- end
- -- end
- -- local t = game.CTime()
- -- printfln('type(t): %s', type(t)); flush()
- -- local m = getmetatable(t)
- -- m.__persist = game_CTime___persist
- -- dump(m, 3, 'm')
- -- debug.memdump(t, game.CTime.__size, 't (default)'); flush()
- -- t:set(2014, 3, 12, 1, 2, 3, 4)
- -- debug.memdump(t, game.CTime.__size, 't (today)'); flush()
- -- local s = marshal.encode(t)
- -- debug.memdump(s, #s, 's'); flush()
- -- local x = marshal.decode(s)
- -- printfln('type(x): %s', type(x)); flush()
- -- end_region()
- -- end
- ---------------------------------------------------------------
- -- do
- -- begin_region('container')
- -- local container = _G.container
- -- dump(container, 2, '_G.container')
- -- do
- -- local s = container.new_sorted_set('number')
- -- dump(getmetatable(s), 2, 'getmetatable(s)')
- -- printfln('size: %d', s:size())
- -- s:insert(10)
- -- s:insert(20)
- -- s:insert(30)
- -- printfln('#len: %d', #s)
- -- s:insert(10)
- -- printfln('#len: %d', #s)
- -- println('values:')
- -- for n in s:iter() do
- -- printfln(' value: %.0f; contains: %d', n, tonumber(s:contains(n)))
- -- end
- -- printfln('s:equals(s): %d', s:equals(s))
- -- end
- -- end_region()
- -- end
- ---------------------------------------------------------------
- -- do
- -- begin_region('error handling')
- -- local function err_lvl0()
- -- error("error 0", 0)
- -- end
- -- local function err_lvl1()
- -- error("error 1", 1)
- -- end
- -- local function err_lvl2()
- -- error("error 2", 2)
- -- end
- -- local function err_root()
- -- err_lvl0()
- -- err_lvl1()
- -- err_lvl2()
- -- println("done")
- -- end
- -- err_root()
- -- end_region()
- -- end
- ---------------------------------------------------------------
- do
- begin_region('traceback')
- replace_global('print', println)
- local u1
- local invoker = function (p1)
- u1 = _G.pcall
- local l1 = "a local"
- local tb = function (n) print(debug.traceback_ex(n)) end
- pcall(tb, 0)
- end
- invoker("a param")
- restore_global('print')
- end_region()
- end
- ---------------------------------------------------------------
- -- do
- -- begin_region("lxsext_c_tests")
- -- replace_global('print', println)
- -- dofile(xs_fs.gamePath('$game_scripts$', [[lib\lxsext_c_tests.lua]]))
- -- -- dofile(xs_fs.gamePath('$game_scripts$', [[lib\tests\literals.lua]]))
- -- -- dofile(xs_fs.gamePath('$game_scripts$', [[lib\tests\strings.lua]]))
- -- -- dofile(xs_fs.gamePath('$game_scripts$', [[lib\tests\math.lua]]))
- -- restore_global('print')
- -- end_region()
- -- end
- ---------------------------------------------------------------
- flush()
- beep()
- end
- end
- if level.present() and act and act:alive() then
- if dik == DIK_keys.DIK_ESCAPE then
- self:OnButton_return_game()
- elseif dik == DIK_keys.DIK_F1 then
- level.set_time_factor(1)
- self:OnButton_return_game()
- elseif dik == DIK_keys.DIK_F2 then
- level.set_time_factor(5)
- self:OnButton_return_game()
- elseif dik == DIK_keys.DIK_F3 then
- level.set_time_factor(480)
- self:OnButton_return_game()
- elseif dik == DIK_keys.DIK_F4 then
- level.set_time_factor(1440)
- self:OnButton_return_game()
- end
- if xs_devmode then
- local adjustMoney = xs_game.GiveOrTakeMoney
- if dik == DIK_keys.DIK_NUMPADENTER then
- local items = {
- "dolg_exo_outfit",
- "exo_outfit",
- "merc_exo_outfit",
- "monolith_exo_outfit",
- "svoboda_exo_outfit",
- }
- for i = 1, #items do
- amk.spawn_item_in_inv(items[i])
- end
- act:give_money(500000)
- xr_sound.set_sound_play(act:id(), "pda_alarm")
- -- amk.spawn_ammo_in_inv(section, count)
- elseif dik == DIK_keys.DIK_ADD then
- adjustMoney(1000, act, true, false)
- elseif dik == DIK_keys.DIK_MULTIPLY then
- adjustMoney(act:money(), act, true, false)
- elseif dik == DIK_keys.DIK_MINUS then
- adjustMoney(-1000, act, true, false)
- elseif dik == DIK_keys.DIK_DIVIDE then
- adjustMoney(-(act:money() * 0.5), act, true, false)
- elseif dik == DIK_keys.DIK_NUMPAD0 then
- local delta = act:money()
- if xs_state.money == nil then
- xs_state.money = delta
- delta = (-delta) - 1
- else
- delta = xs_state.money
- xs_state.money = nil
- end
- adjustMoney(delta, act, true, false)
- end
- end
- else
- if dik == DIK_keys.DIK_L then
- self:ContinueLastGame(console)
- end
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement