Skip to content

Commit

Permalink
Re-added country + more
Browse files Browse the repository at this point in the history
- Set menus::init() for overlay to set defaults
- Favorites add to file
- Auto refresh
- Pref directory
- More FS stuff
- Settings update
- Favorites save
  • Loading branch information
BttrDrgn committed May 12, 2022
1 parent 1fcda8c commit 82159cd
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 41 deletions.
7 changes: 5 additions & 2 deletions src/app/hook/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ bool hook::load(process_t proc)
for (const std::string& dll : hook::dlls)
{
#ifdef _M_AMD64
std::string dll_path = fs::get_cur_dir().append(logger::va("\\x86_64\\%s", &dll[0]));
std::string dll_path = fs::get_cur_dir().append(logger::va("x86_64\\%s", &dll[0]));
#else
std::string dll_path = fs::get_cur_dir().append(logger::va("\\x86\\%s", &dll[0]));
std::string dll_path = fs::get_cur_dir().append(logger::va("x86\\%s", &dll[0]));
#endif
logger::log_debug(logger::va("Loading %s", &dll_path[0]));

Expand Down Expand Up @@ -61,7 +61,10 @@ bool hook::load(process_t proc)
BringWindowToTop(proc.hwnd);
SetForegroundWindow(proc.hwnd);
SetFocus(proc.hwnd);
//Set to top most temporarily
SetWindowPos(proc.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
//Set back
SetWindowPos(proc.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
ShowWindow(proc.hwnd, SW_NORMAL);

return true;
Expand Down
3 changes: 2 additions & 1 deletion src/app/hook/impl/d3d10_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ long __stdcall hkPresent10(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT F
audio::init_overlay(hwnd);
input::init_overlay(hwnd);

ImGui::CreateContext();
menus::init();

ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX10_Init(device);

Expand Down
3 changes: 2 additions & 1 deletion src/app/hook/impl/d3d11_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ long __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT F
audio::init_overlay(hwnd);
input::init_overlay(hwnd);

ImGui::CreateContext();
menus::init();

ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(device, context);

Expand Down
3 changes: 2 additions & 1 deletion src/app/hook/impl/d3d9_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ long __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
audio::init_overlay(hwnd);
input::init_overlay(hwnd);

ImGui::CreateContext();
menus::init();

ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX9_Init(pDevice);

Expand Down
3 changes: 2 additions & 1 deletion src/app/hook/impl/opengl3_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ BOOL __stdcall hwglSwapBuffers(_In_ HDC hDc)
audio::init_overlay(hwnd);
input::init_overlay(hwnd);

ImGui::CreateContext();
menus::init();

ImGui_ImplWin32_Init(hwnd);
ImGui_ImplOpenGL3_Init();

Expand Down
2 changes: 2 additions & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "menus/menus.hpp"
#include "audio/audio.hpp"
#include "settings/settings.hpp"
#include "fs/fs.hpp"

#ifndef OVERLAY
#include "window/window.hpp"
Expand All @@ -28,6 +29,7 @@ void init_app()
#endif
#endif

fs::init();
settings::init();

global::desired_framerate = 60;
Expand Down
112 changes: 101 additions & 11 deletions src/app/menus/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "api/api.hpp"
#include "audio/audio.hpp"
#include "hook/hook.hpp"
#include "settings/settings.hpp"

#ifndef OVERLAY
#include "gfx/gfx.hpp"
Expand All @@ -15,21 +16,25 @@
#include <shellapi.h>
#endif

#ifndef OVERLAY

void menus::init()
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();

ImGui::GetIO().IniFilename = nullptr;

menus::build_font(ImGui::GetIO());

#ifndef OVERLAY
ImGui_ImplSDL2_InitForSDLRenderer(global::window, global::renderer);
ImGui_ImplSDLRenderer_Init(global::renderer);
}
#endif
}

void menus::update()
{

#ifndef OVERLAY
if (menus::show_snow)
{
Expand All @@ -46,8 +51,21 @@ void menus::update()
menus::snow = {};
}
}

static float count = 0;
count += 1.0f * global::get_timestep();
if (count > 100.0f)
{
count = 0.0f;
if (hook::auto_refresh)
{
hook::get_procs();
}
}
#endif

settings::update();

#ifdef OVERLAY
if (!global::hide)
{
Expand Down Expand Up @@ -299,9 +317,34 @@ void menus::places()
if (ImGui::Button("Reset Filter"))
{
menus::filtering = false;
menus::current_country = "N/A";
memset(menus::search_buffer, 0, sizeof(menus::search_buffer));
}

if (ImGui::BeginCombo("Country", &menus::current_country[0]))
{
if (api::places_done)
{
if (ImGui::Button("Reset ##country"))
{
menus::current_country = "N/A";
}

ImGui::NewLine();

for (std::string c : api::all_countries)
{
if (ImGui::Button(&c[0]))
{
menus::current_country = c;

ImGui::CloseCurrentPopup();
}
}
}
ImGui::EndCombo();
}

if (ImGui::InputText("Search", menus::search_buffer, sizeof(search_buffer)))
{
menus::filtering = true;
Expand Down Expand Up @@ -349,10 +392,21 @@ void menus::places()

for (auto place : api::places)
{
if (ImGui::Button(&logger::va("[%s] %s", &place.country[0], &place.city[0])[0]))
if (!menus::current_country.compare("N/A"))
{
api::get_details(place);
ImGui::CloseCurrentPopup();
if (ImGui::Button(&logger::va("[%s] %s", &place.country[0], &place.city[0])[0]))
{
api::get_details(place);
ImGui::CloseCurrentPopup();
}
}
else if (!menus::current_country.compare(place.country))
{
if (ImGui::Button(&logger::va("%s", &place.city[0])[0]))
{
api::get_details(place);
ImGui::CloseCurrentPopup();
}
}
}
}
Expand All @@ -365,13 +419,25 @@ void menus::places()
ImGui::Text("No results found with the search term\n%s", menus::search_buffer);
ImGui::Text("Tip: Search filters country, city, and place ID; case sensitive");
}
else
{
for (auto place : api::filtered_places)
{
if (ImGui::Button(&logger::va("[%s] %s", &place.country[0], &place.city[0])[0]))
if (!menus::current_country.compare("N/A"))
{
api::get_details(place);
ImGui::CloseCurrentPopup();
if (ImGui::Button(&logger::va("[%s] %s", &place.country[0], &place.city[0])[0]))
{
api::get_details(place);
ImGui::CloseCurrentPopup();
}
}
else if (!menus::current_country.compare(place.country))
{
if (ImGui::Button(&logger::va("%s", &place.city[0])[0]))
{
api::get_details(place);
ImGui::CloseCurrentPopup();
}
}
}
}
Expand Down Expand Up @@ -423,6 +489,7 @@ void menus::stations()
if (!has)
{
api::favorite_stations.emplace_back(station);
settings::add_favorite(station);
}
}
}
Expand Down Expand Up @@ -452,6 +519,21 @@ void menus::favorites()
audio::currently_playing.region.country = station.place.country;
audio::play(station.id);
}

ImGui::SameLine();

if (ImGui::Button(&logger::va("-##%s", &station.id[0])[0]))
{
for (int i = 0; i < api::favorite_stations.size(); i++)
{
if (api::favorite_stations[i].id == station.id)
{
settings::remove_favorite(station);
api::favorite_stations.erase(api::favorite_stations.begin() + i);
break;
}
}
}
}
}
ImGui::EndMenu();
Expand Down Expand Up @@ -482,6 +564,13 @@ void menus::overlay()
{
hook::get_procs();
}

ImGui::SameLine();

if (ImGui::Button(&logger::va("Auto Refresh [%s]", &logger::get_toggle(hook::auto_refresh)[0])[0]))
{
hook::auto_refresh = !hook::auto_refresh;
}

ImGui::NewLine();

Expand Down Expand Up @@ -543,9 +632,9 @@ void menus::enumerate_snow()

void menus::build_font(ImGuiIO& io)
{
std::string font = fs::get_cur_dir().append("/fonts/NotoSans-Regular.ttf");
std::string font_jp = fs::get_cur_dir().append("/fonts/NotoSansJP-Regular.ttf");
std::string emoji = fs::get_cur_dir().append("/fonts/NotoEmoji-Regular.ttf");
std::string font = fs::get_pref_dir().append("fonts/NotoSans-Regular.ttf");
std::string font_jp = fs::get_pref_dir().append("fonts/NotoSansJP-Regular.ttf");
std::string emoji = fs::get_pref_dir().append("fonts/NotoEmoji-Regular.ttf");

if (fs::exists(font))
{
Expand Down Expand Up @@ -583,3 +672,4 @@ bool menus::show_drpc;

bool menus::filtering = false;
char menus::search_buffer[64];
std::string menus::current_country = "N/A";
3 changes: 2 additions & 1 deletion src/app/menus/menus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
class menus
{
public:
static void init();
static void update();

#ifndef OVERLAY
static void init();
static void prepare();
static void present();
static void cleanup();
Expand All @@ -21,6 +21,7 @@ class menus
static bool show_drpc;

static char search_buffer[64];
static std::string current_country;

static std::string currently_playing;

Expand Down
Loading

0 comments on commit 82159cd

Please sign in to comment.