Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GameDevWeek
S
Sommersemester 2019
Cpp
PhaseShifter
Commits
a7c72dc0
Commit
a7c72dc0
authored
Sep 21, 2019
by
Florian Oetke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ui hud tweaks
parent
4b9f919b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
src/ui/hud_system.cpp
src/ui/hud_system.cpp
+23
-20
No files found.
src/ui/hud_system.cpp
View file @
a7c72dc0
...
...
@@ -13,7 +13,7 @@ namespace phase_shifter::ui {
using
namespace
mirrage
::
gui
::
literals
;
namespace
{
constexpr
auto
hud_height
=
1
0
0
;
constexpr
auto
hud_height
=
1
3
0
;
constexpr
auto
bar_height
=
80
;
constexpr
auto
beat_bar_height
=
79
;
constexpr
auto
bar_speed
=
100
;
...
...
@@ -38,35 +38,24 @@ namespace phase_shifter::ui {
if
(
font
.
is_some
())
ImGui
::
PushFont
(
font
.
get_or_throw
());
ImGui
::
PositionNextWindow
(
glm
::
vec2
(
viewport
.
z
,
hud_height
),
ImGui
::
WindowPosition_X
::
left
,
ImGui
::
WindowPosition_Y
::
top
);
if
(
ImGui
::
Begin
(
"hud"
,
nullptr
,
ImGuiWindowFlags_NoTitleBar
|
ImGuiWindowFlags_NoMove
|
ImGuiWindowFlags_NoResize
|
ImGuiWindowFlags_NoBackground
|
ImGuiWindowFlags_NoInputs
))
{
ImGui
::
Text
(
"%i"
,
_beat_system
.
beat_state
().
beats_left
);
ImGui
::
End
();
}
ImGui
::
PushStyleColor
(
ImGuiCol_WindowBg
,
ImColor
(
0
,
0
,
0
,
180
).
Value
);
ImGui
::
PushStyleColor
(
ImGuiCol_Border
,
ImColor
(
0
,
0
,
0
,
0
).
Value
);
ImGui
::
PositionNextWindow
(
glm
::
vec2
(
viewport
.
z
,
hud_height
),
ImGui
::
WindowPosition_X
::
center
,
ImGui
::
WindowPosition_Y
::
bottom
);
if
(
ImGui
::
Begin
(
"beat"
,
nullptr
,
ImGuiWindowFlags_NoTitleBar
|
ImGuiWindowFlags_NoMove
|
ImGuiWindowFlags_NoResize
|
ImGuiWindowFlags_No
Background
|
ImGuiWindowFlags_No
Inputs
))
{
|
ImGuiWindowFlags_No
Inputs
|
ImGuiWindowFlags_No
Scrollbar
))
{
ImGui
::
PushStyleColor
(
ImGuiCol_Border
,
"#00000000"
_imcolor
.
Value
);
// Hide Border
ImVec2
cursor
=
ImGui
::
GetCursorScreenPos
();
cursor
.
y
+=
hud_height
/
2.
f
-
10
;
cursor
.
y
+=
hud_height
/
2.
f
+
10
;
auto
beat_state
=
_beat_system
.
beat_state
();
auto
beats
=
_beat_system
.
time_stamps
();
auto
beat_index
=
_beat_system
.
beat_index
()
+
1
;
//auto line_offset = bar_speed * beat_state.avg_beat_time;
//auto beats = std::clamp(beat_state.beats_left, 0, 5);
ImGui
::
BeginChild
(
"Line"
,
{
viewport
.
z
,
bar
_height
},
true
);
ImGui
::
BeginChild
(
"Line"
,
{
viewport
.
z
,
hud
_height
},
true
);
ImDrawList
*
drawList
=
ImGui
::
GetWindowDrawList
();
while
(
beat_index
<
static_cast
<
int
>
(
beats
.
size
()))
{
...
...
@@ -75,10 +64,10 @@ namespace phase_shifter::ui {
auto
bar_color
=
beat_index
<
static_cast
<
int
>
(
beats
.
size
()
*
0.8
f
)
?
0xFFFFFFFF
:
0xFF0000FF
;
ImVec2
p
(
cursor
.
x
+
viewport
.
z
/
2
-
x_offset
,
cursor
.
y
-
height
/
2.
f
);
drawList
->
AddLine
(
p
,
{
p
.
x
,
p
.
y
+
height
},
bar_color
,
1
);
drawList
->
AddLine
(
p
,
{
p
.
x
,
p
.
y
+
height
},
bar_color
,
2
);
p
.
x
=
cursor
.
x
+
viewport
.
z
/
2
+
x_offset
;
drawList
->
AddLine
(
p
,
{
p
.
x
,
p
.
y
+
height
},
bar_color
,
1
);
drawList
->
AddLine
(
p
,
{
p
.
x
,
p
.
y
+
height
},
bar_color
,
2
);
if
(
x_offset
>
beat_bar_length
+
50
)
{
break
;
...
...
@@ -87,7 +76,18 @@ namespace phase_shifter::ui {
}
ImVec2
middle
(
cursor
.
x
+
viewport
.
z
/
2
,
cursor
.
y
-
bar_height
/
2.
f
);
drawList
->
AddLine
(
middle
,
{
middle
.
x
,
middle
.
y
+
bar_height
},
0xFFFF0000
,
4
);
drawList
->
AddLine
(
middle
,
{
middle
.
x
,
middle
.
y
+
bar_height
},
0xFFFF0000
,
6
);
auto
beat_color
=
(
_beat_system
.
beat_state
().
beats_left
<
50
&&
_beat_system
.
beat_state
().
beats_left
%
2
==
0
)
?
ImColor
(
255
,
0
,
0
)
:
ImColor
(
255
,
255
,
255
);
auto
beats_left
=
std
::
to_string
(
_beat_system
.
beat_state
().
beats_left
);
auto
text_size
=
ImGui
::
CalcTextSize
(
beats_left
.
c_str
());
drawList
->
AddText
(
ImVec2
(
middle
.
x
-
text_size
.
x
/
2.
f
,
middle
.
y
-
text_size
.
y
-
10
),
beat_color
,
beats_left
.
c_str
());
ImGui
::
EndChild
();
ImGui
::
PopStyleColor
();
...
...
@@ -102,6 +102,9 @@ namespace phase_shifter::ui {
}
}
ImGui
::
PopStyleColor
();
ImGui
::
PopStyleColor
();
if
(
font
.
is_some
())
ImGui
::
PopFont
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment