mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: make several things rate-independent
This commit is contained in:
parent
1957c19f34
commit
e133fb4906
3 changed files with 15 additions and 12 deletions
|
@ -59,13 +59,13 @@ extern "C" {
|
|||
#define LAYOUT_INI "/layout.ini"
|
||||
#endif
|
||||
|
||||
bool Particle::update() {
|
||||
pos.x+=speed.x;
|
||||
pos.y+=speed.y;
|
||||
speed.x*=friction;
|
||||
speed.y*=friction;
|
||||
speed.y+=gravity;
|
||||
life-=lifeSpeed;
|
||||
bool Particle::update(float frameTime) {
|
||||
pos.x+=speed.x*frameTime;
|
||||
pos.y+=speed.y*frameTime;
|
||||
speed.x*=1.0-((1.0-friction)*frameTime);
|
||||
speed.y*=1.0-((1.0-friction)*frameTime);
|
||||
speed.y+=gravity*frameTime;
|
||||
life-=lifeSpeed*frameTime;
|
||||
return (life>0);
|
||||
}
|
||||
|
||||
|
@ -1437,10 +1437,11 @@ void FurnaceGUI::drawVolMeter() {
|
|||
ImGuiStyle& style=ImGui::GetStyle();
|
||||
ImGui::ItemSize(ImVec2(4.0f,4.0f),style.FramePadding.y);
|
||||
ImU32 lowColor=ImGui::GetColorU32(uiColors[GUI_COLOR_VOLMETER_LOW]);
|
||||
float peakDecay=0.05f*60.0f*ImGui::GetIO().DeltaTime;
|
||||
if (ImGui::ItemAdd(rect,ImGui::GetID("volMeter"))) {
|
||||
ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding);
|
||||
for (int i=0; i<2; i++) {
|
||||
peak[i]*=0.95;
|
||||
peak[i]*=1.0-peakDecay;
|
||||
if (peak[i]<0.0001) peak[i]=0.0;
|
||||
for (int j=0; j<e->oscSize; j++) {
|
||||
if (fabs(e->oscBuf[i][j])>peak[i]) {
|
||||
|
|
|
@ -391,7 +391,7 @@ struct Particle {
|
|||
const char* type;
|
||||
ImVec2 pos, speed;
|
||||
float gravity, friction, life, lifeSpeed;
|
||||
bool update();
|
||||
bool update(float frameTime);
|
||||
Particle(ImU32* color, const char* ty, float x, float y, float sX, float sY, float g, float fr, float l, float lS):
|
||||
colors(color),
|
||||
type(ty),
|
||||
|
|
|
@ -451,7 +451,7 @@ void FurnaceGUI::drawPattern() {
|
|||
chanHead.x*=0.25+keyHit[i]; chanHead.y*=0.25+keyHit[i]; chanHead.z*=0.25+keyHit[i];
|
||||
chanHeadActive.x*=0.8; chanHeadActive.y*=0.8; chanHeadActive.z*=0.8;
|
||||
chanHeadHover.x*=0.4+keyHit[i]; chanHeadHover.y*=0.4+keyHit[i]; chanHeadHover.z*=0.4+keyHit[i];
|
||||
keyHit[i]-=0.02;
|
||||
keyHit[i]-=0.02*60.0*ImGui::GetIO().DeltaTime;
|
||||
if (keyHit[i]<0) keyHit[i]=0;
|
||||
ImGui::PushStyleColor(ImGuiCol_Header,chanHead);
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderActive,chanHeadActive);
|
||||
|
@ -717,6 +717,8 @@ void FurnaceGUI::drawPattern() {
|
|||
}
|
||||
}
|
||||
|
||||
float frameTime=ImGui::GetIO().DeltaTime*60.0f;
|
||||
|
||||
// note slides
|
||||
ImVec2 arrowPoints[7];
|
||||
if (e->isPlaying()) for (int i=0; i<chans; i++) {
|
||||
|
@ -763,7 +765,7 @@ void FurnaceGUI::drawPattern() {
|
|||
dl->AddPolyline(arrowPoints,7,ImGui::GetColorU32(col),ImDrawFlags_None,5.0f*dpiScale);
|
||||
}
|
||||
}
|
||||
patChanSlideY[i]+=((ch->portaNote<=ch->note)?-8:8)*dpiScale;
|
||||
patChanSlideY[i]+=((ch->portaNote<=ch->note)?-8:8)*dpiScale*frameTime;
|
||||
if (width>0) {
|
||||
if (patChanSlideY[i]<0) {
|
||||
patChanSlideY[i]=-fmod(-patChanSlideY[i],width*0.7);
|
||||
|
@ -778,7 +780,7 @@ void FurnaceGUI::drawPattern() {
|
|||
ImDrawList* fdl=ImGui::GetForegroundDrawList();
|
||||
for (size_t i=0; i<particles.size(); i++) {
|
||||
Particle& part=particles[i];
|
||||
if (part.update()) {
|
||||
if (part.update(frameTime)) {
|
||||
if (part.life>255) part.life=255;
|
||||
fdl->AddText(
|
||||
iconFont,
|
||||
|
|
Loading…
Reference in a new issue