MCPcopy Create free account
hub / github.com/chrxh/alien / processProgressAnimation

Method processProgressAnimation

source/Gui/OverlayController.cpp:68–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void OverlayController::processProgressAnimation()
69{
70 if (_persisterFacade->isBusy()) {
71 _busyTimepoint = std::chrono::steady_clock::now();
72 }
73 if (!_busyTimepoint.has_value()) {
74 return;
75 }
76 auto now = std::chrono::steady_clock::now();
77 auto millisecSinceBusy = std::chrono::duration_cast<std::chrono::milliseconds>(now - *_busyTimepoint).count();
78
79 if (millisecSinceBusy < FadeoutProgressAnimationDuration) {
80 if (!_progressBarRefTimepoint.has_value()) {
81 _progressBarRefTimepoint = std::chrono::steady_clock::now();
82 }
83 auto duration = toFloat(std::chrono::duration_cast<std::chrono::milliseconds>(now - *_progressBarRefTimepoint).count());
84 auto alpha = 1.0f - toFloat(millisecSinceBusy) / FadeoutProgressAnimationDuration;
85
86 ImDrawList* drawList = ImGui::GetBackgroundDrawList();
87
88 auto viewSize = toRealVector2D(Viewport::get().getViewSize());
89 auto width = scale(300.0f);
90 auto height = scale(15.0f);
91 auto center = ImVec2{viewSize.x / 2, viewSize.y - scale(60.0f)};
92
93 drawList->AddRectFilledMultiColor(
94 ImVec2{center.x, center.y - height * 5},
95 ImVec2{center.x - width, center.y + height},
96 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
97 ImColor::HSV(0.66f, 1.0f, 0.1f,0.0f),
98 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
99 ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha));
100 drawList->AddRectFilledMultiColor(
101 ImVec2{center.x, center.y - height * 5},
102 ImVec2{center.x + width, center.y + height},
103 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
104 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
105 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
106 ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha));
107 drawList->AddRectFilledMultiColor(
108 ImVec2{center.x + width, center.y + height},
109 ImVec2{center.x, center.y + height * 6},
110 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
111 ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha),
112 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
113 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
114 drawList->AddRectFilledMultiColor(
115 ImVec2{center.x - width, center.y + height},
116 ImVec2{center.x, center.y + height * 6},
117 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
118 ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha),
119 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
120 ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
121 auto N = 16 + toInt(powf(sinf(duration / 500.0f - Const::Pi / 4) + 1, 3.0f) * 5);
122 for (int i = 0; i < N; ++i) {
123 auto amplitude1 = sinf(toFloat(i) * 10.0f / toFloat(N) - duration / 700.0f /** (1.0f + 0.3f * sinf(std::min(5000.0f, duration) / 1000))*/);
124 auto amplitude2 = sinf(toFloat(i) * 14.0f / toFloat(N) - duration / 100.0f /** (1.0f + 0.3f * cosf(std::min(5000.0f, duration) / 1000))*/);
125 //auto hue = toFloat((i * 1000 / N + toInt(duration)) % 3000) / 4500.0f;

Callers

nothing calls this directly

Calls 8

toFloatFunction · 0.85
toRealVector2DFunction · 0.85
scaleFunction · 0.85
toIntFunction · 0.85
getViewSizeMethod · 0.80
getReefMediumFontMethod · 0.80
resetMethod · 0.80
isBusyMethod · 0.45

Tested by

no test coverage detected