#pragma once #include "core/types.h" #include #include #include #include #include class ByteStream; namespace GameSettings { enum class Trait : u32 { ForceInterpreter, ForceSoftwareRenderer, ForceSoftwareRendererForReadbacks, ForceInterlacing, DisableTrueColor, DisableUpscaling, DisableScaledDithering, DisableForceNTSCTimings, DisableWidescreen, DisablePGXP, DisablePGXPCulling, DisablePGXPTextureCorrection, DisablePGXPDepthBuffer, ForcePGXPVertexCache, ForcePGXPCPUMode, ForceRecompilerMemoryExceptions, ForceRecompilerICache, ForceRecompilerLUTFastmem, Count }; const char* GetTraitName(Trait trait); const char* GetTraitDisplayName(Trait trait); struct Entry { std::bitset(Trait::Count)> traits{}; std::optional display_active_start_offset; std::optional display_active_end_offset; std::optional display_line_start_offset; std::optional display_line_end_offset; std::optional dma_max_slice_ticks; std::optional dma_halt_ticks; std::optional gpu_fifo_size; std::optional gpu_max_run_ahead; std::optional gpu_pgxp_tolerance; std::optional gpu_pgxp_depth_threshold; // user settings std::optional runahead_frames; std::optional cpu_overclock_numerator; std::optional cpu_overclock_denominator; std::optional cpu_overclock_enable; std::optional enable_8mb_ram; std::optional cdrom_read_speedup; std::optional cdrom_seek_speedup; std::optional display_crop_mode; std::optional display_aspect_ratio; std::optional gpu_renderer; std::optional gpu_downsample_mode; std::optional display_linear_upscaling; std::optional display_integer_upscaling; std::optional display_force_4_3_for_24bit; std::optional display_aspect_ratio_custom_numerator; std::optional display_aspect_ratio_custom_denominator; std::optional gpu_resolution_scale; std::optional gpu_multisamples; std::optional gpu_per_sample_shading; std::optional gpu_true_color; std::optional gpu_scaled_dithering; std::optional gpu_force_ntsc_timings; std::optional gpu_texture_filter; std::optional gpu_widescreen_hack; std::optional gpu_pgxp; std::optional gpu_pgxp_projection_precision; std::optional gpu_pgxp_depth_buffer; std::optional multitap_mode; std::optional controller_1_type; std::optional controller_2_type; std::optional memory_card_1_type; std::optional memory_card_2_type; std::string memory_card_1_shared_path; std::string memory_card_2_shared_path; std::string input_profile_name; ALWAYS_INLINE bool HasTrait(Trait trait) const { return traits[static_cast(trait)]; } ALWAYS_INLINE void AddTrait(Trait trait) { traits[static_cast(trait)] = true; } ALWAYS_INLINE void RemoveTrait(Trait trait) { traits[static_cast(trait)] = false; } ALWAYS_INLINE void SetTrait(Trait trait, bool enabled) { traits[static_cast(trait)] = enabled; } bool LoadFromStream(ByteStream* stream); bool SaveToStream(ByteStream* stream) const; u32 GetUserSettingsCount() const; void ApplySettings(bool display_osd_messages) const; // Key-based interface, used by Android. std::optional GetValueForKey(const std::string_view& key) const; void SetValueForKey(const std::string_view& key, const std::optional& value); }; class Database { public: Database(); ~Database(); const Entry* GetEntry(const std::string& code) const; void SetEntry(const std::string& code, const std::string& name, const Entry& entry, const char* save_path); bool Load(const std::string_view& ini_data); private: std::unordered_map m_entries; }; }; // namespace GameSettings