feat(Windows): Added player window
This commit is contained in:
parent
260ebf9a88
commit
bebf912131
@ -8,6 +8,11 @@ namespace big
|
|||||||
void backend::loop()
|
void backend::loop()
|
||||||
{
|
{
|
||||||
g.attempt_save();
|
g.attempt_save();
|
||||||
|
QUEUE_JOB_BEGIN_CLAUSE()
|
||||||
|
{
|
||||||
|
looped::system_screen_size();
|
||||||
|
looped::system_update_players();
|
||||||
|
}QUEUE_JOB_END_CLAUSE
|
||||||
|
|
||||||
QUEUE_JOB_BEGIN_CLAUSE()
|
QUEUE_JOB_BEGIN_CLAUSE()
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,9 @@ namespace big
|
|||||||
static void self_noclip();
|
static void self_noclip();
|
||||||
static void self_no_ragdoll();
|
static void self_no_ragdoll();
|
||||||
|
|
||||||
|
static void system_update_players();
|
||||||
|
static void system_screen_size();
|
||||||
|
|
||||||
static void weapons_cage_gun();
|
static void weapons_cage_gun();
|
||||||
static void weapons_delete_gun();
|
static void weapons_delete_gun();
|
||||||
static void weapons_gravity_gun();
|
static void weapons_gravity_gun();
|
||||||
|
14
BigBaseV2/src/backend/looped/system/screen_size.cpp
Normal file
14
BigBaseV2/src/backend/looped/system/screen_size.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "backend/looped/looped.hpp"
|
||||||
|
#include "fiber_pool.hpp"
|
||||||
|
#include "natives.hpp"
|
||||||
|
#include "script.hpp"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
static bool bLastGodMode = false;
|
||||||
|
|
||||||
|
void looped::system_screen_size()
|
||||||
|
{
|
||||||
|
GRAPHICS::_GET_ACTIVE_SCREEN_RESOLUTION(&g.window.x, &g.window.y);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
#include "backend/looped/looped.hpp"
|
||||||
|
#include "natives.hpp"
|
||||||
|
#include "script.hpp"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
static bool busy = false;
|
||||||
|
|
||||||
|
void looped::system_update_players()
|
||||||
|
{
|
||||||
|
if (busy) return;
|
||||||
|
busy = true;
|
||||||
|
|
||||||
|
for (Player i = 0; i < 32; i++)
|
||||||
|
{
|
||||||
|
if (NETWORK::NETWORK_IS_PLAYER_CONNECTED(i) && i != PLAYER::PLAYER_ID())
|
||||||
|
{
|
||||||
|
// if (!g.players[i].is_online) // tell user player joined
|
||||||
|
|
||||||
|
g.players[i].is_online = true;
|
||||||
|
|
||||||
|
int iNetworkHandle[26];
|
||||||
|
NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13);
|
||||||
|
NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]);
|
||||||
|
|
||||||
|
g.players[i].is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(iNetworkHandle, 13) && NETWORK::NETWORK_IS_FRIEND(iNetworkHandle);
|
||||||
|
|
||||||
|
strcpy(g.players[i].name, PLAYER::GET_PLAYER_NAME(i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.players[i].is_online = false;
|
||||||
|
g.players[i].is_friend = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
script::get_current()->yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
busy = false;
|
||||||
|
}
|
||||||
|
}
|
30
BigBaseV2/src/core/data/player_struct.hpp
Normal file
30
BigBaseV2/src/core/data/player_struct.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef PLAYER_STRUCT
|
||||||
|
#define PLAYER_STRUCT
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
struct CPlayer
|
||||||
|
{
|
||||||
|
char name[20];
|
||||||
|
|
||||||
|
bool is_friend = false;
|
||||||
|
bool is_online = false;
|
||||||
|
|
||||||
|
bool operator < (const CPlayer& another) const
|
||||||
|
{
|
||||||
|
char temp[20], temp2[20];
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
temp[i] = tolower(this->name[i]);
|
||||||
|
temp2[i] = tolower(another.name[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return strcmp(temp, temp2) < 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "data/player_struct.hpp"
|
||||||
#include "enums.hpp"
|
#include "enums.hpp"
|
||||||
|
|
||||||
#ifndef GLOBALS_H
|
#ifndef GLOBALS_H
|
||||||
@ -9,6 +10,10 @@ struct globals {
|
|||||||
nlohmann::json default_options;
|
nlohmann::json default_options;
|
||||||
nlohmann::json options;
|
nlohmann::json options;
|
||||||
|
|
||||||
|
struct player {
|
||||||
|
bool spectating = false;
|
||||||
|
};
|
||||||
|
|
||||||
struct self {
|
struct self {
|
||||||
bool godmode = false;
|
bool godmode = false;
|
||||||
bool off_radar = false;
|
bool off_radar = false;
|
||||||
@ -29,8 +34,17 @@ struct globals {
|
|||||||
struct window {
|
struct window {
|
||||||
bool main = true;
|
bool main = true;
|
||||||
bool log = false;
|
bool log = false;
|
||||||
|
bool users = false;
|
||||||
|
bool player = false;
|
||||||
|
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CPlayer players[32];
|
||||||
|
CPlayer selected_player;
|
||||||
|
|
||||||
|
player player{};
|
||||||
self self{};
|
self self{};
|
||||||
vehicle vehicle{};
|
vehicle vehicle{};
|
||||||
weapons weapons{};
|
weapons weapons{};
|
||||||
|
@ -10,5 +10,8 @@ namespace big
|
|||||||
window::log();
|
window::log();
|
||||||
|
|
||||||
window::main();
|
window::main();
|
||||||
|
|
||||||
|
window::player();
|
||||||
|
window::users();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,5 +7,7 @@ namespace big
|
|||||||
static void top_bar();
|
static void top_bar();
|
||||||
static void log();
|
static void log();
|
||||||
static void main();
|
static void main();
|
||||||
|
static void player();
|
||||||
|
static void users();
|
||||||
};
|
};
|
||||||
}
|
}
|
27
BigBaseV2/src/gui/window/window_player.cpp
Normal file
27
BigBaseV2/src/gui/window/window_player.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "gui/window.hpp"
|
||||||
|
#include "imgui.h"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
void window::player()
|
||||||
|
{
|
||||||
|
if (!g.selected_player.is_online) return;
|
||||||
|
|
||||||
|
char title[64];
|
||||||
|
strcpy(title, "Player Options: ");
|
||||||
|
strcat(title, g.selected_player.name);
|
||||||
|
strcat(title, "###player_options");
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSize({ 350.f, 300.f }, ImGuiCond_FirstUseEver);
|
||||||
|
if (g.window.player && ImGui::Begin(title, &g.window.player))
|
||||||
|
{
|
||||||
|
/*ImGui::BeginTabBar("tabbar_player");
|
||||||
|
|
||||||
|
ImGui::EndTabBar();*/
|
||||||
|
|
||||||
|
ImGui::Checkbox("Spectate", &g.player.spectating);
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
BigBaseV2/src/gui/window/window_users.cpp
Normal file
84
BigBaseV2/src/gui/window/window_users.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "gui/window.hpp"
|
||||||
|
#include "imgui.h"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
void window::users()
|
||||||
|
{
|
||||||
|
static const float height_correction = 28.f;
|
||||||
|
static const float width = 170.f;
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSize({ width, (float)g.window.y - height_correction }, ImGuiCond_Always);
|
||||||
|
ImGui::SetNextWindowPos({ g.window.x - width, height_correction }, ImGuiCond_Always);
|
||||||
|
if (ImGui::Begin("###player_menu", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav))
|
||||||
|
{
|
||||||
|
auto vecButtonWidth = ImVec2(ImGui::GetWindowSize().x - 30.f, 0.0f);
|
||||||
|
|
||||||
|
//ImGui::TextColored({ 255,255,255,255 }, "YOU:");
|
||||||
|
|
||||||
|
//if (ImGui::Button(g_player.name, vecButtonWidth))
|
||||||
|
//{
|
||||||
|
// g_selectedPlayer = g_player;
|
||||||
|
// g_temp.windows.player = true;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//ImGui::Separator();
|
||||||
|
|
||||||
|
char title[64];
|
||||||
|
sprintf(title, "Friends (%d)###friend_lists", 0);
|
||||||
|
if (ImGui::TreeNode(title))
|
||||||
|
{
|
||||||
|
ImGui::Unindent();
|
||||||
|
|
||||||
|
bool friendInLobby = false;
|
||||||
|
|
||||||
|
for (auto& player : g.players)
|
||||||
|
{
|
||||||
|
if (player.is_friend && player.is_online)
|
||||||
|
{
|
||||||
|
friendInLobby = true;
|
||||||
|
|
||||||
|
if (ImGui::Button(player.name, vecButtonWidth))
|
||||||
|
{
|
||||||
|
g.selected_player = player;
|
||||||
|
g.window.player = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!friendInLobby)
|
||||||
|
{
|
||||||
|
ImGui::TextColored({ 180,180,180,255 }, "No friends in\ncurrent lobby.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Indent();
|
||||||
|
ImGui::TreePop();
|
||||||
|
ImGui::Separator();
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(title, "Players (%d)###player_lists", 0);
|
||||||
|
if (ImGui::TreeNode(title))
|
||||||
|
{
|
||||||
|
ImGui::Unindent();
|
||||||
|
|
||||||
|
for (auto& player : g.players)
|
||||||
|
{
|
||||||
|
if (!player.is_friend && player.is_online)
|
||||||
|
{
|
||||||
|
if (ImGui::Button(player.name, vecButtonWidth))
|
||||||
|
{
|
||||||
|
g.selected_player = player;
|
||||||
|
g.window.player = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Indent();
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user