-
Notifications
You must be signed in to change notification settings - Fork 24
/
spawnscreen.cpp
62 lines (52 loc) · 1.7 KB
/
spawnscreen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "main.h"
#include "gui/gui.h"
#include "spawnscreen.h"
#include "chatwindow.h"
#include "settings.h"
#include "game/game.h"
#include "net/netgame.h"
extern CGUI *pGUI;
extern CNetGame *pNetGame;
extern CChatWindow *pChatWindow;
extern CSettings *pSettings;
CSpawnScreen::CSpawnScreen()
{
Log("Initializing Spawn Screen..");
m_fPosX = pGUI->ScaleX( pSettings->Get().fSpawnScreenPosX );
m_fPosY = pGUI->ScaleY( pSettings->Get().fSpawnScreenPosY );
m_fSizeX = pGUI->ScaleX( pSettings->Get().fSpawnScreenSizeX );
m_fSizeY = pGUI->ScaleY( pSettings->Get().fSpawnScreenSizeY );
m_fButWidth = m_fSizeX / 3;
m_fButHeight = m_fSizeY * 0.9;
Log("Spawn Screen pos: %f, %f, size: %f, %f", m_fPosX, m_fPosY, m_fSizeX, m_fSizeY);
m_bEnabled = false;
}
void CSpawnScreen::Render()
{
if(!m_bEnabled) return;
ImGuiIO &io = ImGui::GetIO();
CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool();
CLocalPlayer *pLocalPlayer = 0;
if(pPlayerPool) pLocalPlayer = pPlayerPool->GetLocalPlayer();
ImGui::Begin("SpawnScreen", nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings);
if (ImGui::Button("<<", ImVec2(m_fButWidth, m_fButHeight)))
{
pLocalPlayer->SendPrevClass();
}
ImGui::SameLine(0, 0);
if (ImGui::Button("Spawn", ImVec2(m_fButWidth, m_fButHeight)))
{
pLocalPlayer->SendSpawn();
}
ImGui::SameLine(0, 0);
if (ImGui::Button(">>", ImVec2(m_fButWidth, m_fButHeight)))
{
pLocalPlayer->SendNextClass();
}
ImGui::SetWindowSize(ImVec2(-1, -1));
ImVec2 size = ImGui::GetWindowSize();
ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y * 0.95) - size.y) ) );
ImGui::End();
}