2015-12-06 10:18:31 +00:00
# include "state.hpp"
# include <stdexcept>
2015-12-06 11:06:28 +00:00
# include <algorithm>
2015-12-08 16:21:58 +00:00
# include <sstream>
# include "intsetting.hpp"
2015-12-10 09:58:38 +00:00
# include "doublesetting.hpp"
2015-12-10 12:28:48 +00:00
# include "boolsetting.hpp"
2015-12-11 10:15:14 +00:00
# include "coloursetting.hpp"
2016-07-08 03:45:02 +00:00
# include "shortcutsetting.hpp"
2016-07-27 17:53:33 +00:00
# include "modifiersetting.hpp"
2015-12-06 10:18:31 +00:00
CSMPrefs : : State * CSMPrefs : : State : : sThis = 0 ;
void CSMPrefs : : State : : load ( )
{
// default settings file
boost : : filesystem : : path local = mConfigurationManager . getLocalPath ( ) / mConfigFile ;
boost : : filesystem : : path global = mConfigurationManager . getGlobalPath ( ) / mConfigFile ;
if ( boost : : filesystem : : exists ( local ) )
mSettings . loadDefault ( local . string ( ) ) ;
else if ( boost : : filesystem : : exists ( global ) )
mSettings . loadDefault ( global . string ( ) ) ;
else
2015-12-15 13:51:25 +00:00
throw std : : runtime_error ( " No default settings file found! Make sure the file \" openmw-cs.cfg \" was properly installed. " ) ;
2015-12-06 10:18:31 +00:00
// user settings file
boost : : filesystem : : path user = mConfigurationManager . getUserConfigPath ( ) / mConfigFile ;
if ( boost : : filesystem : : exists ( user ) )
mSettings . loadUser ( user . string ( ) ) ;
}
void CSMPrefs : : State : : declare ( )
{
2015-12-08 08:56:42 +00:00
declareCategory ( " Windows " ) ;
2015-12-08 16:21:58 +00:00
declareInt ( " default-width " , " Default window width " , 800 ) .
setTooltip ( " Newly opened top-level windows will open with this width. " ) .
setMin ( 80 ) ;
declareInt ( " default-height " , " Default window height " , 600 ) .
setTooltip ( " Newly opened top-level windows will open with this height. " ) .
setMin ( 80 ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " show-statusbar " , " Show Status Bar " , true ) .
setTooltip ( " If a newly open top level window is showing status bars or not. "
" Note that this does not affect existing windows. " ) ;
2015-12-11 10:32:55 +00:00
declareSeparator ( ) ;
declareBool ( " reuse " , " Reuse Subviews " , true ) .
setTooltip ( " When a new subview is requested and a matching subview already "
" exist, do not open a new subview and use the existing one instead. " ) ;
2015-12-08 16:21:58 +00:00
declareInt ( " max-subviews " , " Maximum number of subviews per top-level window " , 256 ) .
setTooltip ( " If the maximum number is reached and a new subview is opened "
" it will be placed into a new top-level window. " ) .
setRange ( 1 , 256 ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " hide-subview " , " Hide single subview " , false ) .
setTooltip ( " When a view contains only a single subview, hide the subview title "
" bar and if this subview is closed also close the view (unless it is the last "
" view for this document) " ) ;
2015-12-08 16:21:58 +00:00
declareInt ( " minimum-width " , " Minimum subview width " , 325 ) .
setTooltip ( " Minimum width of subviews. " ) .
setRange ( 50 , 10000 ) ;
2015-12-11 10:32:55 +00:00
declareSeparator ( ) ;
2015-12-10 16:33:14 +00:00
EnumValue scrollbarOnly ( " Scrollbar Only " , " Simple addition of scrollbars, the view window "
" does not grow automatically. " ) ;
declareEnum ( " mainwindow-scrollbar " , " Horizontal scrollbar mode for main window. " , scrollbarOnly ) .
addValue ( scrollbarOnly ) .
addValue ( " Grow Only " , " The view window grows as subviews are added. No scrollbars. " ) .
addValue ( " Grow then Scroll " , " The view window grows. The scrollbar appears once it cannot grow any further. " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " grow-limit " , " Grow Limit Screen " , false ) .
setTooltip ( " When \" Grow then Scroll \" option is selected, the window size grows to "
" the width of the virtual desktop. \n If this option is selected the the window growth "
" is limited to the current screen. " ) ;
2015-12-06 10:18:31 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " Records " ) ;
2015-12-10 16:33:14 +00:00
EnumValue iconAndText ( " Icon and Text " ) ;
EnumValues recordValues ;
2015-12-15 11:26:08 +00:00
recordValues . add ( iconAndText ) . add ( " Icon Only " ) . add ( " Text Only " ) ;
2015-12-10 16:33:14 +00:00
declareEnum ( " status-format " , " Modification status display format " , iconAndText ) .
addValues ( recordValues ) ;
declareEnum ( " type-format " , " ID type display format " , iconAndText ) .
addValues ( recordValues ) ;
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " ID Tables " ) ;
2015-12-10 16:33:14 +00:00
EnumValue inPlaceEdit ( " Edit in Place " , " Edit the clicked cell " ) ;
EnumValue editRecord ( " Edit Record " , " Open a dialogue subview for the clicked record " ) ;
EnumValue view ( " View " , " Open a scene subview for the clicked record (not available everywhere) " ) ;
EnumValue editRecordAndClose ( " Edit Record and Close " ) ;
EnumValues doubleClickValues ;
doubleClickValues . add ( inPlaceEdit ) . add ( editRecord ) . add ( view ) . add ( " Revert " ) .
add ( " Delete " ) . add ( editRecordAndClose ) .
add ( " View and Close " , " Open a scene subview for the clicked record and close the table subview " ) ;
declareEnum ( " double " , " Double Click " , inPlaceEdit ) . addValues ( doubleClickValues ) ;
declareEnum ( " double-s " , " Shift Double Click " , editRecord ) . addValues ( doubleClickValues ) ;
declareEnum ( " double-c " , " Control Double Click " , view ) . addValues ( doubleClickValues ) ;
declareEnum ( " double-sc " , " Shift Control Double Click " , editRecordAndClose ) . addValues ( doubleClickValues ) ;
2015-12-11 10:32:55 +00:00
declareSeparator ( ) ;
2015-12-10 16:33:14 +00:00
EnumValue jumpAndSelect ( " Jump and Select " , " Scroll new record into view and make it the selection " ) ;
declareEnum ( " jump-to-added " , " Action on adding or cloning a record " , jumpAndSelect ) .
addValue ( jumpAndSelect ) .
addValue ( " Jump Only " , " Scroll new record into view " ) .
addValue ( " No Jump " , " No special action " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " extended-config " ,
" Manually specify affected record types for an extended delete/revert " , false ) .
setTooltip ( " Delete and revert commands have an extended form that also affects "
" associated records. \n \n "
" If this option is enabled, types of affected records are selected "
" manually before a command execution. \n Otherwise, all associated "
" records are deleted/reverted immediately. " ) ;
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " ID Dialogues " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " toolbar " , " Show toolbar " , true ) ;
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " Reports " ) ;
2015-12-10 16:33:14 +00:00
EnumValue actionNone ( " None " ) ;
EnumValue actionEdit ( " Edit " , " Open a table or dialogue suitable for addressing the listed report " ) ;
EnumValue actionRemove ( " Remove " , " Remove the report from the report table " ) ;
EnumValue actionEditAndRemove ( " Edit And Remove " , " Open a table or dialogue suitable for addressing the listed report, then remove the report from the report table " ) ;
EnumValues reportValues ;
reportValues . add ( actionNone ) . add ( actionEdit ) . add ( actionRemove ) . add ( actionEditAndRemove ) ;
declareEnum ( " double " , " Double Click " , actionEdit ) . addValues ( reportValues ) ;
declareEnum ( " double-s " , " Shift Double Click " , actionRemove ) . addValues ( reportValues ) ;
declareEnum ( " double-c " , " Control Double Click " , actionEditAndRemove ) . addValues ( reportValues ) ;
declareEnum ( " double-sc " , " Shift Control Double Click " , actionNone ) . addValues ( reportValues ) ;
2018-06-19 22:20:03 +00:00
declareBool ( " ignore-base-records " , " Ignore base records in verifier " , false ) ;
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " Search & Replace " ) ;
2015-12-08 16:21:58 +00:00
declareInt ( " char-before " , " Characters before search string " , 10 ) .
setTooltip ( " Maximum number of character to display in search result before the searched text " ) ;
declareInt ( " char-after " , " Characters after search string " , 10 ) .
setTooltip ( " Maximum number of character to display in search result after the searched text " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " auto-delete " , " Delete row from result table after a successful replace " , true ) ;
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " Scripts " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " show-linenum " , " Show Line Numbers " , true ) .
setTooltip ( " Show line numbers to the left of the script editor window. "
" The current row and column numbers of the text cursor are shown at the bottom. " ) ;
2016-01-28 11:28:31 +00:00
declareBool ( " wrap-lines " , " Wrap Lines " , false ) .
setTooltip ( " Wrap lines longer than width of script editor. " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " mono-font " , " Use monospace font " , true ) ;
2016-04-17 00:43:10 +00:00
declareInt ( " tab-width " , " Tab Width " , 4 ) .
setTooltip ( " Number of characters for tab width " ) .
setRange ( 1 , 10 ) ;
2015-12-10 16:33:14 +00:00
EnumValue warningsNormal ( " Normal " , " Report warnings as warning " ) ;
declareEnum ( " warnings " , " Warning Mode " , warningsNormal ) .
addValue ( " Ignore " , " Do not report warning " ) .
addValue ( warningsNormal ) .
2016-01-26 18:41:05 +00:00
addValue ( " Strict " , " Promote warning to an error " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " toolbar " , " Show toolbar " , true ) ;
2015-12-08 16:21:58 +00:00
declareInt ( " compile-delay " , " Delay between updating of source errors " , 100 ) .
setTooltip ( " Delay in milliseconds " ) .
setRange ( 0 , 10000 ) ;
declareInt ( " error-height " , " Initial height of the error panel " , 100 ) .
setRange ( 100 , 10000 ) ;
2017-04-28 07:57:49 +00:00
declareBool ( " highlight-occurrences " , " Highlight other occurrences of selected names " , true ) ;
2017-07-23 08:24:18 +00:00
declareColour ( " colour-highlight " , " Colour of highlighted occurrences " , QColor ( " lightcyan " ) ) ;
2015-12-11 10:32:55 +00:00
declareSeparator ( ) ;
2015-12-11 10:15:14 +00:00
declareColour ( " colour-int " , " Highlight Colour: Integer Literals " , QColor ( " darkmagenta " ) ) ;
declareColour ( " colour-float " , " Highlight Colour: Float Literals " , QColor ( " magenta " ) ) ;
declareColour ( " colour-name " , " Highlight Colour: Names " , QColor ( " grey " ) ) ;
declareColour ( " colour-keyword " , " Highlight Colour: Keywords " , QColor ( " red " ) ) ;
declareColour ( " colour-special " , " Highlight Colour: Special Characters " , QColor ( " darkorange " ) ) ;
declareColour ( " colour-comment " , " Highlight Colour: Comments " , QColor ( " green " ) ) ;
declareColour ( " colour-id " , " Highlight Colour: IDs " , QColor ( " blue " ) ) ;
2015-12-14 16:38:33 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " General Input " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " cycle " , " Cyclic next/previous " , false ) .
setTooltip ( " When using next/previous functions at the last/first item of a "
" list go to the first/last item " ) ;
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " 3D Scene Input " ) ;
2017-12-15 16:22:32 +00:00
declareDouble ( " navi-wheel-factor " , " Camera Zoom Sensitivity " , 8 ) . setRange ( - 100.0 , 100.0 ) ;
declareDouble ( " s-navi-sensitivity " , " Secondary Camera Movement Sensitivity " , 50.0 ) . setRange ( - 1000.0 , 1000.0 ) ;
declareSeparator ( ) ;
2016-04-04 22:42:57 +00:00
declareDouble ( " p-navi-free-sensitivity " , " Free Camera Sensitivity " , 1 / 650. ) . setPrecision ( 5 ) . setRange ( 0.0 , 1.0 ) ;
declareBool ( " p-navi-free-invert " , " Invert Free Camera Mouse Input " , false ) ;
2016-03-26 02:19:44 +00:00
declareDouble ( " navi-free-lin-speed " , " Free Camera Linear Speed " , 1000.0 ) . setRange ( 1.0 , 10000.0 ) ;
2017-12-15 16:22:32 +00:00
declareDouble ( " navi-free-rot-speed " , " Free Camera Rotational Speed " , 3.14 / 2 ) . setRange ( 0.001 , 6.28 ) ;
2016-03-26 02:19:44 +00:00
declareDouble ( " navi-free-speed-mult " , " Free Camera Speed Multiplier (from Modifier) " , 8 ) . setRange ( 0.001 , 1000.0 ) ;
2017-12-15 16:22:32 +00:00
declareSeparator ( ) ;
declareDouble ( " p-navi-orbit-sensitivity " , " Orbit Camera Sensitivity " , 1 / 650. ) . setPrecision ( 5 ) . setRange ( 0.0 , 1.0 ) ;
declareBool ( " p-navi-orbit-invert " , " Invert Orbit Camera Mouse Input " , false ) ;
2016-03-26 02:19:44 +00:00
declareDouble ( " navi-orbit-rot-speed " , " Orbital Camera Rotational Speed " , 3.14 / 4 ) . setRange ( 0.001 , 6.28 ) ;
declareDouble ( " navi-orbit-speed-mult " , " Orbital Camera Speed Multiplier (from Modifier) " , 4 ) . setRange ( 0.001 , 1000.0 ) ;
2017-12-08 19:51:40 +00:00
declareBool ( " navi-orbit-const-roll " , " Keep camera roll constant for orbital camera " , true ) ;
2015-12-11 10:32:55 +00:00
declareSeparator ( ) ;
2017-12-15 16:22:32 +00:00
2015-12-10 12:28:48 +00:00
declareBool ( " context-select " , " Context Sensitive Selection " , false ) ;
2015-12-10 09:58:38 +00:00
declareDouble ( " drag-factor " , " Mouse sensitivity during drag operations " , 1.0 ) .
setRange ( 0.001 , 100.0 ) ;
declareDouble ( " drag-wheel-factor " , " Mouse wheel sensitivity during drag operations " , 1.0 ) .
setRange ( 0.001 , 100.0 ) ;
declareDouble ( " drag-shift-factor " ,
" Shift-acceleration factor during drag operations " , 4.0 ) .
setTooltip ( " Acceleration factor during drag operations while holding down shift " ) .
setRange ( 0.001 , 100.0 ) ;
2016-08-15 19:07:43 +00:00
declareDouble ( " rotate-factor " , " Free rotation factor " , 0.007 ) . setPrecision ( 4 ) . setRange ( 0.0001 , 0.1 ) ;
2015-12-06 11:06:28 +00:00
2017-12-07 22:48:34 +00:00
declareCategory ( " Rendering " ) ;
2017-12-15 13:46:23 +00:00
declareInt ( " camera-fov " , " Camera FOV " , 90 ) . setRange ( 10 , 170 ) ;
2017-12-08 17:18:27 +00:00
declareBool ( " camera-ortho " , " Orthographic projection for camera " , false ) ;
2017-12-15 13:56:03 +00:00
declareInt ( " camera-ortho-size " , " Orthographic projection size parameter " , 100 ) .
setTooltip ( " Size of the orthographic frustum, greater value will allow the camera to see more of the world. " ) .
setRange ( 10 , 10000 ) ;
2017-12-15 13:36:12 +00:00
declareDouble ( " object-marker-alpha " , " Object Marker Transparency " , 0.5 ) . setPrecision ( 2 ) . setRange ( 0 , 1 ) ;
2017-12-07 22:48:34 +00:00
2015-12-08 08:56:42 +00:00
declareCategory ( " Tooltips " ) ;
2015-12-10 12:28:48 +00:00
declareBool ( " scene " , " Show Tooltips in 3D scenes " , true ) ;
declareBool ( " scene-hide-basic " , " Hide basic 3D scenes tooltips " , false ) ;
2015-12-08 16:21:58 +00:00
declareInt ( " scene-delay " , " Tooltip delay in milliseconds " , 500 ) .
setMin ( 1 ) ;
2016-01-11 08:03:02 +00:00
2016-01-14 12:20:01 +00:00
EnumValue createAndInsert ( " Create cell and insert " ) ;
EnumValue showAndInsert ( " Show cell and insert " ) ;
EnumValue dontInsert ( " Discard " ) ;
EnumValue insertAnyway ( " Insert anyway " ) ;
EnumValues insertOutsideCell ;
insertOutsideCell . add ( createAndInsert ) . add ( dontInsert ) . add ( insertAnyway ) ;
EnumValues insertOutsideVisibleCell ;
insertOutsideVisibleCell . add ( showAndInsert ) . add ( dontInsert ) . add ( insertAnyway ) ;
2018-04-29 12:17:06 +00:00
EnumValue createAndLandEdit ( " Create cell and land, then edit " ) ;
EnumValue showAndLandEdit ( " Show cell and edit " ) ;
EnumValue dontLandEdit ( " Discard " ) ;
EnumValues landeditOutsideCell ;
landeditOutsideCell . add ( createAndLandEdit ) . add ( dontLandEdit ) ;
EnumValues landeditOutsideVisibleCell ;
landeditOutsideVisibleCell . add ( showAndLandEdit ) . add ( dontLandEdit ) ;
2018-05-16 08:41:37 +00:00
declareCategory ( " 3D Scene Editing " ) ;
2016-01-11 08:03:02 +00:00
declareInt ( " distance " , " Drop Distance " , 50 ) .
setTooltip ( " If an instance drop can not be placed against another object at the "
" insert point, it will be placed by this distance from the insert point instead " ) ;
2016-01-14 12:20:01 +00:00
declareEnum ( " outside-drop " , " Handling drops outside of cells " , createAndInsert ) .
addValues ( insertOutsideCell ) ;
declareEnum ( " outside-visible-drop " , " Handling drops outside of visible cells " , showAndInsert ) .
addValues ( insertOutsideVisibleCell ) ;
2018-04-29 12:17:06 +00:00
declareEnum ( " outside-landedit " , " Handling land edit outside of cells " , createAndLandEdit ) .
addValues ( landeditOutsideCell ) ;
declareEnum ( " outside-visible-landedit " , " Handling land edit outside of visible cells " , showAndLandEdit ) .
addValues ( landeditOutsideVisibleCell ) ;
2018-05-18 08:32:42 +00:00
declareInt ( " texturebrush-maximumsize " , " Maximum texture brush size " , 50 ) .
setMin ( 1 ) ;
2016-07-08 03:45:02 +00:00
declareCategory ( " Key Bindings " ) ;
2016-07-24 01:23:02 +00:00
2016-07-27 23:15:24 +00:00
declareSubcategory ( " Document " ) ;
2016-07-29 19:00:58 +00:00
declareShortcut ( " document-file-newgame " , " New Game " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_N ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-file-newaddon " , " New Addon " , QKeySequence ( ) ) ;
2016-07-29 19:00:58 +00:00
declareShortcut ( " document-file-open " , " Open " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_O ) ) ;
2016-07-27 04:24:16 +00:00
declareShortcut ( " document-file-save " , " Save " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_S ) ) ;
2016-07-28 01:40:53 +00:00
declareShortcut ( " document-file-verify " , " Verify " , QKeySequence ( ) ) ;
2016-07-27 04:24:16 +00:00
declareShortcut ( " document-file-merge " , " Merge " , QKeySequence ( ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-file-errorlog " , " Open Load Error Log " , QKeySequence ( ) ) ;
2016-07-27 04:24:16 +00:00
declareShortcut ( " document-file-metadata " , " Meta Data " , QKeySequence ( ) ) ;
2016-07-29 19:00:58 +00:00
declareShortcut ( " document-file-close " , " Close Document " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_W ) ) ;
declareShortcut ( " document-file-exit " , " Exit Application " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_Q ) ) ;
2016-07-27 04:24:16 +00:00
declareShortcut ( " document-edit-undo " , " Undo " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_Z ) ) ;
declareShortcut ( " document-edit-redo " , " Redo " , QKeySequence ( Qt : : ControlModifier | Qt : : ShiftModifier | Qt : : Key_Z ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-edit-preferences " , " Open Preferences " , QKeySequence ( ) ) ;
2016-07-29 19:00:58 +00:00
declareShortcut ( " document-edit-search " , " Search " , QKeySequence ( Qt : : ControlModifier | Qt : : Key_F ) ) ;
2016-07-27 04:24:16 +00:00
declareShortcut ( " document-view-newview " , " New View " , QKeySequence ( ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-view-statusbar " , " Toggle Status Bar " , QKeySequence ( ) ) ;
declareShortcut ( " document-view-filters " , " Open Filter List " , QKeySequence ( ) ) ;
declareShortcut ( " document-world-regions " , " Open Region List " , QKeySequence ( ) ) ;
declareShortcut ( " document-world-cells " , " Open Cell List " , QKeySequence ( ) ) ;
declareShortcut ( " document-world-referencables " , " Open Object List " , QKeySequence ( ) ) ;
declareShortcut ( " document-world-references " , " Open Instance List " , QKeySequence ( ) ) ;
2017-08-24 21:12:15 +00:00
declareShortcut ( " document-world-lands " , " Open Lands List " , QKeySequence ( ) ) ;
declareShortcut ( " document-world-landtextures " , " Open Land Textures List " , QKeySequence ( ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-world-pathgrid " , " Open Pathgrid List " , QKeySequence ( ) ) ;
declareShortcut ( " document-world-regionmap " , " Open Region Map " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-globals " , " Open Global List " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-gamesettings " , " Open Game Settings " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-scripts " , " Open Script List " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-spells " , " Open Spell List " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-enchantments " , " Open Enchantment List " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-magiceffects " , " Open Magic Effect List " , QKeySequence ( ) ) ;
declareShortcut ( " document-mechanics-startscripts " , " Open Start Script List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-skills " , " Open Skill List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-classes " , " Open Class List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-factions " , " Open Faction List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-races " , " Open Race List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-birthsigns " , " Open Birthsign List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-topics " , " Open Topic List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-journals " , " Open Journal List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-topicinfos " , " Open Topic Info List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-journalinfos " , " Open Journal Info List " , QKeySequence ( ) ) ;
declareShortcut ( " document-character-bodyparts " , " Open Body Part List " , QKeySequence ( ) ) ;
2017-08-19 07:43:31 +00:00
declareShortcut ( " document-assets-reload " , " Reload Assets " , QKeySequence ( Qt : : Key_F5 ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-assets-sounds " , " Open Sound Asset List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-soundgens " , " Open Sound Generator List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-meshes " , " Open Mesh Asset List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-icons " , " Open Icon Asset List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-music " , " Open Music Asset List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-soundres " , " Open Sound File List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-textures " , " Open Texture Asset List " , QKeySequence ( ) ) ;
declareShortcut ( " document-assets-videos " , " Open Video Asset List " , QKeySequence ( ) ) ;
2016-07-27 04:24:16 +00:00
declareShortcut ( " document-debug-run " , " Run Debug " , QKeySequence ( ) ) ;
declareShortcut ( " document-debug-shutdown " , " Stop Debug " , QKeySequence ( ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " document-debug-runlog " , " Open Run Log " , QKeySequence ( ) ) ;
2016-07-24 01:23:02 +00:00
2016-07-27 23:15:24 +00:00
declareSubcategory ( " Table " ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " table-edit " , " Edit Record " , QKeySequence ( ) ) ;
2016-07-29 19:00:58 +00:00
declareShortcut ( " table-add " , " Add Row/Record " , QKeySequence ( Qt : : ShiftModifier | Qt : : Key_A ) ) ;
declareShortcut ( " table-clone " , " Clone Record " , QKeySequence ( Qt : : ShiftModifier | Qt : : Key_D ) ) ;
2017-09-05 23:29:07 +00:00
declareShortcut ( " touch-record " , " Touch Record " , QKeySequence ( ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " table-revert " , " Revert Record " , QKeySequence ( ) ) ;
declareShortcut ( " table-remove " , " Remove Row/Record " , QKeySequence ( Qt : : Key_Delete ) ) ;
declareShortcut ( " table-moveup " , " Move Record Up " , QKeySequence ( ) ) ;
declareShortcut ( " table-movedown " , " Move Record Down " , QKeySequence ( ) ) ;
declareShortcut ( " table-view " , " View Record " , QKeySequence ( ) ) ;
declareShortcut ( " table-preview " , " Preview Record " , QKeySequence ( ) ) ;
declareShortcut ( " table-extendeddelete " , " Extended Record Deletion " , QKeySequence ( ) ) ;
declareShortcut ( " table-extendedrevert " , " Extended Record Revertion " , QKeySequence ( ) ) ;
2016-07-27 05:53:21 +00:00
2016-07-27 23:15:24 +00:00
declareSubcategory ( " Report Table " ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " reporttable-show " , " Show Report " , QKeySequence ( ) ) ;
declareShortcut ( " reporttable-remove " , " Remove Report " , QKeySequence ( Qt : : Key_Delete ) ) ;
declareShortcut ( " reporttable-replace " , " Replace Report " , QKeySequence ( ) ) ;
declareShortcut ( " reporttable-refresh " , " Refresh Report " , QKeySequence ( ) ) ;
2016-07-27 05:53:21 +00:00
2016-07-27 23:15:24 +00:00
declareSubcategory ( " Scene " ) ;
2016-07-31 09:54:13 +00:00
declareShortcut ( " scene-navi-primary " , " Camera Rotation From Mouse Movement " , QKeySequence ( Qt : : LeftButton ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " scene-navi-secondary " , " Camera Translation From Mouse Movement " ,
2016-07-31 09:54:13 +00:00
QKeySequence ( Qt : : ControlModifier | ( int ) Qt : : LeftButton ) ) ;
declareShortcut ( " scene-edit-primary " , " Primary Edit " , QKeySequence ( Qt : : RightButton ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " scene-edit-secondary " , " Secondary Edit " ,
2016-07-31 09:54:13 +00:00
QKeySequence ( Qt : : ControlModifier | ( int ) Qt : : RightButton ) ) ;
declareShortcut ( " scene-select-primary " , " Primary Select " , QKeySequence ( Qt : : MiddleButton ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " scene-select-secondary " , " Secondary Select " ,
2016-07-31 09:54:13 +00:00
QKeySequence ( Qt : : ControlModifier | ( int ) Qt : : MiddleButton ) ) ;
2016-07-31 20:07:17 +00:00
declareModifier ( " scene-speed-modifier " , " Speed Modifier " , Qt : : Key_Shift ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " scene-load-cam-cell " , " Load Camera Cell " , QKeySequence ( Qt : : KeypadModifier | Qt : : Key_5 ) ) ;
declareShortcut ( " scene-load-cam-eastcell " , " Load East Cell " , QKeySequence ( Qt : : KeypadModifier | Qt : : Key_6 ) ) ;
declareShortcut ( " scene-load-cam-northcell " , " Load North Cell " , QKeySequence ( Qt : : KeypadModifier | Qt : : Key_8 ) ) ;
declareShortcut ( " scene-load-cam-westcell " , " Load West Cell " , QKeySequence ( Qt : : KeypadModifier | Qt : : Key_4 ) ) ;
declareShortcut ( " scene-load-cam-southcell " , " Load South Cell " , QKeySequence ( Qt : : KeypadModifier | Qt : : Key_2 ) ) ;
2016-07-27 23:15:24 +00:00
declareShortcut ( " scene-edit-abort " , " Abort " , QKeySequence ( Qt : : Key_Escape ) ) ;
2016-07-29 19:00:35 +00:00
declareShortcut ( " scene-focus-toolbar " , " Toggle Toolbar Focus " , QKeySequence ( Qt : : Key_T ) ) ;
declareShortcut ( " scene-render-stats " , " Debug Rendering Stats " , QKeySequence ( Qt : : Key_F3 ) ) ;
2016-07-31 20:07:17 +00:00
declareSubcategory ( " 1st/Free Camera " ) ;
declareShortcut ( " free-forward " , " Forward " , QKeySequence ( Qt : : Key_W ) ) ;
declareShortcut ( " free-backward " , " Backward " , QKeySequence ( Qt : : Key_S ) ) ;
declareShortcut ( " free-left " , " Left " , QKeySequence ( Qt : : Key_A ) ) ;
declareShortcut ( " free-right " , " Right " , QKeySequence ( Qt : : Key_D ) ) ;
declareShortcut ( " free-roll-left " , " Roll Left " , QKeySequence ( Qt : : Key_Q ) ) ;
declareShortcut ( " free-roll-right " , " Roll Right " , QKeySequence ( Qt : : Key_E ) ) ;
declareShortcut ( " free-speed-mode " , " Toggle Speed Mode " , QKeySequence ( Qt : : Key_F ) ) ;
declareSubcategory ( " Orbit Camera " ) ;
declareShortcut ( " orbit-up " , " Up " , QKeySequence ( Qt : : Key_W ) ) ;
declareShortcut ( " orbit-down " , " Down " , QKeySequence ( Qt : : Key_S ) ) ;
declareShortcut ( " orbit-left " , " Left " , QKeySequence ( Qt : : Key_A ) ) ;
declareShortcut ( " orbit-right " , " Right " , QKeySequence ( Qt : : Key_D ) ) ;
declareShortcut ( " orbit-roll-left " , " Roll Left " , QKeySequence ( Qt : : Key_Q ) ) ;
declareShortcut ( " orbit-roll-right " , " Roll Right " , QKeySequence ( Qt : : Key_E ) ) ;
declareShortcut ( " orbit-speed-mode " , " Toggle Speed Mode " , QKeySequence ( Qt : : Key_F ) ) ;
declareShortcut ( " orbit-center-selection " , " Center On Selected " , QKeySequence ( Qt : : Key_C ) ) ;
2017-04-26 07:42:03 +00:00
declareSubcategory ( " Script Editor " ) ;
declareShortcut ( " script-editor-comment " , " Comment Selection " , QKeySequence ( ) ) ;
declareShortcut ( " script-editor-uncomment " , " Uncomment Selection " , QKeySequence ( ) ) ;
2015-12-06 11:06:28 +00:00
}
2015-12-08 08:56:42 +00:00
void CSMPrefs : : State : : declareCategory ( const std : : string & key )
2015-12-06 11:06:28 +00:00
{
std : : map < std : : string , Category > : : iterator iter = mCategories . find ( key ) ;
if ( iter ! = mCategories . end ( ) )
{
mCurrentCategory = iter ;
}
else
{
mCurrentCategory =
2015-12-08 08:56:42 +00:00
mCategories . insert ( std : : make_pair ( key , Category ( this , key ) ) ) . first ;
2015-12-06 11:06:28 +00:00
}
2015-12-06 10:18:31 +00:00
}
2015-12-08 16:21:58 +00:00
CSMPrefs : : IntSetting & CSMPrefs : : State : : declareInt ( const std : : string & key ,
const std : : string & label , int default_ )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
std : : ostringstream stream ;
stream < < default_ ;
setDefault ( key , stream . str ( ) ) ;
default_ = mSettings . getInt ( key , mCurrentCategory - > second . getKey ( ) ) ;
CSMPrefs : : IntSetting * setting =
2015-12-15 11:19:48 +00:00
new CSMPrefs : : IntSetting ( & mCurrentCategory - > second , & mSettings , & mMutex , key , label ,
default_ ) ;
2015-12-08 16:21:58 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2015-12-10 09:58:38 +00:00
CSMPrefs : : DoubleSetting & CSMPrefs : : State : : declareDouble ( const std : : string & key ,
const std : : string & label , double default_ )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
std : : ostringstream stream ;
stream < < default_ ;
setDefault ( key , stream . str ( ) ) ;
default_ = mSettings . getFloat ( key , mCurrentCategory - > second . getKey ( ) ) ;
CSMPrefs : : DoubleSetting * setting =
2015-12-15 11:19:48 +00:00
new CSMPrefs : : DoubleSetting ( & mCurrentCategory - > second , & mSettings , & mMutex ,
key , label , default_ ) ;
2015-12-10 09:58:38 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2015-12-10 12:28:48 +00:00
CSMPrefs : : BoolSetting & CSMPrefs : : State : : declareBool ( const std : : string & key ,
const std : : string & label , bool default_ )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
setDefault ( key , default_ ? " true " : " false " ) ;
default_ = mSettings . getBool ( key , mCurrentCategory - > second . getKey ( ) ) ;
CSMPrefs : : BoolSetting * setting =
2015-12-15 11:19:48 +00:00
new CSMPrefs : : BoolSetting ( & mCurrentCategory - > second , & mSettings , & mMutex , key , label ,
default_ ) ;
2015-12-10 12:28:48 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2015-12-10 16:33:14 +00:00
CSMPrefs : : EnumSetting & CSMPrefs : : State : : declareEnum ( const std : : string & key ,
const std : : string & label , EnumValue default_ )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
setDefault ( key , default_ . mValue ) ;
default_ . mValue = mSettings . getString ( key , mCurrentCategory - > second . getKey ( ) ) ;
CSMPrefs : : EnumSetting * setting =
2015-12-15 11:19:48 +00:00
new CSMPrefs : : EnumSetting ( & mCurrentCategory - > second , & mSettings , & mMutex , key , label ,
default_ ) ;
2015-12-10 16:33:14 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2015-12-11 10:15:14 +00:00
CSMPrefs : : ColourSetting & CSMPrefs : : State : : declareColour ( const std : : string & key ,
const std : : string & label , QColor default_ )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
setDefault ( key , default_ . name ( ) . toUtf8 ( ) . data ( ) ) ;
default_ . setNamedColor ( QString : : fromUtf8 ( mSettings . getString ( key , mCurrentCategory - > second . getKey ( ) ) . c_str ( ) ) ) ;
CSMPrefs : : ColourSetting * setting =
2015-12-15 11:19:48 +00:00
new CSMPrefs : : ColourSetting ( & mCurrentCategory - > second , & mSettings , & mMutex , key , label ,
default_ ) ;
2015-12-11 10:15:14 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2016-07-08 03:45:02 +00:00
CSMPrefs : : ShortcutSetting & CSMPrefs : : State : : declareShortcut ( const std : : string & key , const std : : string & label ,
2016-07-31 20:07:17 +00:00
const QKeySequence & default_ )
2016-07-08 03:45:02 +00:00
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
2016-07-31 20:07:17 +00:00
std : : string seqStr = getShortcutManager ( ) . convertToString ( default_ ) ;
2016-07-08 03:45:02 +00:00
setDefault ( key , seqStr ) ;
2016-07-27 01:22:31 +00:00
// Setup with actual data
QKeySequence sequence ;
2016-07-08 03:45:02 +00:00
2016-07-31 20:07:17 +00:00
getShortcutManager ( ) . convertFromString ( mSettings . getString ( key , mCurrentCategory - > second . getKey ( ) ) , sequence ) ;
getShortcutManager ( ) . setSequence ( key , sequence ) ;
2016-07-08 03:45:02 +00:00
2016-07-27 01:22:31 +00:00
CSMPrefs : : ShortcutSetting * setting = new CSMPrefs : : ShortcutSetting ( & mCurrentCategory - > second , & mSettings , & mMutex ,
2016-07-27 17:53:33 +00:00
key , label ) ;
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2016-07-31 20:07:17 +00:00
CSMPrefs : : ModifierSetting & CSMPrefs : : State : : declareModifier ( const std : : string & key , const std : : string & label ,
int default_ )
2016-07-27 17:53:33 +00:00
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
2016-07-31 20:07:17 +00:00
std : : string modStr = getShortcutManager ( ) . convertToString ( default_ ) ;
setDefault ( key , modStr ) ;
// Setup with actual data
int modifier ;
getShortcutManager ( ) . convertFromString ( mSettings . getString ( key , mCurrentCategory - > second . getKey ( ) ) , modifier ) ;
getShortcutManager ( ) . setModifier ( key , modifier ) ;
2016-07-27 17:53:33 +00:00
CSMPrefs : : ModifierSetting * setting = new CSMPrefs : : ModifierSetting ( & mCurrentCategory - > second , & mSettings , & mMutex ,
key , label ) ;
2016-07-08 03:45:02 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
return * setting ;
}
2015-12-11 10:32:55 +00:00
void CSMPrefs : : State : : declareSeparator ( )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
CSMPrefs : : Setting * setting =
2015-12-15 11:19:48 +00:00
new CSMPrefs : : Setting ( & mCurrentCategory - > second , & mSettings , & mMutex , " " , " " ) ;
2015-12-11 10:32:55 +00:00
mCurrentCategory - > second . addSetting ( setting ) ;
}
2016-07-27 23:15:24 +00:00
void CSMPrefs : : State : : declareSubcategory ( const std : : string & label )
{
if ( mCurrentCategory = = mCategories . end ( ) )
throw std : : logic_error ( " no category for setting " ) ;
CSMPrefs : : Setting * setting =
new CSMPrefs : : Setting ( & mCurrentCategory - > second , & mSettings , & mMutex , " " , label ) ;
mCurrentCategory - > second . addSetting ( setting ) ;
}
2015-12-08 16:21:58 +00:00
void CSMPrefs : : State : : setDefault ( const std : : string & key , const std : : string & default_ )
{
Settings : : CategorySetting fullKey ( mCurrentCategory - > second . getKey ( ) , key ) ;
Settings : : CategorySettingValueMap : : iterator iter =
mSettings . mDefaultSettings . find ( fullKey ) ;
if ( iter = = mSettings . mDefaultSettings . end ( ) )
mSettings . mDefaultSettings . insert ( std : : make_pair ( fullKey , default_ ) ) ;
}
2015-12-06 10:18:31 +00:00
CSMPrefs : : State : : State ( const Files : : ConfigurationManager & configurationManager )
2015-12-15 13:51:25 +00:00
: mConfigFile ( " openmw-cs.cfg " ) , mConfigurationManager ( configurationManager ) ,
2015-12-06 11:06:28 +00:00
mCurrentCategory ( mCategories . end ( ) )
2015-12-06 10:18:31 +00:00
{
if ( sThis )
throw std : : logic_error ( " An instance of CSMPRefs::State already exists " ) ;
2016-07-08 03:45:02 +00:00
sThis = this ;
2015-12-06 10:18:31 +00:00
load ( ) ;
declare ( ) ;
}
CSMPrefs : : State : : ~ State ( )
{
sThis = 0 ;
}
void CSMPrefs : : State : : save ( )
{
boost : : filesystem : : path user = mConfigurationManager . getUserConfigPath ( ) / mConfigFile ;
mSettings . saveUser ( user . string ( ) ) ;
}
2015-12-08 08:56:42 +00:00
CSMPrefs : : State : : Iterator CSMPrefs : : State : : begin ( )
2015-12-06 11:06:28 +00:00
{
2015-12-08 08:56:42 +00:00
return mCategories . begin ( ) ;
}
2015-12-06 11:06:28 +00:00
2015-12-08 08:56:42 +00:00
CSMPrefs : : State : : Iterator CSMPrefs : : State : : end ( )
{
return mCategories . end ( ) ;
2015-12-06 11:06:28 +00:00
}
2016-07-08 03:45:02 +00:00
CSMPrefs : : ShortcutManager & CSMPrefs : : State : : getShortcutManager ( )
{
return mShortcutManager ;
}
2015-12-11 10:50:06 +00:00
CSMPrefs : : Category & CSMPrefs : : State : : operator [ ] ( const std : : string & key )
2015-12-08 11:04:45 +00:00
{
Iterator iter = mCategories . find ( key ) ;
if ( iter = = mCategories . end ( ) )
throw std : : logic_error ( " Invalid user settings category: " + key ) ;
return iter - > second ;
}
2015-12-08 16:21:58 +00:00
void CSMPrefs : : State : : update ( const Setting & setting )
{
2015-12-11 11:06:20 +00:00
emit ( settingChanged ( & setting ) ) ;
2015-12-08 16:21:58 +00:00
}
2015-12-06 10:18:31 +00:00
CSMPrefs : : State & CSMPrefs : : State : : get ( )
{
if ( ! sThis )
throw std : : logic_error ( " No instance of CSMPrefs::State " ) ;
return * sThis ;
}
2017-05-09 07:50:16 +00:00
void CSMPrefs : : State : : resetCategory ( const std : : string & category )
{
for ( Settings : : CategorySettingValueMap : : iterator i = mSettings . mUserSettings . begin ( ) ;
i ! = mSettings . mUserSettings . end ( ) ; + + i )
{
// if the category matches
if ( i - > first . first = = category )
{
// mark the setting as changed
mSettings . mChangedSettings . insert ( std : : make_pair ( i - > first . first , i - > first . second ) ) ;
// reset the value to the default
i - > second = mSettings . mDefaultSettings [ i - > first ] ;
}
}
Collection : : iterator container = mCategories . find ( category ) ;
if ( container ! = mCategories . end ( ) )
{
Category settings = container - > second ;
for ( Category : : Iterator i = settings . begin ( ) ; i ! = settings . end ( ) ; + + i )
{
( * i ) - > updateWidget ( ) ;
update ( * * i ) ;
}
}
}
void CSMPrefs : : State : : resetAll ( )
{
for ( Collection : : iterator iter = mCategories . begin ( ) ; iter ! = mCategories . end ( ) ; + + iter )
{
resetCategory ( iter - > first ) ;
}
}
2015-12-06 10:18:31 +00:00
CSMPrefs : : State & CSMPrefs : : get ( )
{
return State : : get ( ) ;
}