Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
vabatta committed Feb 27, 2019
0 parents commit 4e9a2d1
Show file tree
Hide file tree
Showing 10 changed files with 5,715 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "standard",
"rules": {
"brace-style": [ "error", "stroustrup" ]
}
}
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Compiled source
*.com
*.class
*.dll
*.exe
*.o
*.so
dist/

# Packages
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Dependencies
bower_components/
node_modules/
vendor/

# Logs and databases
*.log
*.sqlite

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
.nfs*

# IDE
.idea
.vscode

# Config
.env
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { src, dest, series } = require('gulp')
const rename = require('gulp-rename')
const file = require('gulp-file')
const zip = require('gulp-zip')

const update = () => {
const moduleInfo = require('./module.json')
const packageInfo = require('./package.json')

moduleInfo.updated = new Date(Date.now()).toLocaleString('en-US').split(',')[0]
moduleInfo.author = packageInfo.author
moduleInfo.version = packageInfo.version
moduleInfo.description = packageInfo.description
// build id
const dashName = packageInfo.name.replace('zedit-patcher-', '')
moduleInfo.id = dashName[0].toUpperCase() + dashName.replace(/-([a-z0-9])/g, (a, b) => b.toUpperCase()).slice(1)

return file('./module.json', JSON.stringify(moduleInfo, null, 2), { src: true })
.pipe(dest('.'))
}

const pack = () => {
const moduleInfo = require('./module.json')
const moduleId = moduleInfo.id
const moduleVersion = moduleInfo.version

return src([
'index.js',
'src/**/*',
'partials/*.html',
'LICENSE',
'module.json'
], { base: '.', allowEmpty: true })
.pipe(rename(path => {
path.dirname = `${moduleId}/${path.dirname}`
return path.dirname
}))
.pipe(zip(`${moduleId}-v${moduleVersion}.zip`))
.pipe(dest('.'))
}

// module.exports = series(pack)
module.exports.pack = series(pack)
module.exports.update = series(update)
76 changes: 76 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* global info, xelib, registerPatcher, patcherUrl */

registerPatcher({
info: info,
gameModes: [ xelib.gmSSE, xelib.gmTES5 ],
settings: {
label: info.name,
hide: false,
templateUrl: `${patcherUrl}/partials/settings.html`,
defaultSettings: {
title: info.name,
patchFileName: 'Reading is Good - Patch.esp'
}
},
requiredFiles: [ 'Reading Is Good 2.esp' ],
getFilesToPatch: filenames => {
return filenames
},
execute: (patchFile, helpers, settings, locals) => ({
initialize: () => {
// initialize
// measure the execution time
locals.start = new Date()
// get the base mod file
const ris = xelib.FileByName('Reading Is Good 2.esp')
// locally save the lists
locals.lists = []
locals.lists[0] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_OneHanded'), patchFile, false) // sSBList1HD
locals.lists[1] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_TwoHanded'), patchFile, false) // sSBList2HD
locals.lists[2] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Marksman'), patchFile, false) // sSBListARC
locals.lists[3] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Block'), patchFile, false) // sSBListBLO
locals.lists[4] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Smithing'), patchFile, false) // sSBListSMI
locals.lists[5] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_HeavyArmor'), patchFile, false) // sSBListHVA
locals.lists[6] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_LightArmor'), patchFile, false) // sSBListLTA
locals.lists[7] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Pickpocket'), patchFile, false) // sSBListPIC
locals.lists[8] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Lockpicking'), patchFile, false) // sSBListLOC
locals.lists[9] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Sneak'), patchFile, false) // sSBListSNK
locals.lists[10] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Alchemy'), patchFile, false) // sSBListALC
locals.lists[11] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Speechcraft'), patchFile, false) // sSBListSPE
locals.lists[12] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Alteration'), patchFile, false) // sSBListALT
locals.lists[13] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Conjuration'), patchFile, false) // sSBListCON
locals.lists[14] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Destruction'), patchFile, false) // sSBListDES
locals.lists[15] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Illusion'), patchFile, false) // sSBListILU
locals.lists[16] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Restoration'), patchFile, false) // sSBListRES
locals.lists[17] = xelib.CopyElement(xelib.GetElement(ris, '_RIG_SkillBookList_Enchanting'), patchFile, false) // sSBListENC
},
process: [{
load: {
signature: 'BOOK',
filter: record => {
// Returns true if it's a winning override and is a skill book
return xelib.GetEnabledFlags(record, 'DATA - Data\\Flags').includes('Teaches Skill') && xelib.IsWinningOverride(record)
}
},
patch: record => {
// get the skill related to the book
let skillId = xelib.GetIntValue(record, 'DATA\\Skill') - 6

// check if the skill is valid
if (skillId >= 0 && skillId <= 17) {
// add the form id to the list
xelib.AddFormID(locals.lists[skillId], xelib.GetHexFormID(record))
// patch the skill to none
xelib.SetIntValue(record, 'DATA\\Skill', -1)
// log report
// helpers.logMessage(`${xelib.EditorId(record)}: Patched (skill ID ${skillId})`)
}
}
}],
finalize: () => {
// log the execution time
locals.time = new Date() - locals.start
helpers.logMessage(`Took ${locals.time / 1000} seconds`)
}
})
})
14 changes: 14 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "ModReadingIsGood2",
"name": "Reading is Good 2 patcher",
"author": "vabatta",
"version": "1.0.0",
"released": "1/25/2019",
"updated": "2/27/2019",
"description": "Patcher to dynamically add skill books to Reading is Good 2 mod formlists.",
"requires": [
"unifiedPatchingFramework"
],
"moduleLoader": "UPF",
"canHotLoad": true
}
Loading

0 comments on commit 4e9a2d1

Please sign in to comment.