-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathsets.cpp
More file actions
165 lines (123 loc) · 4.12 KB
/
sets.cpp
File metadata and controls
165 lines (123 loc) · 4.12 KB
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
157
158
159
160
161
162
163
164
165
#include "main.h"
#include "game/game.h"
#include "net/netgame.h"
#include "gui/gui.h"
#include "vendor/imgui/imgui_internal.h"
#include "keyboard.h"
#include "sets.h"
#include "servers.h"
#include "settings.h"
#include "modsa.h"
#include <stdlib.h>
#include <string.h>
extern CGUI *pGUI;
extern CGame *pGame;
extern CNetGame *pNetGame;
extern CKeyBoard *pKeyBoard;
extern CServersWindow *pServersWindow;
extern CSettings *pSettings;
extern CModSAWindow *pModSAWindow;
char szUsernameInputBuffer[100];
char utf8UsernameInputBuffer[100*3];
char szPasswordInputBuffer[100];
char utf8PasswordInputBuffer[100*3];
CSetsWindow::CSetsWindow()
{
m_bIsActive = false;
}
CSetsWindow::~CSetsWindow()
{
}
void CSetsWindow::Show(bool bShow)
{
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(false);
m_bIsActive = bShow;
if(bShow != false)
{
sprintf(utf8UsernameInputBuffer, "%s", pSettings->Get().szNickName);
sprintf(szUsernameInputBuffer, "%s", pSettings->Get().szNickName);
}
}
void CSetsWindow::Clear()
{
m_bIsActive = false;
memset(szUsernameInputBuffer, 0, 100);
memset(utf8UsernameInputBuffer, 0, 100*3);
memset(szPasswordInputBuffer, 0, 100);
memset(utf8PasswordInputBuffer, 0, 100*3);
}
void SetsWindowInputHandler(const char* str)
{
if(!str || *str == '\0') return;
strcpy(szUsernameInputBuffer, str);
cp1251_to_utf8(utf8UsernameInputBuffer, str);
}
void SetsWindowInputHandlerTwo(const char* str)
{
if(!str || *str == '\0') return;
strcpy(szPasswordInputBuffer, str);
cp1251_to_utf8(utf8PasswordInputBuffer, str);
}
void CSetsWindow::Render()
{
if(!m_bIsActive) return;
ImGuiIO &io = ImGui::GetIO();
ImGui::StyleColorsClassic();
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8,8));
ImGui::Begin("> Server Properties", nullptr,
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize);
ImGui::Text("Введите свой игровой никнейм");
ImGui::ItemSize( ImVec2(0, pGUI->GetFontSize()/2 + 2.5) );
if( ImGui::Button(utf8UsernameInputBuffer, ImVec2((555 - 125), 50) ))
{
pKeyBoard->Open(&SetsWindowInputHandler);
}
ImGui::SameLine(0, pGUI->GetFontSize() - 10.5);
if(ImGui::Button("Импорт", ImVec2(125, 50)))
{
sprintf(utf8UsernameInputBuffer, "%s", pSettings->Get().szNickName);
sprintf(szUsernameInputBuffer, "%s", pSettings->Get().szNickName);
}
ImGui::ItemSize( ImVec2(0, pGUI->GetFontSize()/2 + 5) );
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - 278 + ImGui::GetStyle().ItemSpacing.x) / 2);
if(ImGui::Button("Далее", ImVec2(125, 50)))
{
if(strlen(utf8UsernameInputBuffer) >= 3)
{
username = szUsernameInputBuffer;
password = szPasswordInputBuffer;
unsigned short port = 7777;
pModSAWindow->extOS = 0;
char *address = ADDRFOUR;//ADDRLOC;
pNetGame = new CNetGame(address, port, username, password);
Show(false);
pModSAWindow->protect = 1;
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(true);
}else{
sprintf(utf8UsernameInputBuffer, "%s", pSettings->Get().szNickName);
sprintf(szUsernameInputBuffer, "%s", pSettings->Get().szNickName);
username = szUsernameInputBuffer;
password = szPasswordInputBuffer;
unsigned short port = 7777;
pModSAWindow->extOS = 0;
char *address = ADDRFOUR;
pNetGame = new CNetGame(address, port, username, password);
Show(false);
pModSAWindow->protect = 1;
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(true);
}
}
ImGui::SameLine(0, pGUI->GetFontSize());
if(ImGui::Button("Выйти", ImVec2(125, 50)))
{
exit(0);
}
ImGui::SetWindowSize(ImVec2(-1, -1));
ImVec2 size = ImGui::GetWindowSize();
ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y - size.y)/2)) );
ImGui::End();
ImGui::PopStyleVar();
}