Skip to content

Commit

Permalink
Merge pull request #55 from darkxex/master
Browse files Browse the repository at this point in the history
battery
  • Loading branch information
darkxex authored Feb 27, 2022
2 parents aa5fe27 + a335c83 commit 9726a39
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/custom_widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#include <imgui.h>
#include <stdint.h>

void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel);
void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel, float w, float h);
16 changes: 13 additions & 3 deletions source/UI/custom_widgets.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "custom_widgets.h"

void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel){

ImVec2 iconsize = ImVec2(50.0f, 20.0f);
void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel, float w, float h){

//ImVec2 iconsize = ImVec2(50.0f, 20.0f);
ImVec2 iconsize = ImVec2(w, h);

ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
if(absolute){
canvas_p0 = pos;
Expand All @@ -18,7 +19,16 @@ void batteryIcon(ImVec2 pos,bool absolute,uint32_t batlevel){

//ImDrawList* draw_list = ImGui::GetWindowDrawList();
ImGui::GetForegroundDrawList()->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(0, 0, 0, 255));
//green
if(batlevel >= 66)
ImGui::GetForegroundDrawList()->AddRectFilled(canvas_pnew, batteryfill, IM_COL32(50, 255, 50, 255));
//yellow
else if(batlevel >= 33 )
ImGui::GetForegroundDrawList()->AddRectFilled(canvas_pnew, batteryfill, IM_COL32(255, 204, 0, 255));
//red
else if(batlevel >= 0 )
ImGui::GetForegroundDrawList()->AddRectFilled(canvas_pnew, batteryfill, IM_COL32(204, 51, 0, 255));

ImGui::GetForegroundDrawList()->AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255));

ImGui::GetForegroundDrawList()->AddRectFilled(batteryicon_p0, batteryicon_p1, IM_COL32(255, 255, 255, 255));
Expand Down
1 change: 0 additions & 1 deletion source/UI/mainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Windows {
void MainMenuWindow(bool *focus, bool *first_item) {
Windows::SetupMainWindow();
std::vector<std::string> topmenu = configini->topmenu;
batteryIcon(ImVec2(1200.0f,5.0f),true,35);
if (ImGui::Begin(nxmpTitle.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse)) {
static int selected = -1;
for (unsigned int n = 0; n < topmenu.size(); n++){
Expand Down
10 changes: 6 additions & 4 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "imgui.h"
#include "utils.h"
#include "imgui_internal.h"
#include "custom_widgets.h"
#ifdef NXMP_SWITCH
#include "SwitchSys.h"
#endif
Expand Down Expand Up @@ -91,11 +92,12 @@ namespace playerWindows{
*first_item = false;
}
//battery

ImGui::SetCursorPosY(ImGui::GetWindowSize().y -80);
ImGui::SetCursorPosY(ImGui::GetWindowSize().y -40);
ImGui::Separator();
ImGui::Text("Battery");
ImGui::ProgressBar((float)batteryPorcent/100, ImVec2(180, 0));
batteryIcon(ImVec2(rightmenuposX + 15.0f,ImGui::GetWindowSize().y -24),true,batteryPorcent,40,18);
ImGui::Text(" %d%%",batteryPorcent);

//endBattery

ImGui::EndListBox();
Expand Down

0 comments on commit 9726a39

Please sign in to comment.