Skip to content

Commit

Permalink
Merge pull request #65 from matsn0w/develop
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
matsn0w authored Mar 3, 2022
2 parents 950e322 + 6b20380 commit 03e7453
Show file tree
Hide file tree
Showing 25 changed files with 19,612 additions and 147 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
FiveM build: xxxx
MISS ELS version: x.x.x
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
31 changes: 31 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Type of change

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Other

## Description

<!-- Please describe your PR. What does this? Why should this be added? Why should this be fixed? What could be improved later? -->

## Issue

<!-- Please link to any relevant issue(s) -->

Fixes #xx

## Screenshots

<!-- Please add some screenshots or videos when relevant -->

## Checklist

- [ ] My code follows the code style of this project
- [ ] I have performed a self-review of my code
- [ ] I have tested my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] Any dependent changes have been merged and published in downstream modules

@matsn0w
21 changes: 21 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Merged Pull Requests for this release

### rc.1

- #
- ...

### Final

- #
- ...

## Release candidates

- [vX.X.X-rc.X](https://github.com/matsn0w/MISS-ELS/releases/tag/X.X.X-rc.X)
- ...

## Todo for final release

- [ ] update changelog
- [ ] update docs
8 changes: 6 additions & 2 deletions .github/workflows/configurator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ jobs:
os: [ubuntu-latest]
node: [14]

defaults:
run:
working-directory: ./configurator

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup node env
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm
run: npm ci

- name: Generate
run: npm run generate
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ Feel free to [create an issue](https://github.com/matsn0w/MISS-ELS/issues/new) i

## Changelog

### v2.1.0

#### Resource

* Added automatic scanning for VCF's
* Added 'missing zero' detection in the XML parser
* Fixed a bunch of errors thrown in the console when 'others' activated their lights

#### Configurator

* Added importing of existing VCF's
* Fixed missing zeros in XML output

### v2.0.1

* Fixed a bug in the update checking script
Expand Down
19 changes: 19 additions & 0 deletions configurator/assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,22 @@ input[type='checkbox'] {
.nocolor {
@apply text-white bg-gray-500 #{!important};
}

.import-button {
position: relative;
overflow: hidden;
display: inline-block;

/* Fancy button looking */
border: 2px solid black;
border-radius: 5px;
padding: 8px 12px;
cursor: pointer;
}
.import-button input {
position: absolute;
top: 0;
left: 0;
z-index: -1;
opacity: 0;
}
21 changes: 21 additions & 0 deletions configurator/components/importButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<label class="import-button">
Import Existing VCF
<input type="file" @change="loadVCF">
</label>
</template>

<script>
export default {
name: 'ImportButton',
methods: {
loadVCF (ev) {
const file = ev.target.files[0]
const reader = new FileReader()
reader.onload = e => this.$emit('load', e.target.result)
reader.readAsText(file)
}
}
}
</script>
1 change: 0 additions & 1 deletion configurator/components/statics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default {
computed: {
...mapMultiRowFields(['configuration.statics'])
},
methods: {
addStatic () {
const highest = this.statics.at(-1)?.extra ?? 0
Expand Down
92 changes: 92 additions & 0 deletions configurator/helpers/transformImportedVCF.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* This method takes in an existing VCF file (as XML string), parses the XML
* and maps it to an expected format for the VueX store.
*
*/
export default function generateStoreAttributesFromExistingVCF (data) {
const vcf = {
flashID: 1,
author: null,
description: null,
extras: [],
statics: [],
useServerSirens: false,
sounds: [],
patterns: [],
flashes: []
}

// parse the XML string
const parsedVCF = new DOMParser().parseFromString(data, 'text/xml')

// get basic document info
vcf.description = parsedVCF.querySelector('vcfroot').getAttribute('Description')
vcf.author = parsedVCF.querySelector('vcfroot').getAttribute('Author')

// EOVERRIDE section
const eoverride = parsedVCF.querySelector('EOVERRIDE')
const extras = eoverride.querySelectorAll('*')

extras.forEach((extra) => {
vcf.extras.push({
id: parseInt(extra.nodeName.match(/([0-9]|[1-9][0-9])$/g)[0]),
enabled: extra.getAttribute('IsElsControlled') === 'true',
allowEnv: extra.getAttribute('AllowEnvLight') === 'true',
color: extra.getAttribute('Color') ?? null
})
})

// STATICS section
const staticsObject = parsedVCF.querySelector('STATIC')
const statics = staticsObject.querySelectorAll('*')

statics.forEach((staticExtra) => {
vcf.statics.push({
extra: parseInt(staticExtra.nodeName.match(/([0-9]|[1-9][0-9])$/g)[0]),
name: staticExtra.getAttribute('Name') ?? staticExtra.nodeName
})
})

// SOUNDS section
const soundsObject = parsedVCF.querySelector('SOUNDS')
const sounds = soundsObject.querySelectorAll('*')

sounds.forEach((sound) => {
vcf.sounds.push({
name: sound.nodeName,
allowUse: sound.getAttribute('AllowUse') === 'true',
audioString: sound.getAttribute('AudioString') ?? null,
soundSet: sound.getAttribute('SoundSet') ?? null
})
})

// determine whether a SoundSet is present
sounds.forEach((sound) => {
if (sound.getAttribute('SoundSet') !== null) {
vcf.useServerSirens = true
}
})

// PATTERN section
const patternsObject = parsedVCF.querySelector('PATTERN')

for (const pattern of patternsObject.children) {
vcf.patterns.push({
name: pattern.nodeName,
isEmergency: pattern.getAttribute('IsEmergency') === 'true'
})

for (const flash of pattern.children) {
const enabledExtras = flash.getAttribute('Extras')?.split(',') ?? []

vcf.flashes.push({
id: vcf.flashID++,
duration: parseInt(flash.getAttribute('Duration')) ?? 100,
extras: enabledExtras.map(extra => parseInt(extra)) ?? [],
pattern: pattern.nodeName
})
}
}

return vcf
}
4 changes: 3 additions & 1 deletion configurator/helpers/xmlGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export default {
const extras = doc.createElement('EOVERRIDE')

data.extras.forEach((extra) => {
const e = doc.createElement(`Extra${extra.id}`)
let extraId = `${extra.id}`
extraId = extraId.replace(/(^[^\d\n]*\d[^\d\n]*$)/gm, '0$1')
const e = doc.createElement(`Extra${extraId}`)
e.setAttribute('IsElsControlled', extra.enabled)

if (extra.allowEnv) {
Expand Down
Loading

0 comments on commit 03e7453

Please sign in to comment.