Add Next and Prev ops to menu. I think it is done now.
This commit is contained in:
parent
00f13f71c1
commit
faf7d81198
118
src/main.cpp
118
src/main.cpp
|
@ -141,6 +141,66 @@ void DrawPlay(Vector2 Pos, float scale, Color color) {
|
||||||
DrawTriangle(backtop, backbot, front, color);
|
DrawTriangle(backtop, backbot, front, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawNext(Vector2 Pos, float scale, Color color) {
|
||||||
|
Vector2 backtop = (Vector2) { .x=-0.35f, .y=-0.35f };
|
||||||
|
Vector2 backbot = (Vector2) { .x=-0.35f, .y=0.35f};
|
||||||
|
Vector2 front = (Vector2) {.x = 0.28f, .y=0};
|
||||||
|
|
||||||
|
backtop = Vector2Scale(backtop, scale);
|
||||||
|
backbot = Vector2Scale(backbot, scale);
|
||||||
|
front = Vector2Scale(front, scale);
|
||||||
|
|
||||||
|
backtop = Vector2Add(backtop, Pos);
|
||||||
|
backbot = Vector2Add(backbot, Pos);
|
||||||
|
front = Vector2Add(front, Pos);
|
||||||
|
|
||||||
|
DrawTriangle(backtop, backbot, front, color);
|
||||||
|
|
||||||
|
Vector2 topleft = (Vector2) {.x = -0.29f, .y = -0.4f };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Vector2 bar2topleft = Vector2Add(topleft, (Vector2) {0.706f*0.6f, .y=0});
|
||||||
|
bar2topleft = Vector2Scale(bar2topleft, scale);
|
||||||
|
bar2topleft = Vector2Add(bar2topleft, Pos);
|
||||||
|
|
||||||
|
Vector2 size = (Vector2) {.x=0.706f *0.2f, .y = 0.8f };
|
||||||
|
size = Vector2Scale(size, scale);
|
||||||
|
|
||||||
|
|
||||||
|
DrawRectangleV(bar2topleft, size, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawBack(Vector2 Pos, float scale, Color color) {
|
||||||
|
Vector2 backtop = (Vector2) { .x=0.35f, .y=-0.35f };
|
||||||
|
Vector2 backbot = (Vector2) { .x=0.35f, .y=0.35f};
|
||||||
|
Vector2 front = (Vector2) {.x = -0.28f, .y=0};
|
||||||
|
|
||||||
|
backtop = Vector2Scale(backtop, scale);
|
||||||
|
backbot = Vector2Scale(backbot, scale);
|
||||||
|
front = Vector2Scale(front, scale);
|
||||||
|
|
||||||
|
backtop = Vector2Add(backtop, Pos);
|
||||||
|
backbot = Vector2Add(backbot, Pos);
|
||||||
|
front = Vector2Add(front, Pos);
|
||||||
|
|
||||||
|
//DrawTriangle(backtop, backbot, front, color);
|
||||||
|
DrawTriangle(front, backbot, backtop, color);
|
||||||
|
|
||||||
|
Vector2 topleft = (Vector2) {.x = -0.29f, .y = -0.4f };
|
||||||
|
|
||||||
|
|
||||||
|
Vector2 bar1topleft = Vector2Scale(topleft, scale);
|
||||||
|
bar1topleft = Vector2Add(bar1topleft, Pos);
|
||||||
|
|
||||||
|
Vector2 size = (Vector2) {.x=0.706f *0.2f, .y = 0.8f };
|
||||||
|
size = Vector2Scale(size, scale);
|
||||||
|
|
||||||
|
|
||||||
|
DrawRectangleV(bar1topleft, size, color);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawStop(Vector2 Pos, float scale, Color color) {
|
void DrawStop(Vector2 Pos, float scale, Color color) {
|
||||||
Vector2 topleft = (Vector2) {.x = -0.353f, .y = -0.353f };
|
Vector2 topleft = (Vector2) {.x = -0.353f, .y = -0.353f };
|
||||||
Vector2 botright = (Vector2) {.x = 0.353f, .y = 0.353f };
|
Vector2 botright = (Vector2) {.x = 0.353f, .y = 0.353f };
|
||||||
|
@ -204,38 +264,6 @@ int main(int argc, char *argv[]) {
|
||||||
std::vector<std::string> serviceList = GetMprisServices();
|
std::vector<std::string> serviceList = GetMprisServices();
|
||||||
|
|
||||||
auto current_player = MprisPlayer("org.mpris.MediaPlayer2.playerctld");
|
auto current_player = MprisPlayer("org.mpris.MediaPlayer2.playerctld");
|
||||||
// current_player.pp();
|
|
||||||
/*
|
|
||||||
auto connection = sdbus::createSessionBusConnection();
|
|
||||||
|
|
||||||
sdbus::ServiceName dest{"org.freedesktop.DBus"};
|
|
||||||
sdbus::ObjectPath objec{"/org/freedesktop/DBus"};
|
|
||||||
|
|
||||||
auto prox = sdbus::createProxy(dest, objec);
|
|
||||||
sdbus::InterfaceName interfaceName{"org.freedesktop.DBus"};
|
|
||||||
sdbus::MethodName introspect("ListNames");
|
|
||||||
|
|
||||||
auto method = prox->createMethodCall(interfaceName, introspect);
|
|
||||||
auto reply = prox->callMethod(method);
|
|
||||||
std::vector<std::string> res;
|
|
||||||
reply >> res;
|
|
||||||
for (std::string item : res) {
|
|
||||||
std::cout << item << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// if the linked ImGui has docking, enable it.
|
|
||||||
// this will only be true if you use the docking branch of ImGui.
|
|
||||||
#ifdef IMGUI_HAS_DOCK
|
|
||||||
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// for (json::iterator it = course_info.begin(); it != course_info.end(); ++it) {
|
|
||||||
// std::cout << *it << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
double lasttime = 0.0;
|
double lasttime = 0.0;
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose() &&
|
while (!WindowShouldClose() &&
|
||||||
|
@ -276,16 +304,35 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
DrawPlay(centerline, 0.1*GetScreenWidth(), WHITE);
|
DrawPlay(centerline, 0.1*GetScreenWidth(), WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 next = Vector2Add(centerline, (Vector2) {screen.x * 0.2f, 0.0f});
|
||||||
|
DrawCircleV(next, 0.05*GetScreenWidth(), transblack);
|
||||||
|
DrawNext(next, 0.1*GetScreenWidth(), WHITE);
|
||||||
|
|
||||||
|
Vector2 back = Vector2Add(centerline, (Vector2) {screen.x * -0.2f, 0.0f});
|
||||||
|
DrawCircleV(back, 0.05*GetScreenWidth(), transblack);
|
||||||
|
DrawBack(back, 0.1*GetScreenWidth(), WHITE);
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), centerline, 0.05*GetScreenWidth()) ) {
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), centerline, 0.05*GetScreenWidth()) ) {
|
||||||
current_player.PausePlay();
|
current_player.PausePlay();
|
||||||
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), next, 0.05*GetScreenWidth()) ) {
|
||||||
|
current_player.Next();
|
||||||
|
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), back, 0.05*GetScreenWidth()) ) {
|
||||||
|
current_player.Prev();
|
||||||
|
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SLASH)) {
|
if (IsKeyPressed(KEY_SLASH) || IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
|
||||||
showIMgui = !showIMgui;
|
showIMgui = !showIMgui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,15 +374,20 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (ImGui::Begin("Player Control")) {
|
if (ImGui::Begin("Player Control")) {
|
||||||
ImGui::Text("%s", current_player.GetIdentity().c_str());
|
ImGui::Text("%s", current_player.GetIdentity().c_str());
|
||||||
|
|
||||||
|
|
||||||
if (ImGui::Button("Prev")) {
|
if (ImGui::Button("Prev")) {
|
||||||
current_player.Prev();
|
current_player.Prev();
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Play/Pause")) {
|
if (ImGui::Button("Play/Pause")) {
|
||||||
current_player.PausePlay();
|
current_player.PausePlay();
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Next")) {
|
if (ImGui::Button("Next")) {
|
||||||
current_player.Next();
|
current_player.Next();
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Refresh")) {
|
if (ImGui::Button("Refresh")) {
|
||||||
current_player.Refresh();
|
current_player.Refresh();
|
||||||
current_player.UpdateTexture();
|
current_player.UpdateTexture();
|
||||||
|
|
Loading…
Reference in a new issue