--/SGM строки: 38,44,45,278 и ниже
-- 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
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:__finalize()
end
function main_menu:InitControls()
    self:SetWndRect(Frect():set(0,0,1024,768))
    local xml	       = CScriptXmlInit()
    xml:ParseFile("ui_main_menu.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:TextControl():SetText("ver. " .. mm:GetGSVer())
    self.l_mgr         = mm:GetLoginMngr()
    self.acc_mgr       = mm:GetAccountMngr()
    self.profile_store = mm:GetProfileStore()
    self.gs_profile    = self.l_mgr:get_current_profile()
    if (self.gs_profile and not(level.present())) then
	self.shniaga:ShowPage(CUIMMShniaga.epi_new_network_game) --fake
	self.shniaga:SetPage(CUIMMShniaga.epi_main, "ui_mm_main.xml", "menu_main_logout")
	self.shniaga:ShowPage(CUIMMShniaga.epi_main)
    end
    sgm_version.parse_mod_version("sigerous_mod_version",self)
end
function main_menu:Show(f)
	self.shniaga:SetVisibleMagnifier(f)
end
function main_menu:InitCallBacks()
	self:AddCallback("btn_mod_option",ui_events.BUTTON_CLICKED,self.mod_options,self)
	self:AddCallback("btn_coord_pos",ui_events.BUTTON_CLICKED,self.OnButton_coord_pos_clicked,self)
	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_net_game",ui_events.BUTTON_CLICKED,self.OnButton_network_game_clicked,self)
	self:AddCallback("btn_internet",ui_events.BUTTON_CLICKED,self.OnButton_internet_clicked,self)
	self:AddCallback("btn_localnet",ui_events.BUTTON_CLICKED,self.OnButton_localnet_clicked,self)
	self:AddCallback("btn_multiplayer",ui_events.BUTTON_CLICKED,self.OnButton_multiplayer_clicked,self)
	self:AddCallback("btn_logout",ui_events.BUTTON_CLICKED,self.OnButton_logout_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)
	self:Register(self,"self")
	self:AddCallback("self",ui_events.MAIN_MENU_RELOADED,self.OnMenuReloaded,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 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
	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.message_box:ShowDialog(true)
end
function main_menu:OnButton_credits_clicked()
	game.start_tutorial("credits_seq")
end
function main_menu:OnButton_quit_clicked()
	self.message_box:InitMessageBox("message_box_quit_windows")
	self.message_box:ShowDialog(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")
	else
		self.message_box:SetText("ui_mm_quit_game_message")
	end
	self.message_box:ShowDialog(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()
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()
	self.god_dlg = ui_god_dialog.god_dialog()
	self.god_dlg.owner = self

	self.god_dlg:FillList()

	self.god_dlg:ShowDialog(true)
	self:HideDialog()
	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.save_dlg:ShowDialog(true)
	self:HideDialog()
	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:SetCurrentValues()
	self.opt_dlg:ShowDialog(true)
	self:HideDialog()
	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.load_dlg:ShowDialog(true)
	self:HideDialog()
	self:Show(false)
end
function main_menu:OnButton_network_game_clicked()
	self.shniaga:ShowPage(CUIMMShniaga.epi_new_network_game)
end
function main_menu:OnButton_multiplayer_clicked()
	if not(self.mp_dlg) then
                self.mp_dlg = ui_mp_main.mp_main(self.gs_profile:online())
                self.mp_dlg.owner = self
		self.mp_dlg:OnRadio_NetChanged()
		if (self.mp_dlg.online) then
			self.mp_dlg.dlg_profile:InitBestScores()
			self.mp_dlg.dlg_profile:FillRewardsTable()
		end
        end
        self.mp_dlg:UpdateControls()
        self.mp_dlg:ShowDialog(true)
        self:HideDialog()
	self:Show(false)
	local console = get_console()
	console:execute("check_for_updates 0")
end
function main_menu:OnButton_logout_clicked()
	self.shniaga:ShowPage(CUIMMShniaga.epi_new_network_game)
	self.l_mgr:logout()
	self.gs_profile = nil
	self.mp_dlg = nil
	self.shniaga:SetPage(CUIMMShniaga.epi_main, "ui_mm_main.xml", "menu_main")
	self.shniaga:ShowPage(CUIMMShniaga.epi_main)
end
function main_menu:OnButton_internet_clicked()
        if not(self.gs_dlg) then
            self.gs_dlg = ui_mm_mp_gamespy.gamespy_page()
            self.gs_dlg.owner = self
        end
        self.gs_dlg:ShowLoginPage()
        self.gs_dlg:ShowDialog(true)
	self:HideDialog()
	self:Show(false)
	local console = get_console()
	console:execute("check_for_updates 0")
end
function main_menu:OnButton_localnet_clicked()
	if not(self.ln_dlg) then
         self.ln_dlg = ui_mm_mp_localnet.localnet_page()
         self.ln_dlg.owner = self
         self.ln_dlg.lp_nickname:SetText(self.l_mgr:get_nick_from_registry())
         self.ln_dlg.lp_check_remember_me:SetCheck(self.l_mgr:get_remember_me_from_registry())
        end
        self.ln_dlg:ShowDialog(true)
	self:HideDialog()
	self:Show(false)
	local console = get_console()
	console:execute("check_for_updates 0")
end
function main_menu:Dispatch(cmd, param)
	if cmd == 2 then
	   self:OnButton_multiplayer_clicked()
	end
	return true
end
function main_menu:OnMenuReloaded()
	self:OnButton_options_clicked()
	self.opt_dlg:OnMenuReloaded()
end
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()
	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())) or (false==IsGameTypeSingle())) then
		      self.OnButton_return_game()
		   end
		end
		if dik == DIK_keys.DIK_F11 then
               		 if db.actor then
				self:OnButton_load_spawn()
                		end
		end
		if dik==DIK_keys.DIK_Q then
			self:OnMessageQuitWin()
		elseif dik==DIK_keys.DIK_SUBTRACT then
			self:screenshot_mode_on()
		elseif dik==DIK_keys.DIK_ADD then
			self:screenshot_mode_off()
		elseif db.actor~=nil and dik==DIK_keys.DIK_F5 then
			self:mod_options()
		elseif db.actor~=nil and dik==DIK_keys.DIK_T then
                        self.OnButton_return_game()
                        run_choose_box("yes_or_no","remove_bad_outfit","Удалить текущий бронекостюм?")
                end
                if has_alife_info("sgm_achievements_legend") and find_out_string(command_line(),"") and find_out_string(command_line(),"") then
		  if db.actor~=nil and dik==DIK_keys.DIK_0 then
		        self:set_0_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_1 then
		        self:set_1_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_2 then
		        self:set_2_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_3 then
		        self:set_3_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_4 then
		        self:set_4_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_5 then
		        self:set_5_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_F1 then
		        self:mod_modes()
		  end
                end
                if find_in_string(command_line(),"") and find_out_string(command_line(),"") then
		  if db.actor~=nil and dik==DIK_keys.DIK_0 then
		        self:set_0_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_1 then
		        self:set_1_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_2 then
		        self:set_2_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_3 then
		        self:set_3_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_4 then
		        self:set_4_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_5 then
		        self:set_5_factor()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_F1 then
		        self:mod_modes()
	          elseif db.actor~=nil and dik==DIK_keys.DIK_F2 then
                        self.OnButton_return_game()
	                run_dynamic_element(ui_mod_spawner.spawn_item_dialog(),false)
                        give_info("spawn_menu_active")
		  elseif db.actor~=nil and dik==DIK_keys.DIK_F3 then
		        self:mod_bonuses()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_F4 then
		        self:mod_rank()
		  elseif db.actor~=nil and dik==DIK_keys.DIK_P then
	                self:mod_money()
		  end
                end
                if find_in_string(command_line(),"") then
		  if dik==DIK_keys.DIK_F1 then
		        self:mod_modes()
	          elseif dik==DIK_keys.DIK_F2 then
                        self.OnButton_return_game()
	                run_dynamic_element(ui_mod_spawner.spawn_item_dialog(),false)
                        give_info("spawn_menu_active")
		  elseif dik==DIK_keys.DIK_F3 then
		        self:mod_bonuses()
		  elseif dik==DIK_keys.DIK_F4 then
		        self:mod_rank()
		  elseif db.actor==nil and dik==DIK_keys.DIK_F5 then
			self:mod_options()
		  elseif dik==DIK_keys.DIK_L then --/Плеер PPE и CAM эффектов.
                        self.OnButton_return_game()
	                run_dynamic_element(ui_mod_elements.effect_player(),false)
		  elseif dik==DIK_keys.DIK_W then --/Специальный редактор, точек путей.
                        self.OnButton_return_game()
                        sgm_flags.bool_is_ui_disabled=true
	                run_dynamic_element(ui_mod_elements.waypoint_editor(),false)
		  elseif dik==DIK_keys.DIK_N then --/Отображать в КПК, смарты.
                        sgm_flags.bool_show_smarts=true
		  elseif dik==DIK_keys.DIK_B then --/Открыть все переходы между локациями.
                        give_info("show_mod_level_changers")
		  elseif dik==DIK_keys.DIK_A then
                        sgm_flags.value_demo_anim_counter=sgm_flags.value_demo_anim_counter+1
                        show_hud_message(sgm_flags.value_demo_anim_counter)
		  elseif dik==DIK_keys.DIK_P then
	                self:mod_money()
		  elseif dik==DIK_keys.DIK_0 then
		        self:set_0_factor()
		  elseif dik==DIK_keys.DIK_1 then
		        self:set_1_factor()
		  elseif dik==DIK_keys.DIK_2 then
		        self:set_2_factor()
		  elseif dik==DIK_keys.DIK_3 then
		        self:set_3_factor()
		  elseif dik==DIK_keys.DIK_4 then
		        self:set_4_factor()
		  elseif dik==DIK_keys.DIK_5 then
		        self:set_5_factor()
		  elseif dik==DIK_keys.DIK_U then --/Из Припяти на Юпитер.
                        give_info("jup_b43_teleport_actor_from_pripyat_to_jupiter")
		  elseif dik==DIK_keys.DIK_I then --/Из Припяти на Затон.
                        give_info("jup_b43_teleport_actor_from_pripyat_to_zaton")
		  elseif dik==DIK_keys.DIK_J then --/Из Затона на Юпитер.
                        give_info("zat_b215_guide_to_jupiter")
		  elseif dik==DIK_keys.DIK_O then --/Из Затона на Припять.
                        give_info("zat_b215_guide_to_pripyat")
		  elseif dik==DIK_keys.DIK_K then --/Из Юпитера на Припять.
                        give_info("jup_b43_teleport_actor_from_jupiter_to_pripyat")
		  elseif dik==DIK_keys.DIK_Z then
                        create("test_npc",db.actor:position().x,db.actor:position().y,db.actor:position().z,db.actor:level_vertex_id(),db.actor:game_vertex_id())
		  elseif dik==DIK_keys.DIK_C then
                        create("snork_normal",db.actor:position().x+3,db.actor:position().y,db.actor:position().z+3,db.actor:level_vertex_id(),db.actor:game_vertex_id())
		  elseif dik==DIK_keys.DIK_V then
                        create_dead_body("stalker_dead_body_1","medkit",db.actor:position().x,db.actor:position().y,db.actor:position().z,db.actor:level_vertex_id(),db.actor:game_vertex_id())
		  elseif dik==DIK_keys.DIK_S then
                        create_force("smart_checker_squad",db.actor:position().x,db.actor:position().y,db.actor:position().z,db.actor:level_vertex_id(),db.actor:game_vertex_id())
		  elseif dik==DIK_keys.DIK_G then
                        create("wpn_abakan",db.actor:position().x,db.actor:position().y,db.actor:position().z,db.actor:level_vertex_id(),db.actor:game_vertex_id())
		  elseif dik==DIK_keys.DIK_M then
                        sgm_functions.write_variable("sleep_factor",0)
		  elseif dik==DIK_keys.DIK_D then
                        if level.name()=="jupiter" then
                           db.actor:set_actor_position(vector():set(358.331,27.367,-329.447))
                        end
                        if level.name()=="jupiter_underground" then
                           db.actor:set_actor_position(vector():set(81.383,4.019,-222.235))
                        end
		  elseif dik==DIK_keys.DIK_X then
                        give_object_to_actor("wpn_g43")
                        give_object_to_actor("wpn_fnfal")
                        give_object_to_actor("detector_omega_up")
                        give_object_to_actor("csky_exo_outfit")
                        give_object_to_actor("helm_battle")
                        give_object_to_actor("skill_book_fnfal")
                        give_object_to_actor("skill_book_g43")
                        dialogs.relocate_item_section(db.actor,"ammo_7.62x54_sv","in",20)
                        dialogs.relocate_item_section(db.actor,"ammo_dumdum","in",10)
                        dialogs.relocate_item_section(db.actor,"ammo_7.62x51_ap","in",100)
                        give_info("sgm_achievements_guidebook")
                        give_info("opt_activate_immortal")
                        give_info("opt_activate_power")
                        give_info("opt_activate_bleeding")
                        give_info("opt_activate_repair")
                        give_info("opt_more_monsters")
                        give_info("opt_marauder_container")
                        give_info("opt_deactivate_minetrap")
                        give_info("opt_activate_automatic_use")
                        give_info("opt_activate_shock_motion")
                        give_info("opt_show_rank_counter")
		  elseif dik==DIK_keys.DIK_R then
                        give_info("pri_expiation_sin_2_taynik_9_zalogen")
                        give_info("pri_expiation_sin_2_reward")
		  end
                end
	end
	return true
end
------------------------------------------------------------------------------
---------------------------------/SGM mod/------------------------------------
------------------------------------------------------------------------------
function main_menu:screenshot_mode_on()
     level.hide_indicators_safe()
     local hud = get_hud()
     hud:HideActorMenu()
     hud:HidePdaMenu()
     give_info("screenshot_mode")
end
function main_menu:screenshot_mode_off()
     level.show_indicators()
     disable_info("screenshot_mode")
end
function main_menu:mod_money()
     if db.actor~=nil then
	dialogs.relocate_money(db.actor,1000000,"in")
     end
end
function main_menu:mod_rank()
     xr_statistic.add_100_trade_rank()
end
function main_menu:mod_bonuses()
     give_mp3_bonus([[Бонусы\Бонус_1]],"mp3_club_bonus_1")
     give_mp3_bonus([[Бонусы\Бонус_2]],"mp3_club_bonus_2")
     give_mp3_bonus([[Бонусы\Бонус_3]],"mp3_club_bonus_3")
     give_mp3_bonus([[Бонусы\Бонус_4]],"mp3_club_bonus_4")
     give_mp3_bonus([[Бонусы\Бонус_5]],"mp3_club_bonus_5")
     give_mp3_bonus([[Бонусы\Бонус_6]],"mp3_club_bonus_6")
     give_mp3_bonus([[Бонусы\Бонус_7]],"mp3_club_bonus_7")
     give_mp3_bonus([[Бонусы\Бонус_8]],"mp3_club_bonus_8")
     give_mp3_bonus([[Бонусы\Бонус_9]],"mp3_club_bonus_9")
     give_mp3_bonus([[Бонусы\Бонус_10]],"mp3_club_bonus_10")
     give_mp3_bonus([[Бонусы\Бонус_11]],"mp3_club_bonus_11")
     give_mp3_bonus([[Бонусы\Бонус_12]],"mp3_club_bonus_12")
     give_mp3_bonus([[Бонусы\Бонус_13]],"mp3_club_bonus_13")
     give_mp3_bonus([[Бонусы\Бонус_14]],"mp3_club_bonus_14")
     give_mp3_bonus([[Бонусы\Бонус_15]],"mp3_club_bonus_15")
     give_mp3_bonus([[Бонусы\Бонус_16]],"mp3_club_bonus_16")
     give_mp3_bonus([[Бонусы\Бонус_17]],"mp3_club_bonus_17")
     give_mp3_bonus([[Бонусы\Бонус_18]],"mp3_club_bonus_18")
     give_mp3_bonus([[Бонусы\Бонус_19]],"mp3_club_bonus_19")
     give_mp3_bonus([[Бонусы\Бонус_20]],"mp3_club_bonus_20")
     give_object_to_actor("mp3_player")
end
function main_menu:OnButton_coord_pos_clicked() 
     text="Позиция:\\nX= "..db.actor:position().x.."\\nY= "..db.actor:position().y.."\\nZ= "..db.actor:position().z.."\\nlevel_vertex= "..db.actor:level_vertex_id().."\\ngame_vertex_id= "..db.actor:game_vertex_id().."\\ndirection= "..db.actor:direction():getH()
     news_manager.send_tip(db.actor,text,0,mutant_hunter,10000,nil,"Координата") 
     fill_log(db.actor:position().x..","..db.actor:position().y..","..db.actor:position().z..","..db.actor:level_vertex_id()..","..db.actor:game_vertex_id())
     --/debug_to_file("points.txt",db.actor:level_vertex_id()..","..db.actor:game_vertex_id())
     debug_to_file("points.txt",db.actor:position().x..","..db.actor:position().y..","..db.actor:position().z..","..db.actor:level_vertex_id()..","..db.actor:game_vertex_id())
     --/debug_treasure_data(66,"points.txt",db.actor:position().x..","..db.actor:position().y..","..db.actor:position().z..","..db.actor:level_vertex_id()..","..db.actor:game_vertex_id())
end
function main_menu:set_0_factor()
     if db.actor~=nil then
        level.set_time_factor(DefaultTimeFactor())
     end
end
function main_menu:set_1_factor()
     if db.actor~=nil then
        level.set_time_factor(50)
     end
end
function main_menu:set_2_factor()
     if db.actor~=nil then
        level.set_time_factor(100)
     end
end
function main_menu:set_3_factor()
     if db.actor~=nil then
        level.set_time_factor(500)
     end
end
function main_menu:set_4_factor()
     if db.actor~=nil then
        level.set_time_factor(1000)
     end
end
function main_menu:set_5_factor()
     if db.actor~=nil then
        level.set_time_factor(5000)
     end
end
function main_menu:mod_modes()
     if self.mod_modes_dlg == nil then
	self.mod_modes_dlg = ui_mod_modes.mod_modes()
	self.mod_modes_dlg.owner = self
     end
     self.mod_modes_dlg:ShowDialog(true)
     self:HideDialog()
     self:Show(false)
end
function main_menu:mod_options()
     if self.mod_dlg == nil then
	self.mod_dlg = ui_mod_options.mod_options()
	self.mod_dlg.owner = self
     end
     self.mod_dlg:ShowDialog(true)
     self:HideDialog()
     self:Show(false)
end