note description: "[ m_misc.c Main loop menu stuff. Default Config File. PCX Screenshots. ]" license: "[ Copyright (C) 1993-1996 by id Software, Inc. Copyright (C) 2005-2014 Simon Howard Copyright (C) 2021 Ilgiz Mustafin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ]" class M_MISC inherit DOOMDEF_H create make feature i_main: I_MAIN make (a_i_main: like i_main) do i_main := a_i_main end feature usemouse: INTEGER_32 assign set_usemouse set_usemouse (a_usemouse: like usemouse) do usemouse := a_usemouse end usejoystick: INTEGER_32 assign set_usejoystick set_usejoystick (a_usejoystick: like usejoystick) do usejoystick := a_usejoystick end feature Defaults: ARRAYED_LIST [TUPLE [name: STRING_8; set_value: PROCEDURE [INTEGER_32]; defaultvalue: INTEGER_32]] once create Result.make (0) Result.extend (["mouse_sensitivity", agent i_main.M_menu.set_mousesensitivity, 5]) Result.extend (["sfx_volume", agent i_main.S_sound.set_snd_sfxvolume, 8]) Result.extend (["music_volume", agent i_main.S_sound.set_snd_musicvolume, 2]) Result.extend (["show_messages", agent i_main.M_menu.set_showmessages, 1]) Result.extend (["key_right", agent i_main.G_game.set_key_right, Key_rightarrow]) Result.extend (["key_left", agent i_main.G_game.set_key_left, Key_leftarrow]) Result.extend (["key_up", agent i_main.G_game.set_key_up, Key_uparrow]) Result.extend (["key_down", agent i_main.G_game.set_key_down, Key_downarrow]) Result.extend (["key_strafeleft", agent i_main.G_game.set_key_strafeleft, (',').code]) Result.extend (["key_straferight", agent i_main.G_game.set_key_straferight, ('.').code]) Result.extend (["key_fire", agent i_main.G_game.set_key_fire, Key_rctrl]) Result.extend (["key_use", agent i_main.G_game.set_key_use, (' ').code]) Result.extend (["key_strafe", agent i_main.G_game.set_key_strafe, Key_ralt]) Result.extend (["key_speed", agent i_main.G_game.set_key_speed, Key_rshift]) Result.extend (["use_mouse", agent set_usemouse, 1]) Result.extend (["key_debug_a", agent i_main.G_game.set_key_debug_a, ('n').code]) Result.extend (["key_debug_b", agent i_main.G_game.set_key_debug_b, ('m').code]) Result.extend (["mouseb_fire", agent i_main.G_game.set_mousebfire, 0]) Result.extend (["mouseb_strafe", agent i_main.G_game.set_mousebstrafe, 1]) Result.extend (["mouseb_forward", agent i_main.G_game.set_mousebforward, 2]) Result.extend (["use_joystick", agent set_usejoystick, 0]) Result.extend (["joyb_fire", agent i_main.G_game.set_joybfire, 0]) Result.extend (["joyb_strafe", agent i_main.G_game.set_joybstrafe, 1]) Result.extend (["joyb_use", agent i_main.G_game.set_joybuse, 3]) Result.extend (["joyb_speed", agent i_main.G_game.set_joybspeed, 2]) Result.extend (["screenblocks", agent i_main.M_menu.set_screenblocks, 9]) Result.extend (["detaillevel", agent i_main.M_menu.set_detaillevel, 0]) Result.extend (["snd_channels", agent i_main.S_sound.set_numchannels, 3]) Result.extend (["usegamma", agent i_main.V_video.set_usegamma, 0]) end feature m_loaddefaults do across Defaults as d loop d.item.set_value.call (d.item.defaultvalue) end {NOT_IMPLEMENTED}.not_implemented ("M_LoadDefaults", False) print ("Loading WASD keys from code%N") i_main.G_game.key_up := ('w').code i_main.G_game.key_down := ('s').code i_main.G_game.key_strafeleft := ('a').code i_main.G_game.key_straferight := ('d').code print ("Setting novert%N") i_main.I_input.novert := 1 print ("Setting mouse acceleration%N") i_main.I_input.mouse_acceleration := 5.to_real end m_screenshot do {NOT_IMPLEMENTED}.not_implemented ("M_ScreenShot", False) end m_tempfile (s: STRING_8): STRING_8 -- Returns the path to a temporary file of the given name, -- stored inside the system temporary directory. -- -- The returned value must be freed with Z_Free after use. local tempdir: STRING_8 do tempdir := "/tmp" Result := tempdir + Operating_environment.Directory_separator.out + s end m_writefile_managed_pointer (name: STRING_8; source: MANAGED_POINTER): BOOLEAN local handle: RAW_FILE do create handle.make_open_write (name) if handle.is_writable then handle.put_managed_pointer (source, 0, source.count) handle.close Result := True end end m_writefile_list (name: STRING_8; source: LIST [NATURAL_8]): BOOLEAN local handle: RAW_FILE do create handle.make_open_write (name) if handle.is_writable then across source as s loop handle.put_natural_8 (s.item) end handle.close Result := True end end m_dirname (path: STRING_8): STRING_8 -- Returns the directory portion of the given path, -- without the trailing slash separator character. -- If no directory is described in the path, -- the string "." is returned. In either case, the result is newly -- allocated and must be freed by the caller after use. local last_sep: INTEGER_32 do last_sep := path.last_index_of (Operating_environment.Directory_separator, path.count) if last_sep = 0 then Result := "." else Result := path.substring (1, last_sep - 1) end end end -- class M_MISC
Generated by ISE EiffelStudio