Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------
- -- Mod: LURK 1.2 with RMA and ZRP
- -- Last edit: 2014.04.04
- -- Author: Daemonion
- -- Thanks: KamikaZze (OGSE), Tlar, NatVac, Alundaio and GSC forums <3
- -- Notes: Dynamic Menu by Daemonion for LURK 1.2
- --------------------------------------------------------------
- class "main_menu" (CUIScriptWnd)
- --------------------------------------------------------------
- -- BEGIN LURK 1.2 UTILITIES
- --------------------------------------------------------------
- -- determine whether it is day or night on the current level
- local function is_night()
- local gth = level.get_time_hours()
- return gth <= 5 or gth >= 19
- end
- -- this starts by looking in gamedata\sounds\daemonion\menu\
- -- looks for a file name which begins with "mm_"
- -- then determines if it is day or night, then looks for a file name of "mm_night" or "mm_day"
- -- then expands the search to "mm_night_audio_" or "mm_day_audio_"
- -- then adds the name of the current level to become "mm_night_audio_l01_escape"
- -- then adds the final postfix "_l" or "_r" for stereo audio playback
- function play_daemonion_audio()
- local con = get_console()
- local actor = db.actor
- local sound = "daemonion\\menu\\mm_"
- if (is_night() == true) then
- sound = sound .. "night"
- else
- sound = sound .. "day"
- end
- sound = sound .. "_audio_"..level.name()
- audio_left_channel = xr_sound.get_safe_sound_object(sound.."_l")
- audio_right_channel = xr_sound.get_safe_sound_object(sound.."_r")
- con:execute("daemonion_audio:executing_play_daemonion_audio...")
- if audio_left_channel:playing() == false then
- audio_left_channel:play_at_pos (actor, vector():set(-5, 0, 1), 1, sound_object.s2d)
- audio_right_channel:play_at_pos (actor, vector():set(5, 0, 1), 1, sound_object.s2d)
- end
- end
- -- stops audio from playing in the main menu when the player hits ESC or clicks "return to game" button
- function stop_daemonion_audio()
- local con = get_console()
- if audio_left_channel:playing() == true then
- con:execute("daemonion_audio:stopping_daemonion_audio...")
- audio_left_channel:stop()
- audio_right_channel:stop()
- end
- end
- -- create global variables for menu sound (they will get over-written) /dae
- audio_left_channel = xr_sound.get_safe_sound_object("daemonion\\misc\\silence")
- audio_right_channel = xr_sound.get_safe_sound_object("daemonion\\misc\\silence")
- --------------------------------------------------------------
- -- END LURK 1.2 UTILITIES
- --------------------------------------------------------------
- -- runs when main menu is first loaded /dae
- function main_menu:__init() super()
- self.mbox_mode = 0
- self:InitControls()
- self:InitCallBacks()
- -- if the main menu is brought up after a game or save is loaded, do this: /dae
- local con = get_console()
- if (level.present() and db.actor) and audio_left_channel:playing() == false then
- con:execute("daemonion_audio:attempting_to_execute_daemonion_audio_function ...")
- play_daemonion_audio()
- end
- end
- -- runs when main menu is closed, supposedly, but doesn't work well for me /dae
- function main_menu:__finalize()
- end
- _ver_static = nil
- function main_menu:InitControls()
- -- testing widescreen support /dae
- local screen = device()
- local scr_width = screen.width
- local scr_height = screen.height
- local screen_aspect_ratio = 1.34
- -- 1024x768,1280x1024,1600x1200 = 1.33
- -- 1280x800,1440x900,1680x1050,1920x1200 = 1.6
- -- 1280x720,1920x1080 = 1.77
- if scr_width > 0 and scr_height > 0 then
- screen_aspect_ratio = scr_width / scr_height
- end
- self:Init(0,0,1024,768) -- not sure what the first two numbers are for /dae
- local xml = CScriptXmlInit()
- -- lurk_main_menu.xml refers to gamedata\config\ui
- -- it is a modified main menu xml I made for compatibility (no need to change the old one!)
- xml:ParseFile("lurk_main_menu.xml") -- non-vanilla file must be created (added for compatibility)
- -- determines which video/texture to use at launch (before a new or saved game begins)
- if (screen_aspect_ratio == 1.6) then xml:InitStatic("start_movie_1.6", self)
- elseif (screen_aspect_ratio > 1.6) then xml:InitStatic("start_movie_1.77", self)
- else xml:InitStatic("start_movie_1.33", self) end
- local flist = getFS():file_list_open_ex("$game_saves$",bit_or(bit_or(FS.FS_ListFiles,FS.FS_RootOnly), FS.FS_ClampExt) , "*.sav")
- local f_cnt = flist:Size()
- local con = get_console()
- local y,m,d,h,min,sec,ms = nil,nil,nil,nil,nil,nil,nil
- flist:Sort(5)
- if f_cnt > 0 then
- local file = flist:GetAt(0)
- local sg = CSavedGameWrapper(file:NameFull())
- y,m,d,h,min,sec,ms = sg:game_time():get()
- -- little fixin's from OGSE to display data in main menu console; we could add other things /daemonion
- local ar = screen_aspect_ratio
- con:execute("aspect_ratio="..ar)
- local level_name = sg:level_name()
- con:execute("level_name="..level_name)
- local level_id = sg:level_id()
- con:execute("level_id="..level_id)
- local actor_health = sg:actor_health()
- con:execute("actor_health="..actor_health)
- end
- -- reads level and time of day
- -- then picks proper texture from lurk_main_menu.xml
- if level and level.present() then
- local htime = level.get_time_hours()
- if (screen_aspect_ratio > 1.4) then
- -- player using widescreen resolution
- if (is_night() == true) then
- -- it is night time; use night and widescreen resolution version
- xml:InitStatic("mm_night_wide_"..level.name(), self)
- else
- -- it is day time; use day and widescreen resolution version
- xml:InitStatic("mm_day_wide_"..level.name(), self)
- end
- else
- -- player using a super lame resolution
- if (is_night() == true) then
- -- it is night time; use night and super lame resolution version
- xml:InitStatic("mm_night_"..level.name(), self)
- else
- -- it is day time; use day and super lame resolution version
- xml:InitStatic("mm_day_"..level.name(), self)
- end
- end
- end
- self.shniaga = xml:InitMMShniaga("shniaga_wnd",self);
- self.message_box = CUIMessageBoxEx()
- self:Register(self.message_box, "msg_box")
- local _ver = xml:InitStatic ("lurk_version",self)
- local mm = _G.main_menu.get_main_menu()
- if type(mm.GetGSVer) ~= "function" then
- _ver:SetText("ver. 1.0 - NOT COMPATIBLE with " .. _z.mod_version_str)
- else
- _ver:SetText("ver. " .. mm:GetGSVer() .. " - " .. _z.mod_version_str)
- end
- _ver_static = _ver
- save_made = false
- end
- -- stops audio when "return to game" is clocked
- function main_menu:OnButton_return_game()
- local console = get_console()
- console:execute("main_menu off")
- stop_daemonion_audio() -- /daemonion
- end
- -- to stop audio when ESC Key is pressed:
- -- find the following line:
- if dik == DIK_keys.DIK_ESCAPE and alive_on_level then
- -- and add a call to this function:
- stop_daemonion_audio() -- /daemonion
Advertisement
Add Comment
Please, Sign In to add comment