Skip to content

Commit

Permalink
Add game version tag to all mods
Browse files Browse the repository at this point in the history
  • Loading branch information
StarGazer1258 committed May 26, 2019
1 parent d59ce2b commit e3b232c
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 154 deletions.
426 changes: 279 additions & 147 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "beatdrop",
"description": "A desktop app for downloading Beat Saber songs.",
"author": "Nathaniel Johns (StarGazer1258)",
"version": "2.3.1-beta",
"version": "2.3.2-beta",
"private": false,
"license": "CC-BY-NC-SA-4.0",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ function handleArgs(argv, sendImmediately) {

function createWindow() {
mainWindow = new BrowserWindow({
width: 1015,
width: 1080,
height: 615,
minWidth: 1015,
minWidth: 1090,
minHeight: 615,
resizable: true,
frame: false,
Expand Down
4 changes: 2 additions & 2 deletions src/actions/modActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const fetchLocalMods = () => (dispatch, getState) => {
let installedMods = getState().mods.installedMods
let m = []
for(let i = 0; i < installedMods.length; i++) {
if(beatModsResponse.filter(mod => mod.name === installedMods[i].name)[0]) m.push(beatModsResponse.filter(mod => mod.name === installedMods[i].name)[0])
if(beatModsResponse.filter(mod => mod._id === installedMods[i].id)[0]) m.push(beatModsResponse.filter(mod => mod._id === installedMods[i].id)[0])
console.log(installedMods[i].name)
}
dispatch({
Expand Down Expand Up @@ -259,7 +259,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge
return
}
console.log(`Fetching ${modName}@${version} from BeatMods...`)
fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive&name=${encodeURIComponent(modName)}&gameVersion=${getState().settings.gameVersion}&version=${version}`)
fetch(`https://beatmods.com/api/v1/mod?status=approved${!!version ? `&status=inactive&version=${version}` : ''}&name=${encodeURIComponent(modName)}&gameVersion=${getState().settings.gameVersion}`)
.then(res => res.json())
.then(beatModsResponse => {
console.log(`Got the BeatMods response for ${modName}@${version}`)
Expand Down
1 change: 1 addition & 0 deletions src/components/ModDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ModDetails extends Component {
<h1 className="mod-title">{ this.props.details.name }</h1>
<h3 className="mod-author">by { this.props.details.author.username }</h3>
<Badge>{ this.props.details.category.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()}) }</Badge>
<Badge>Beat Saber v{ this.props.details.gameVersion }</Badge>
{ this.props.installedMods.some(mod => mod.id === this.props.details._id) ? <div className="mod-in-library">This mod is in your library.</div> : null }
{ this.props.details.name === 'BSIPA' ? <div className="mod-in-library">BSIPA is required to load mods and cannot be uninstalled or deactivated.</div> : null }
{ this.props.installedMods.some(mod => mod.id === this.props.details._id) && (this.props.installedMods.filter(m => m.name === this.props.details.name)[0].dependencyOf.some(dependent => this.props.installedMods.some(installedMod => installedMod.name === dependent))) ? <div className="mod-in-library">{ this.props.details.name } is required by { this.props.installedMods.filter(m => m.name === this.props.details.name)[0].dependencyOf.filter(dependent => this.props.installedMods.some(installedMod => installedMod.name === dependent)).join(', ') } and cannot be uninstalled or deactivated.</div> : null }
Expand Down
6 changes: 6 additions & 0 deletions src/components/ModsListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ModsListView extends Component {
<th><span>&nbsp;</span></th>
<th onClick={ () => { this.setState({ sortBy: 'name', sortDirection: this.state.sortBy === 'name' ? !this.state.sortDirection : 0 }) } }><span>Mod Name{ this.state.sortBy === 'name' ? this.state.sortDirection ? '▼' : '▲' : null }</span></th>
<th width={ 80 } onClick={ () => { this.setState({ sortBy: 'version', sortDirection: this.state.sortBy === 'version' ? !this.state.sortDirection : 0 }) } }><span>Version{ this.state.sortBy === 'version' ? this.state.sortDirection ? '▼' : '▲' : null }</span></th>
<th width={ 80 } onClick={ () => { this.setState({ sortBy: 'gameVersion', sortDirection: this.state.sortBy === 'gameVersion' ? !this.state.sortDirection : 0 }) } }><span>Game V.{ this.state.sortBy === 'gameVersion' ? this.state.sortDirection ? '▼' : '▲' : null }</span></th>
<th onClick={ () => { this.setState({ sortBy: 'author', sortDirection: this.state.sortBy === 'author' ? !this.state.sortDirection : 0 }) } }><span>Author{ this.state.sortBy === 'author' ? this.state.sortDirection ? '▼' : '▲' : null }</span></th>
<th onClick={ () => { this.setState({ sortBy: 'category', sortDirection: this.state.sortBy === 'category' ? !this.state.sortDirection : 0 }) } }><span>Category{ this.state.sortBy === 'category' ? this.state.sortDirection ? '▼' : '▲' : null }</span></th>
<th onClick={ () => { this.setState({ sortBy: 'uploadDate', sortDirection: this.state.sortBy === 'uploadDate' ? !this.state.sortDirection : 0 }) } }><span>Upload Date{ this.state.sortBy === 'uploadDate' ? this.state.sortDirection ? '▼' : '▲' : null }</span></th>
Expand All @@ -80,6 +81,10 @@ class ModsListView extends Component {
if(a.version < b.version) return this.state.sortDirection * 2 - 1
if(a.version > b.version) return -(this.state.sortDirection * 2 - 1)
return 0
case 'gameVersion':
if(a.gameVersion < b.gameVersion) return this.state.sortDirection * 2 - 1
if(a.gameVersion > b.gameVersion) return -(this.state.sortDirection * 2 - 1)
return 0
case 'author':
if(a.author.username < b.author.username) return this.state.sortDirection * 2 - 1
if(a.author.username > b.author.username) return -(this.state.sortDirection * 2 - 1)
Expand Down Expand Up @@ -129,6 +134,7 @@ class ModsListView extends Component {
</td>
<td>{ mod.name }</td>
<td>{ mod.version }</td>
<td>{ mod.gameVersion }</td>
<td>{ mod.name === 'YUR Fit Calorie Tracker' ? <a href='https://yur.chat' onClick={ (e) => { e.preventDefault(); e.stopPropagation(); shell.openExternal('https://yur.chat') } }>https://yur.chat</a> : (mod.author.username || 'Unknown') }</td>
<td>{ mod.category }</td>
<td>{ `${new Date(mod.uploadDate).toLocaleDateString() }, ${ new Date(mod.uploadDate).toLocaleTimeString() }` }</td>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ModsView extends Component {
{ this.props.mods.installedMods.some(m => m.name === mod.name) ? (!this.props.mods.installedMods.filter(m => m.name === mod.name)[0].active ? <DeactivatedIndicator /> : null) : null }
<div className={ `mod-image${ category === 'libraries' ? ' library' : '' }${ category === 'tweaks / tools' ? ' tweak' : '' }${ category === 'cosmetic' ? ' cosmetic' : '' }${ category === 'practice / training' ? ' training' : '' }${ category === 'multiplayer' ? ' multiplayer' : '' }${ category === 'gameplay' ? ' gameplay' : '' }${ category === 'streaming tools' ? ' stream' : '' }${ category === 'lighting changes' ? ' lighting' : '' }${ category === 'text changes' ? ' text' : '' }${ category === 'ui enhancements' ? ' text' : '' }` }></div>
<div className="mod-info">
<span className="first-row"><span className="mod-title">{ mod.name }</span> <span className="mod-version">v{ mod.version }</span></span>
<span className="first-row"><span className="mod-title">{ mod.name }</span> <span className="mod-version">v{ mod.version } (for v{ mod.gameVersion })</span></span>
<div className="mod-author">{ mod.name === 'YUR Fit Calorie Tracker' ? <>Join our discord: <a href='https://yur.chat' onClick={ (e) => { e.preventDefault(); e.stopPropagation(); shell.openExternal('https://yur.chat') } }>https://yur.chat</a></> : `by ${ mod.author.username || 'Unknown' }` }</div>
<div className="mod-category">{ category.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()}).replace('Ui', 'UI') }</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/ReleaseNotesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ReleaseNotesModal extends Component {
<li>Added <b>custom theme image</b> setting. You can now download songs while watching anime or looking at cute cats!</li>
<li>Added <b>game version support.</b> This means you can set your game version and get only the correct mods for the version. (May require mod reinstallation to update.)</li>
<li>We have a new Wave tier Patron! Welcome to the credits <b>Marc Smith!</b></li>
<li>2.3.2: Add <b>game version tag</b> to all mods. Now you can see for what version of the game a mod was made for.</li>
</ul>
<h2 style={ { color: 'salmon' } }>What's fixed?</h2>
<hr style={ { borderColor: 'salmon' } } />
Expand Down
6 changes: 5 additions & 1 deletion src/reducers/modReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SET_MOD_LIST, APPEND_MOD_LIST, LOAD_MOD_DETAILS, INSTALL_MOD, UNINSTALL_MOD, CLEAR_MODS, SET_INSTALLED_MODS, SET_SCANNING_FOR_MODS, SET_MOD_ACTIVE, ADD_PENDING_MOD, ADD_DEPENDENT, SET_PATCHING } from '../actions/types'
import { SET_MOD_LIST, APPEND_MOD_LIST, LOAD_MOD_DETAILS, INSTALL_MOD, UNINSTALL_MOD, CLEAR_MODS, SET_INSTALLED_MODS, SET_SCANNING_FOR_MODS, SET_MOD_ACTIVE, ADD_PENDING_MOD, ADD_DEPENDENT, SET_PATCHING, REMOVE_DEPENDENT } from '../actions/types'

const initialState = {
mods: [],
Expand Down Expand Up @@ -43,6 +43,10 @@ export default function(state = initialState, action) {
let newDependentState = { ...state }
newDependentState.installedMods[action.payload.index].dependencyOf.push(action.payload.dependent)
return newDependentState
case REMOVE_DEPENDENT:
let removedDependantState = { ...state }
removedDependantState.installedMods[action.payload.index].dependencyOf.splice(removedDependantState.installedMods[action.payload.index].dependencyOf.findIndex(m => m.name === action.payload.dependant), 1)
return removedDependantState
case UNINSTALL_MOD:
let uninstalledState = { ...state }
uninstalledState.installedMods.splice(action.payload, 1)
Expand Down

0 comments on commit e3b232c

Please sign in to comment.