-
Notifications
You must be signed in to change notification settings - Fork 52
New: Mania #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
knvi
wants to merge
9
commits into
tosuapp:master
Choose a base branch
from
knvi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New: Mania #72
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c61ffd0
Add metadata for Mania counter by knvi
knvi 1735491
Add mania counter files
knvi f04514b
move script.js to js/script.js
knvi bcb294c
move css to css/style.css
knvi 034e644
Delete script.js
knvi c345fa8
Delete style.css
knvi 716c1f6
update file paths
knvi c4572f2
delete hitrow updated
knvi faa6fdf
update script.js to account for removed updated anim
knvi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| * { | ||
| margin: 0; | ||
| padding: 0; | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| body { | ||
| font-family: 'Arial', 'Helvetica', sans-serif; | ||
| background: transparent; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .hit-container { | ||
| display: inline-block; | ||
| background: rgba(20, 20, 30, 0.85); | ||
| padding: 9px 15px; | ||
| border-radius: 3px; | ||
| min-width: 150px; | ||
| visibility: hidden; | ||
| opacity: 0; | ||
| transition: opacity 0.3s ease, visibility 0.3s ease; | ||
| } | ||
|
|
||
| .hit-row { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| padding: 3px 0; | ||
| gap: 60px; | ||
| line-height: 1.6; | ||
| transition: all 0.1s ease; | ||
| } | ||
|
|
||
| .label { | ||
| font-weight: bold; | ||
| font-size: 18px; | ||
| letter-spacing: 0px; | ||
| text-shadow: 0px 0px 4px rgba(0, 0, 0, 1); | ||
| min-width: 33px; | ||
| text-align: left; | ||
| } | ||
|
|
||
| .value { | ||
| font-weight: bold; | ||
| font-size: 18px; | ||
| text-shadow: 0px 0px 4px rgba(0, 0, 0, 1); | ||
| text-align: right; | ||
| min-width: 45px; | ||
| } | ||
|
|
||
| .perfect .label, | ||
| .perfect .value { | ||
| color: #00FFFF; | ||
| } | ||
|
|
||
| .great .label, | ||
| .great .value { | ||
| color: #FFFF00; | ||
| } | ||
|
|
||
| .good .label, | ||
| .good .value { | ||
| color: #00FF00; | ||
| } | ||
|
|
||
| .ok .label, | ||
| .ok .value { | ||
| color: #00BFFF; | ||
| } | ||
|
|
||
| .meh .label, | ||
| .meh .value { | ||
| color: #FF00FF; | ||
| } | ||
|
|
||
| .miss .label, | ||
| .miss .value { | ||
| color: #FF0000; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Mania Counter</title> | ||
| <link rel="stylesheet" href="css/style.css"> | ||
| </head> | ||
| <body> | ||
| <div class="hit-container"> | ||
| <div class="hit-row perfect"> | ||
| <span class="label">MA</span> | ||
| <span class="value" id="perfect">0</span> | ||
| </div> | ||
| <div class="hit-row great"> | ||
| <span class="label">PR</span> | ||
| <span class="value" id="great">0</span> | ||
| </div> | ||
| <div class="hit-row good"> | ||
| <span class="label">GR</span> | ||
| <span class="value" id="good">0</span> | ||
| </div> | ||
| <div class="hit-row ok"> | ||
| <span class="label">GD</span> | ||
| <span class="value" id="ok">0</span> | ||
| </div> | ||
| <div class="hit-row meh"> | ||
| <span class="label">BD</span> | ||
| <span class="value" id="meh">0</span> | ||
| </div> | ||
| <div class="hit-row miss"> | ||
| <span class="label">MS</span> | ||
| <span class="value" id="miss">0</span> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script src="js/script.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| let socket; | ||
| let reconnectInterval; | ||
|
|
||
| const GameState = { | ||
| menu: 0, | ||
| edit: 1, | ||
| play: 2, | ||
| exit: 3, | ||
| selectEdit: 4, | ||
| selectPlay: 5, | ||
| selectDrawings: 6, | ||
| resultScreen: 7, | ||
| update: 8, | ||
| busy: 9, | ||
| unknown: 10, | ||
| lobby: 11, | ||
| matchSetup: 12, | ||
| selectMulti: 13 | ||
| }; | ||
|
|
||
| const elements = { | ||
| perfect: document.getElementById('perfect'), | ||
| great: document.getElementById('great'), | ||
| good: document.getElementById('good'), | ||
| ok: document.getElementById('ok'), | ||
| meh: document.getElementById('meh'), | ||
| miss: document.getElementById('miss') | ||
| }; | ||
|
|
||
| const container = document.querySelector('.hit-container'); | ||
|
|
||
| let previousHits = { | ||
| perfect: 0, | ||
| great: 0, | ||
| good: 0, | ||
| ok: 0, | ||
| meh: 0, | ||
| miss: 0 | ||
| }; | ||
|
|
||
| let isInGameplay = false; | ||
|
|
||
| function connectWebSocket() { | ||
| socket = new WebSocket('ws://127.0.0.1:24050/websocket/v2'); | ||
|
|
||
| socket.onopen = () => { | ||
| console.log('connected'); | ||
| if (reconnectInterval) { | ||
| clearInterval(reconnectInterval); | ||
| reconnectInterval = null; | ||
| } | ||
| }; | ||
|
|
||
| socket.onmessage = (event) => { | ||
| try { | ||
| const data = JSON.parse(event.data); | ||
| updateHitCounter(data); | ||
| } catch (error) { | ||
| console.error('error parsing data:', error); | ||
| } | ||
| }; | ||
|
|
||
| socket.onerror = (error) => { | ||
| console.error('ws error:', error); | ||
| }; | ||
|
|
||
| socket.onclose = () => { | ||
| console.log('disconnected'); | ||
| hideCounter(); | ||
| if (!reconnectInterval) { | ||
| reconnectInterval = setInterval(() => { | ||
| connectWebSocket(); | ||
| }, 3000); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| function updateHitCounter(data) { | ||
| const statusNumber = data.state?.number; | ||
|
|
||
| const isPlaying = statusNumber === GameState.play; | ||
|
|
||
| if (!isPlaying || !data.play || !data.play.hits) { | ||
| if (isInGameplay) { | ||
| hideCounter(); | ||
| resetCounter(); | ||
| isInGameplay = false; | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| if (!isInGameplay) { | ||
| showCounter(); | ||
| isInGameplay = true; | ||
| } | ||
|
|
||
| const hits = data.play.hits; | ||
|
|
||
| const currentHits = { | ||
| perfect: Number(hits.geki) || 0, | ||
| great: Number(hits['300']) || 0, | ||
| good: Number(hits.katu) || 0, | ||
| ok: Number(hits['100']) || 0, | ||
| meh: Number(hits['50']) || 0, | ||
| miss: Number(hits['0']) || 0 | ||
| }; | ||
|
|
||
| console.log('Parsed hits:', currentHits); | ||
|
|
||
| updateValue('perfect', currentHits.perfect); | ||
| updateValue('great', currentHits.great); | ||
| updateValue('good', currentHits.good); | ||
| updateValue('ok', currentHits.ok); | ||
| updateValue('meh', currentHits.meh); | ||
| updateValue('miss', currentHits.miss); | ||
|
|
||
| previousHits = currentHits; | ||
| } | ||
|
|
||
| function updateValue(key, value) { | ||
| const element = elements[key]; | ||
| if (!element) { | ||
| console.warn(`Element not found for key: ${key}`); | ||
| return; | ||
| } | ||
|
|
||
| const oldValue = parseInt(element.textContent) || 0; | ||
|
|
||
| element.textContent = value.toString(); | ||
| } | ||
|
|
||
| function showCounter() { | ||
| container.style.opacity = '1'; | ||
| container.style.visibility = 'visible'; | ||
| } | ||
|
|
||
| function hideCounter() { | ||
| container.style.opacity = '0'; | ||
| container.style.visibility = 'hidden'; | ||
| } | ||
|
|
||
| function resetCounter() { | ||
| Object.keys(elements).forEach(key => { | ||
| if (elements[key]) { | ||
| elements[key].textContent = '0'; | ||
| } | ||
| }); | ||
|
|
||
| previousHits = { | ||
| perfect: 0, | ||
| great: 0, | ||
| good: 0, | ||
| ok: 0, | ||
| meh: 0, | ||
| miss: 0 | ||
| }; | ||
| } | ||
|
|
||
| connectWebSocket(); | ||
|
|
||
| hideCounter(); | ||
|
|
||
| document.addEventListener('visibilitychange', () => { | ||
| if (!document.hidden && socket.readyState !== WebSocket.OPEN) { | ||
| connectWebSocket(); | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Usecase: in-game, obs-overlay | ||
| Name: Mania | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please find another name for this. Idk, |
||
| Version: 1.0.0 | ||
| Author: knvi | ||
| CompatibleWith: tosu | ||
| Resolution: 169x224 | ||
| authorLinks: https://github.com/knvi | ||
| Notes: just a simple mania judgement counter (inspired by etterna) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the official tosu socket.
https://github.com/tosuapp/counters/blob/master/quickstart/js/socket.js