Skip to content

Commit

Permalink
Merge pull request #93 from Tarnadas/dev
Browse files Browse the repository at this point in the history
update Discord and website link
  • Loading branch information
Mario Reder authored Mar 26, 2019
2 parents c51ff03 + 9c57cdc commit 33cf24a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Net64+ Client

[![Discord](https://discordapp.com/api/guilds/354358899328942081/widget.png)](https://discord.gg/net64)
[![Discord](https://discordapp.com/api/guilds/559982917049253898/widget.png)](https://discord.gg/GgGUKH8)
[![Build Status](https://api.travis-ci.org/Tarnadas/net64plus.svg?branch=master)](https://travis-ci.org/Tarnadas/net64plus)

Net64 aka SM64O allows playing Super Mario 64 in an online multiplayer mode.
Expand Down
1 change: 1 addition & 0 deletions compat-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports = function getCompatMin (currentVersion) {
const [ major, minor ] = currentVersion.split('.').map(n => Number(n))
if (major === 2 && minor === 1) return [ '2', '0' ]
if (major === 2 && minor === 2) return [ '2', '0' ]
if (major === 2 && minor === 3) return [ '2', '0' ]
throw new Error(`Compatibility list found unknown version ${currentVersion}`)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "net64plus",
"version": "2.2.0",
"version": "2.3.0",
"compatVersion": "1.0.0",
"description": "Net64+ client",
"main": "index.js",
Expand Down
86 changes: 55 additions & 31 deletions src/main/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,59 @@ import {
const UPDATE_INTERVAL = 32
const MAX_SERVER_PLAYER = 24

interface GameModeRPC {
name: string
imageName: string
}

/**
* Helper function to sort gamemode as the DRPC image and gamemode as readable name
*
* @param {number} gamemodeInteger - The integer of the gamemode ranging from 1-6, 8
*/
function getGameModeString(gamemodeInteger: number): {[k: string]: string} {
const retObj: {[k: string]: string} = {}
switch(gamemodeInteger) {
function getGameModeString(gamemodeInteger: number): GameModeRPC {
switch (gamemodeInteger) {
case 1:
retObj.name = 'Regular'
retObj.imageName = 'regular'
break
return {
name: 'Regular',
imageName: 'regular'
}
case 2:
retObj.name = 'Third Person Shooter'
retObj.imageName = 'shooter'
break
return {
name: 'Third Person Shooter',
imageName: 'shooter'
}
case 3:
retObj.name = 'Interactionless'
retObj.imageName = 'interactionless'
break
return {
name: 'Interactionless',
imageName: 'reinteractionlessgular'
}
case 4:
retObj.name = 'Prop Hunt'
retObj.imageName = 'prop_hunt'
break
return {
name: 'Prop Hunt',
imageName: 'prop_hunt'
}
case 5:
retObj.name = 'Boss Rush'
retObj.imageName = 'boss_rush'
break
return {
name: 'Boss Rush',
imageName: 'boss_rush'
}
case 6:
retObj.name = 'Tag'
retObj.imageName = 'tag'
break
return {
name: 'RegTagular',
imageName: 'tag'
}
case 8:
retObj.name = 'Wario Ware'
retObj.imageName = 'wario_ware'
break
return {
name: 'Wario Ware',
imageName: 'wario_ware'
}
default:
retObj.name = 'None'
retObj.imageName = ''
break
return {
name: 'None',
imageName: ''
}
}
return retObj
}
/**
* A Connection object represents the connection to an actual
Expand Down Expand Up @@ -171,7 +183,15 @@ export class Connection {
this.loop = null
}
connector.closeWebSocket(code, this.hasError)
updateRPC({state: 'Ready', details: 'Ready', largeImageKey: 'net64', largeImageText: `Net64+ ${process.env.VERSION}`}, true)
updateRPC(
{
state: 'Ready',
details: 'Ready',
largeImageKey: 'net64',
largeImageText: `Net64+ ${process.env.VERSION}`
},
true
)
if (!emulator) return
emulator.reset()
}
Expand Down Expand Up @@ -381,7 +401,11 @@ export class Connection {
emulator!.setGameMode(gameMode.gameMode)
connector.setGameMode(gameMode.gameMode)
const gamemodeObj = getGameModeString(gameMode.gameMode)
updateRPC({details: `Playing in ${gamemodeObj.name} mode`, smallImageKey: gamemodeObj.imageName, smallImageText: gamemodeObj.name})
updateRPC({
details: `Playing in ${gamemodeObj.name} mode`,
smallImageKey: gamemodeObj.imageName,
smallImageText: gamemodeObj.name
})
connector.commandMessage(`Gamemode changed to ${gameMode.gameMode}`)
}

Expand Down Expand Up @@ -437,7 +461,7 @@ export class Connection {
const players = messageData.playerListUpdate.playerUpdates
if (!players) return
connector.setPlayers(players)
updateRPC({partySize: players.length})
updateRPC({ partySize: players.length })
}

/**
Expand Down
13 changes: 11 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ export const deleteConnection = () => {
if (connection) connection.disconnect()
connection = undefined
}
export const RPCClient = new RPCClientInstance('550708311582834700')

export const RPCClient = new RPCClientInstance('560060224321355811')
RPCClient.on("error", (err: Error) => {
if (process.env.NODE_ENV === 'development') {
console.error(err)
}
})

export let RPCState = {}

export function updateRPC(update: Object, clean?: boolean): void {
if (clean) {RPCState = {}}
Object.assign(RPCState, update)
RPCClient.updatePresence(RPCState)
}

;(() => {
const onReady = () => {
const mainWindow = new BrowserWindow({
Expand All @@ -74,7 +78,12 @@ export function updateRPC(update: Object, clean?: boolean): void {
}
})
connector = new Connector(mainWindow)
updateRPC({state: 'Ready', details: 'Ready', largeImageKey: 'net64', largeImageText: `Net64+ ${process.env.VERSION}`})
updateRPC({
state: 'Ready',
details: 'Ready',
largeImageKey: 'net64',
largeImageText: `Net64+ ${process.env.VERSION}`
})
mainWindow.loadURL(path.normalize(`file://${__dirname}/index.html`))

if (process.env.NODE_ENV === 'development') {
Expand Down
9 changes: 2 additions & 7 deletions src/renderer/components/views/MainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,15 @@ class View extends React.PureComponent<MainViewProps> {
<h3>Join our community</h3>
<div>
<SMMButton
link='https://discord.gg/net64' external
link='https://discord.gg/GgGUKH8' external
text='Net64 Discord'
iconSrc='img/discord.svg'
/>
<SMMButton
link='https://smmdb.ddns.net/' external
link='https://net64-mod.github.io/' external
text='Net64 Website'
iconSrc='img/net64.svg'
/>
<SMMButton
link='https://reddit.com/r/Net64' external
text='Net64 SubReddit'
iconSrc='img/reddit.svg'
/>
</div>
</div>
)
Expand Down
26 changes: 26 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,20 @@ diffie-hellman@^5.0.0:
miller-rabin "^4.0.0"
randombytes "^2.0.0"

[email protected]:
version "0.0.8"
resolved "https://registry.yarnpkg.com/discord-rich-presence/-/discord-rich-presence-0.0.8.tgz#7a2b41ff87a278e8a2c8835cd91c9890d6b9fbdd"
integrity sha512-IpVMPjv15C9UvppxvrrGdv6bzQHOW1P1vLoMH15HvdJwGJ3dBd2bnrJ63Uy36YRUfrAMxGLiwUDHncvC8AuPaQ==
dependencies:
discord-rpc "github:discordjs/rpc"

"discord-rpc@github:discordjs/rpc":
version "3.0.1"
resolved "https://codeload.github.com/discordjs/rpc/tar.gz/60ddddc38d2bd3ffe6df91e518ac7974239562b5"
dependencies:
node-fetch "^2.3.0"
ws "^6.1.1"

[email protected], doctrine@^1.2.2:
version "1.5.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
Expand Down Expand Up @@ -6040,6 +6054,11 @@ node-emoji@^1.8.1:
dependencies:
lodash.toarray "^4.4.0"

node-fetch@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==

node-gyp-build@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-3.7.0.tgz#daa77a4f547b9aed3e2aac779eaf151afd60ec8d"
Expand Down Expand Up @@ -9264,6 +9283,13 @@ ws@^5.2.0:
dependencies:
async-limiter "~1.0.0"

ws@^6.1.1:
version "6.2.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.0.tgz#13806d9913b2a5f3cbb9ba47b563c002cbc7c526"
integrity sha512-deZYUNlt2O4buFCa3t5bKLf8A7FPP/TVjwOeVNpw818Ma5nk4MLXls2eoEGS39o8119QIYxTrTDoPQ5B/gTD6w==
dependencies:
async-limiter "~1.0.0"

xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
Expand Down

0 comments on commit 33cf24a

Please sign in to comment.