-
Notifications
You must be signed in to change notification settings - Fork 26
/
servers.cpp
156 lines (127 loc) · 3.65 KB
/
servers.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "main.h"
#include "game/game.h"
#include "net/netgame.h"
#include "game/common.h"
#include "gui/gui.h"
#include "servers.h"
#include "vendor/imgui/imgui_internal.h"
#include "keyboard.h"
#include "chatwindow.h"
#include "net/vehiclepool.h"
#include <stdlib.h>
#include <string.h>
#include "settings.h"
#include "sets.h"
#include "modsa.h"
#include "dialog.h"
#include "customserver.h"
extern CGUI *pGUI;
extern CGame *pGame;
extern CNetGame *pNetGame;
extern CKeyBoard *pKeyBoard;
extern CChatWindow *pChatWindow;
extern CSettings *pSettings;
extern CSetsWindow *pSetsWindow;
extern CModSAWindow *pModSAWindow;
extern CCustomServerWindow *pCustomServer;
char* AddressOne = ADDRZERO;
char* AddressTwo = ADDRONE;
char* AddressThree = ADDRTWO;
CServersWindow::CServersWindow()
{
m_bIsActive = false;
m_bMenuStep = 0;
}
CServersWindow::~CServersWindow()
{
}
void CServersWindow::Show(bool bShow)
{
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(false);
m_bIsActive = bShow;
}
void CServersWindow::Clear()
{
m_bIsActive = false;
m_bMenuStep = 0;
}
void CServersWindow::ShowAllServers()
{
ImGui::StyleColorsClassic();
ImGui::Text("Direct connection");
if(ImGui::Button("Custom Server", ImVec2(350, 50)))
{
pCustomServer->Show(true);
Show(false);
pModSAWindow->extOS = 0;
}
ImGui::ItemSize( ImVec2(0, pGUI->GetFontSize()/2 + 5) );
ImGui::Text("Official");
if(ImGui::Button("Mordor RP", ImVec2(350, 50)))
{
unsigned short port = 7777;
pModSAWindow->extOS = 0;
pNetGame = new CNetGame(
AddressTwo,
port,
pSetsWindow->username,
pSetsWindow->password);
Show(false);
pModSAWindow->protect = 1;
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(true);
}
//if(ImGui::Button("SanTrope RP", ImVec2(350, 50)))
//{
// unsigned short port = 7777;
// pModSAWindow->extOS = 1;
// pModSAWindow->ToggleRPC(9); // pickups
//
// pNetGame = new CNetGame(
// AddressThree,
// port,
// pSetsWindow->username,
// pSetsWindow->password);
// Show(false);
//
// pModSAWindow->protect = 1;
// if(pGame)
// pGame->FindPlayerPed()->TogglePlayerControllable(true);
//}
ImGui::ItemSize( ImVec2(0, pGUI->GetFontSize()/2 + 5) );
ImGui::Text("Internet");
if(ImGui::Button("Axwell World", ImVec2(350, 50)))
{
unsigned short port = 7778;
pModSAWindow->extOS = 1;
pNetGame = new CNetGame(
AddressOne,
port,
pSetsWindow->username,
pSetsWindow->password);
Show(false);
pModSAWindow->protect = 0;
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(true);
}
}
void CServersWindow::Render()
{
if(!m_bIsActive || m_bMenuStep == 0) return;
ImGuiIO &io = ImGui::GetIO();
ImGui::StyleColorsClassic();
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8));
ImGui::Begin("> Select the server", nullptr,
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
switch(m_bMenuStep){
case 1:
ShowAllServers();
break;
}
ImGui::SetWindowSize(ImVec2(-8, -8));
ImVec2 size = ImGui::GetWindowSize();
ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y - size.y)/2) ) );
ImGui::End();
ImGui::PopStyleVar();
}