public void LoadPreferences()
        {
            Directory.SetCurrentDirectory(m_filepath_root);

            //m_filepath_root = UserPrefs.GetString("filepath_root", m_filepath_root);
            m_filepath_decal_textures = UserPrefs.GetString("filepath_decal_textures", m_filepath_decal_textures);
            m_filepath_level_textures = UserPrefs.GetString("filepath_level_textures", m_filepath_level_textures);
            m_filepath_decals         = UserPrefs.GetString("filepath_decals", m_filepath_decals);

            m_grid_display = (GridDisplay)UserPrefs.GetInt("grid_display", (int)m_grid_display);
            m_grid_spacing = UserPrefs.GetFloat("grid_spacing", m_grid_spacing);
            SetGridLines();
            m_grid_snap = UserPrefs.GetFloat("grid_snap", m_grid_snap);

            m_extrude_length = UserPrefs.GetFloat("extrude_length", m_extrude_length);
            m_inset_pct      = UserPrefs.GetInt("inset_pct", m_inset_pct);
            m_inset_length   = UserPrefs.GetFloat("inset_length", m_inset_length);
            m_bevel_width    = UserPrefs.GetFloat("bevel_width", m_bevel_width);

            m_coplanar_tol = UserPrefs.GetInt("coplanar_tol", m_coplanar_tol);
            m_side_select  = (SideSelect)UserPrefs.GetInt("side_select", (int)m_side_select);
            m_drag_mode    = (DragMode)UserPrefs.GetInt("drag_mode", (int)m_drag_mode);

            m_view_mode_ortho = (ViewMode)UserPrefs.GetInt("view_mode_ortho", (int)m_view_mode_ortho);
            m_view_mode_persp = (ViewMode)UserPrefs.GetInt("view_mode_persp", (int)m_view_mode_persp);
            m_view_persp_fov  = UserPrefs.GetInt("view_persp_fov", m_view_persp_fov);
            m_view_layout     = (ViewLayout)UserPrefs.GetInt("view_layout", (int)m_view_layout);
            m_bg_color        = (BGColor)UserPrefs.GetInt("bg_color", (int)m_bg_color);
            m_gimbal_display  = (GimbalDisplay)UserPrefs.GetInt("gimbal_display", (int)m_gimbal_display);
            m_lighting_type   = (LightingType)UserPrefs.GetInt("lighting_type", (int)m_lighting_type);
            m_pivot_mode      = (PivotMode)UserPrefs.GetInt("pivot_mode", (int)m_pivot_mode);

            m_low_res_force = UserPrefs.GetBool("low_res_force", m_low_res_force);
            forceLowResTexturesToolStripMenuItem.Checked = m_low_res_force;

            m_tex_list_loc       = UserPrefs.GetPoint("tex_list_loc", texture_list.Location);
            m_tex_list_sz        = UserPrefs.GetPoint("tex_list_sz", (Point)texture_list.Size);
            m_tunnel_builder_loc = UserPrefs.GetPoint("tunnel_builder_loc", tunnel_builder.Location);
            texture_list.Size    = (Size)m_tex_list_sz;

            for (int i = 0; i < RECENT_NUM; i++)
            {
                m_recent_files[i] = UserPrefs.GetString("recent" + i.ToString(), m_recent_files[i]);
            }
            UpdateRecentFileMenu();
        }
        public void SavePreferences()
        {
            //UserPrefs.SetString("filepath_root", m_filepath_root);
            UserPrefs.SetString("filepath_decal_textures", m_filepath_decal_textures);
            UserPrefs.SetString("filepath_level_textures", m_filepath_level_textures);
            UserPrefs.SetString("filepath_decals", m_filepath_decals);

            UserPrefs.SetInt("grid_display", (int)m_grid_display);
            UserPrefs.SetFloat("grid_spacing", m_grid_spacing);
            UserPrefs.SetFloat("grid_snap", m_grid_snap);

            UserPrefs.SetFloat("extrude_length", m_extrude_length);
            UserPrefs.SetInt("inset_pct", m_inset_pct);
            UserPrefs.SetFloat("inset_length", m_inset_length);
            UserPrefs.SetFloat("bevel_width", m_bevel_width);

            UserPrefs.SetInt("coplanar_tol", m_coplanar_tol);
            UserPrefs.SetInt("side_select", (int)m_side_select);
            UserPrefs.SetInt("drag_mode", (int)m_drag_mode);

            UserPrefs.SetInt("view_mode_ortho", (int)m_view_mode_ortho);
            UserPrefs.SetInt("view_mode_persp", (int)m_view_mode_persp);
            UserPrefs.SetInt("view_persp_fov", m_view_persp_fov);
            UserPrefs.SetInt("view_layout", (int)m_view_layout);
            UserPrefs.SetInt("bg_color", (int)m_bg_color);
            UserPrefs.SetInt("gimbal_display", (int)m_gimbal_display);
            UserPrefs.SetInt("lighting_type", (int)m_lighting_type);
            UserPrefs.SetInt("pivot_mode", (int)m_pivot_mode);

            UserPrefs.SetBool("low_res_force", m_low_res_force);

            UserPrefs.SetPoint("tex_list_loc", m_tex_list_loc);
            UserPrefs.SetPoint("tex_list_sz", (Point)texture_list.Size);
            UserPrefs.SetPoint("tunnel_builder_loc", m_tunnel_builder_loc);

            for (int i = 0; i < RECENT_NUM; i++)
            {
                UserPrefs.SetString("recent" + i.ToString(), m_recent_files[i]);
            }

            Directory.SetCurrentDirectory(m_filepath_root);
            UserPrefs.Flush();
        }
        public void StoreLayoutToPreferences(string layout)
        {
            if (string.IsNullOrWhiteSpace(layout))
            {
                m_editor_layout = string.Empty;
            }
            else
            {
                m_editor_layout = layout;
            }

            UserPrefs.SetString("layout", m_editor_layout);

            //Save whether pop-up windows are open
            UserPrefs.SetBool("decal_list_vis", decal_list.Visible);
            UserPrefs.SetBool("tex_list_vis", texture_list.Visible);
            UserPrefs.SetBool("texture_set_list_vis", texture_set_list.Visible);
            UserPrefs.SetBool("uv_editor_vis", uv_editor.Visible);
        }
        public void SavePreferences()
        {
            UserPrefs.SetInt("grid_display", (int)m_grid_display);
            UserPrefs.SetInt("grid_spacing", m_grid_spacing);
            UserPrefs.SetFloat("grid_snap", m_grid_snap);

            UserPrefs.SetInt("coplanar_tol", m_coplanar_tol);
            UserPrefs.SetInt("rotate_angle", m_rotate_angle);
            UserPrefs.SetInt("side_select", (int)m_side_select);
            UserPrefs.SetBool("insert_advance", m_insert_advance);
            UserPrefs.SetInt("drag_mode", (int)m_drag_mode);

            UserPrefs.SetInt("view_mode_ortho", (int)m_view_mode_ortho);
            UserPrefs.SetInt("view_mode_persp", (int)m_view_mode_persp);
            UserPrefs.SetInt("view_persp_fov", m_view_persp_fov);
            UserPrefs.SetInt("view_layout", (int)m_view_layout);
            UserPrefs.SetInt("bg_color", (int)m_bg_color);
            UserPrefs.SetInt("gimbal_display", (int)m_gimbal_display);
            UserPrefs.SetInt("lighting_type", (int)m_lighting_type);
            UserPrefs.SetInt("clip_decal", (int)m_cp_display);
            UserPrefs.SetInt("insert_decal", (int)m_insert_decal);
            UserPrefs.SetInt("show_segment_numbers", (int)m_show_3d_text_type);
            UserPrefs.SetBool("auto_center", m_auto_center);

            UserPrefs.SetInt("entity_pivot", (int)m_pivot_mode);

            UserPrefs.SetPoint("decal_list_loc", m_decal_list_loc);
            UserPrefs.SetPoint("decal_list_sz", (Point)decal_list.Size);
            UserPrefs.SetPoint("tex_list_loc", m_tex_list_loc);
            UserPrefs.SetPoint("tex_list_sz", (Point)texture_list.Size);
            UserPrefs.SetPoint("texture_set_list_loc", m_texture_set_list_loc);
            UserPrefs.SetPoint("texture_set_list_sz", (Point)texture_set_list.Size);
            UserPrefs.SetPoint("uv_editor_loc", m_uv_editor_loc);
            UserPrefs.SetPoint("uv_editor_sz", (Point)uv_editor.RestoreBounds.Size);

            UserPrefs.SetInt("mm_edit_type", (int)m_mm_edit_type);
            UserPrefs.SetInt("mm_op_mode", (int)m_mm_op_mode);

            for (int i = 0; i < NumRecentFiles; i++)
            {
                UserPrefs.SetString(string.Format("recent{0}", i), GetRecentFile(i));
            }

#if !PUBLIC_RELEASE
            UserPrefs.SetString("m_cached_username", Overload.Perforce.m_cached_username);
            UserPrefs.SetString("m_cached_clientname", Overload.Perforce.m_cached_clientname);
#endif // !PUBLIC_RELEASE

            //Pack texture collections into string
            if (TextureCollections.Count > 0)
            {
                UserPrefs.SetInt("num_texture_collections", TextureCollections.Count);
                int num = 0;
                foreach (TextureCollection collection in TextureCollections)
                {
                    UserPrefs.SetString("texture_collection_" + num, collection.Serialize());
                    num++;
                }
            }

            Directory.SetCurrentDirectory(m_filepath_root);
            UserPrefs.Flush();
        }
        public void LoadPreferences()
        {
            Directory.SetCurrentDirectory(m_filepath_root);

            m_grid_display = (GridDisplay)UserPrefs.GetInt("grid_display", (int)m_grid_display);
            m_grid_spacing = UserPrefs.GetInt("grid_spacing", m_grid_spacing);
            m_grid_snap    = UserPrefs.GetFloat("grid_snap", m_grid_snap);

            m_coplanar_tol   = UserPrefs.GetInt("coplanar_tol", m_coplanar_tol);
            m_rotate_angle   = UserPrefs.GetInt("rotate_angle", m_rotate_angle);
            m_side_select    = (SideSelect)UserPrefs.GetInt("side_select", (int)m_side_select);
            m_insert_advance = UserPrefs.GetBool("insert_advance", m_insert_advance);
            m_drag_mode      = (DragMode)UserPrefs.GetInt("drag_mode", (int)m_drag_mode);

            m_view_mode_ortho   = (ViewMode)UserPrefs.GetInt("view_mode_ortho", (int)m_view_mode_ortho);
            m_view_mode_persp   = (ViewMode)UserPrefs.GetInt("view_mode_persp", (int)m_view_mode_persp);
            m_view_persp_fov    = UserPrefs.GetInt("view_persp_fov", m_view_persp_fov);
            m_view_layout       = (ViewLayout)UserPrefs.GetInt("view_layout", (int)m_view_layout);
            m_bg_color          = (BGColor)UserPrefs.GetInt("bg_color", (int)m_bg_color);
            m_gimbal_display    = (GimbalDisplay)UserPrefs.GetInt("gimbal_display", (int)m_gimbal_display);
            m_lighting_type     = (LightingType)UserPrefs.GetInt("lighting_type", (int)m_lighting_type);
            m_cp_display        = (ClipPlaneDisplay)UserPrefs.GetInt("clip_decal", (int)m_cp_display);
            m_insert_decal      = (InsertDecal)UserPrefs.GetInt("insert_decal", (int)m_insert_decal);
            m_show_3d_text_type = (ShowTextType)UserPrefs.GetInt("show_segment_numbers", (int)m_show_3d_text_type);
            m_auto_center       = UserPrefs.GetBool("auto_center", m_auto_center);

            m_decal_list_loc       = UserPrefs.GetPoint("decal_list_loc", decal_list.Location);
            m_decal_list_sz        = UserPrefs.GetPoint("decal_list_sz", (Point)decal_list.Size);
            m_tex_list_loc         = UserPrefs.GetPoint("tex_list_loc", texture_list.Location);
            m_tex_list_sz          = UserPrefs.GetPoint("tex_list_sz", (Point)texture_list.Size);
            m_texture_set_list_loc = UserPrefs.GetPoint("texture_set_list_loc", texture_list.Location);
            m_texture_set_list_sz  = UserPrefs.GetPoint("texture_set_list_sz", (Point)texture_list.Size);
            m_uv_editor_loc        = UserPrefs.GetPoint("uv_editor_loc", uv_editor.Location);
            m_uv_editor_sz         = UserPrefs.GetPoint("uv_editor_sz", (Point)uv_editor.Size);

            decal_list.Size   = (Size)m_decal_list_sz;
            texture_list.Size = (Size)m_tex_list_sz;
            uv_editor.Size    = (Size)m_uv_editor_sz;

            for (int i = 0; i < NumRecentFiles; i++)
            {
                string recent_file = GetRecentFile(i);
                SetRecentFile(i, UserPrefs.GetString("recent" + i.ToString(), recent_file));
            }
            Shell.UpdateRecentFileMenu();

            m_pivot_mode = (PivotMode)UserPrefs.GetInt("entity_pivot", (int)m_pivot_mode);

            m_editor_layout = UserPrefs.GetString("layout", string.Empty);

            //Save whether pop-up windows are open at startup
            m_decal_list_visible       = UserPrefs.GetBool("decal_list_vis", false);
            m_texture_list_visible     = UserPrefs.GetBool("tex_list_vis", false);
            m_texture_set_list_visible = UserPrefs.GetBool("texture_set_list_vis", false);
            m_uv_editor_visible        = UserPrefs.GetBool("uv_editor_vis", false);

#if !PUBLIC_RELEASE
            Overload.Perforce.m_cached_username   = UserPrefs.GetString("m_cached_username", string.Empty);
            Overload.Perforce.m_cached_clientname = UserPrefs.GetString("m_cached_clientname", string.Empty);
#endif // !PUBLIC_RELEASE

            m_mm_edit_type = (EditMode)UserPrefs.GetInt("mm_edit_type", (int)m_mm_edit_type);
            m_mm_op_mode   = (OperationMode)UserPrefs.GetInt("mm_op_mode", (int)m_mm_op_mode);

            //Read texture collections
            int num_texture_collections = UserPrefs.GetInt("num_texture_collections", 0);
            for (int c = 0; c < num_texture_collections; c++)
            {
                TextureCollections.Add(new TextureCollection(UserPrefs.GetString("texture_collection_" + c), true));
            }
        }