Skip to content

Commit 152c7b7

Browse files
committed
Added setting
Added the ability to set the path to the INI file in case you want to keep it somewhere outside of My Documents. The path needs to be absolute and can either be the path to a folder, in which case a file called SublimePapyrus.ini will be created when the INI creation command is run, or to a file, in which case that file will be used. If nothing is defined by the user, then the package will use the default path.
1 parent 5a7b3e7 commit 152c7b7

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

Core/SublimePapyrus.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
BUILD_SYSTEM = importlib.import_module("Default.exec")
1515

1616
# INI related variables.
17-
INI_LOCATION = os.path.expanduser("~/Documents/SublimePapyrus.ini")
17+
INI_LOCATION = ""
1818
if (os.path.exists("C:\\Program Files (x86)")):
1919
END_USER_ROOT = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\skyrim"
2020
else:
@@ -75,6 +75,20 @@
7575
def plugin_loaded():
7676
global USER_SETTINGS
7777
USER_SETTINGS = sublime.load_settings('SublimePapyrus.sublime-settings')
78+
iniPath = USER_SETTINGS.get('ini_path', "")
79+
if iniPath != "":
80+
if iniPath.endswith(".ini"):
81+
folderPath = os.path.dirname(iniPath)
82+
if os.path.exists(folderPath) == False:
83+
os.mkdir(folderPath)
84+
else:
85+
if os.path.exists(iniPath) == False:
86+
os.mkdir(iniPath)
87+
iniPath += "\\SublimePapyrus.ini"
88+
else:
89+
iniPath = os.path.expanduser("~\\Documents\\SublimePapyrus.ini")
90+
global INI_LOCATION
91+
INI_LOCATION = iniPath
7892

7993
def getPrefs(filePath):
8094
fileDir, fileName = os.path.split(filePath)
@@ -117,12 +131,15 @@ def getPrefs(filePath):
117131
ret["import"] = ";".join(filter(None, ret["import"]))
118132
elif PYTHON_VERSION[0] == 3:
119133
ret["import"] = ";".join([_f for _f in ret["import"] if _f])
134+
else:
135+
sublime.status_message("Could not find the configuration file. Falling back to default values.")
136+
ret["debug"] = []
120137
ret["filename"] = fileName
121138
return ret
122139

123140
class CreateDefaultSettingsFileCommand(sublime_plugin.WindowCommand):
124141
def run(self, **args):
125-
if os.path.exists(INI_LOCATION):
142+
if os.path.isfile(INI_LOCATION):
126143
if sublime.ok_cancel_dialog("INI file already exists at %s.\n Do you want to open the file?" % INI_LOCATION):
127144
self.window.open_file(INI_LOCATION)
128145
else:

Core/SublimePapyrus.sublime-settings

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"highlight_compiler_errors": false,
33
"hide_successful_build_results": false,
4-
"word_wrap": false
4+
"word_wrap": false,
5+
"ini_path": ""
56
}

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Includes function/event snippets and syntax definitions for:
2525

2626
- Packaged: Download a [release](https://github.com/Kapiainen/SublimePapyrus/releases). Copy SublimePapyrus.sublime-package (and any other .sublime-package files you want) to *"%AppData%\Sublime Text #\Data\Installed Packages"*, or *"\Sublime Text #\Data\Installed Packages"* if you are using the portable version of Sublime Text, (replace # with the version of Sublime Text you are using).
2727

28-
- If you have Skyrim installed outside of *"C:\Program Files (x86)\Steam\steamapps\common\skyrim\" or "C:\Program Files\Steam\steamapps\common\skyrim\"*, then you need to open the Command Palette (CTRL+SHIFT+P), type in *"SublimePapyrus INI"*. An option called *"SublimePapyrus: Create default INI file"* should show up. Select it and a file called *SublimePapyrus.ini* will be created in *My Documents*. This file contains paths to compiled scripts, script sources, the Papyrus compiler, and paths to libraries you wish to import (optional). Edit the paths according to where you have the relevant files (usually where Skyrim has been installed).
28+
- If you have Skyrim installed outside of *"C:\Program Files (x86)\Steam\steamapps\common\skyrim\" or "C:\Program Files\Steam\steamapps\common\skyrim\"*, then you need to open the Command Palette (CTRL+SHIFT+P), type in *"SublimePapyrus INI"*. An option called *"SublimePapyrus: Create default INI file"* should show up. Select it and a file called *SublimePapyrus.ini* will be created in *My Documents*. This file contains paths to compiled scripts, script sources, the Papyrus compiler, and paths to libraries you wish to import (optional). Edit the paths according to where you have the relevant files (usually where Skyrim has been installed). If you want to have the INI file in another folder, then you can set it via the user settings (*Preferences -> Package Settings -> SublimePapyrus -> Settings - User*) with the setting *"ini_path"*. The value of that setting should be an absolute path to a folder that will contain the INI file or a file with the *.ini* extension.
2929

3030
If you are using [Advanced Papyrus](https://github.com/Kapiainen/Advanced-Papyrus), then you should set the *compiler* option in *SublimePapyrus.ini* to point to the actual compiler, which would be called *PapyrusCompiler - Original.exe*, rather than the wrapper program.
3131

@@ -70,7 +70,7 @@ Syntax highlighting for all keywords defined in Papyrus as well as names of all
7070

7171

7272
####Build systems
73-
You can now compile Papyrus scripts from Sublime Text as long as you have defined the path to the Papyrus compiler and flags in *SublimePapyrus.ini*. The various INI settings are documented in detail in the INI file generated via the *SublimePapyrus: Create default INI file* command.
73+
You can now compile Papyrus scripts from Sublime Text as long as you have defined the path to the Papyrus compiler and flags in *SublimePapyrus.ini*. The various INI settings are documented in detail in the INI file generated via the *SublimePapyrus: Create default INI file* command.
7474

7575
The *Import* section of the INI file is of particular interest as it allows you to keep various scripts, and their source files, separate, which can be useful if you for example use [Mod Organizer](http://www.nexusmods.com/skyrim/mods/1334/).
7676

@@ -143,7 +143,7 @@ Automatically hide the build results when the Papyrus compiler finishes without
143143

144144
This feature is disabled by default and can be enabled in *Preferences -> Package Settings -> SublimePapyrus -> Settings - User*.
145145

146-
146+
147147
##Credits
148148
Based on the work done by Bethesda Game Studios and Mark Hanna. Used according to the license included in the original package and said license is included in this package.
149149

0 commit comments

Comments
 (0)