Skip to content

Commit

Permalink
Попытка номер раз
Browse files Browse the repository at this point in the history
  • Loading branch information
msw7007 committed Oct 9, 2024
1 parent 4167d4e commit 9ede477
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions modular_ss220/instruments/_instruments.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
#include "code/instrument_items.dm"
#include "code/concertspeaker_fake.dm"
#include "code/drumskit.dm"
#include "code/song.dm"
16 changes: 16 additions & 0 deletions modular_ss220/instruments/code/song.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#define MUSIC_INTERVAL_TICK 0.01

/datum/song/sanitize_tempo(new_tempo)
new_tempo = abs(new_tempo)
var/result = clamp(round(new_tempo, MUSIC_INTERVAL_TICK), MUSIC_INTERVAL_TICK, 5 SECONDS)
return result

/datum/song/ui_act(action, params)
. = ..()
switch(action)
if("setbpm")
set_bpm(round(text2num(params["new"]), 1))

/datum/song/set_bpm(bpm)
tempo = sanitize_tempo(600 / bpm)
SStgui.update_uis(parent)
29 changes: 9 additions & 20 deletions tgui/packages/tgui/interfaces/Instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,26 +341,15 @@ const InstrumentStatus = (properties, context) => {
</LabeledList.Item>
<LabeledList.Item label="Tempo">
<Box>
<Button
disabled={tempo >= maxTempo}
content="-"
as="span"
mr="0.5rem"
onClick={() =>
act('tempo', {
new: tempo + tickLag,
})
}
/>
{round(600 / tempo)} BPM
<Button
disabled={tempo <= minTempo}
content="+"
as="span"
ml="0.5rem"
onClick={() =>
act('tempo', {
new: tempo - tickLag,
<Slider
minValue={round(600 / maxTempo)}
maxValue={round(600 / minTempo)}
value={round(600 / tempo)}
stepPixelSize={1}
format={(v) => v + ' BPM'}
onDrag={(_e, v) =>
act('setbpm', {
new: v,
})
}
/>
Expand Down

0 comments on commit 9ede477

Please sign in to comment.