1+ #include " extdll_menu.h"
2+ #include " imgui.h"
3+ #include " imgui_utils.h"
4+ #include " Utils.h"
5+
6+ #include " qrcode.h"
7+
8+ #include " mathlib.h"
9+ #include " const.h"
10+ #include " cl_entity.h"
11+ #include " ref_params.h"
12+ #include " entity_types.h"
13+
14+ #include < vector>
15+
16+ namespace ui {
17+ static HIMAGE g_playerPIC = 0 ;
18+
19+ static QRCode s_qrcode;
20+ static std::vector<uint8_t > s_qrCodeBytes;
21+
22+ void Background_VidInit ()
23+ {
24+ const char *player_images[] = {
25+ " gfx/vgui/urban" ,
26+ " gfx/vgui/Guerilla" ,
27+ };
28+ g_playerPIC = EngFuncs::PIC_Load (player_images[0 ]);
29+
30+ // The structure to manage the QR code
31+ s_qrCodeBytes.resize (qrcode_getBufferSize (9 ));
32+ qrcode_initText (&s_qrcode, s_qrCodeBytes.data (), 9 , ECC_LOW, " https://qm.qq.com/cgi-bin/qm/qr?k=m-wI8acAT7XurfGiy_2JZy9DBupc1tXe&authKey=ZgiTHa6sHJjpkKqMLE8XQH31pHL1gFGF4mOi3xH5zW6D169YuTGbKJqcRI0B7cVX" );
33+ }
34+
35+ static void CalcFov (ref_menu_params_t &refdef) {
36+ float x = refdef.viewport [2 ] / tan (DEG2RAD (refdef.fov_x ) * 0 .5f );
37+ float half_fov_y = atan (refdef.viewport [3 ] / x);
38+ refdef.fov_y = RAD2DEG (half_fov_y) * 2 ;
39+ }
40+
41+ static void RenderPlayerModel () {
42+ auto ent = EngFuncs::GetPlayerModel ();
43+
44+ int w = ScreenWidth;
45+ int h = ScreenHeight;
46+
47+ static ref_menu_params_t refdef = {};
48+ refdef.fov_x = 40 .0f ;
49+ refdef.fov_y = 40 .0f ;
50+ refdef.viewport [0 ] = 0 ;
51+ refdef.viewport [1 ] = 0 ;
52+ refdef.viewport [2 ] = 128 ;
53+ refdef.viewport [3 ] = 128 ;
54+ CalcFov (refdef);
55+
56+ // adjust entity params
57+ ent->index = 0 ;
58+ ent->curstate .body = 0 ;
59+ ent->curstate .number = 1 ; // IMPORTANT: always set playerindex to 1
60+ ent->curstate .animtime = gpGlobals->time ; // start animation
61+ ent->curstate .sequence = 1 ;
62+ ent->curstate .scale = 1 .0f ;
63+ ent->curstate .frame = 0 .0f ;
64+ ent->curstate .framerate = 1 .0f ;
65+ // ent->curstate.effects |= EF_FULLBRIGHT;
66+ ent->curstate .controller [0 ] = 127 ;
67+ ent->curstate .controller [1 ] = 127 ;
68+ ent->curstate .controller [2 ] = 127 ;
69+ ent->curstate .controller [3 ] = 127 ;
70+ ent->latched .prevcontroller [0 ] = 127 ;
71+ ent->latched .prevcontroller [1 ] = 127 ;
72+ ent->latched .prevcontroller [2 ] = 127 ;
73+ ent->latched .prevcontroller [3 ] = 127 ;
74+ ent->origin [0 ] = ent->curstate .origin [0 ] = 45 .0f / tan (DEG2RAD (refdef.fov_y / 2 .0f ));
75+ ent->origin [2 ] = ent->curstate .origin [2 ] = 2 .0f ;
76+ ent->angles [1 ] = ent->curstate .angles [1 ] = 180 .0f ;
77+
78+ ent->player = 1 ; // yes, draw me as playermodel
79+
80+ ent->curstate .rendermode = kRenderTransTexture ;
81+ ent->curstate .renderamt = 255 ;
82+
83+ // EngFuncs::CvarSetString( "model", "player" );
84+
85+
86+ EngFuncs::ClearScene ();
87+
88+ refdef.time = gpGlobals->time ;
89+ refdef.frametime = gpGlobals->frametime ;
90+
91+ EngFuncs::CL_CreateVisibleEntity (ET_NORMAL, ent);
92+ EngFuncs::RenderScene (&refdef);
93+
94+ EngFuncs::SetModel (ent, " models/player.mdl" );
95+
96+
97+ // draw the player model
98+ }
99+
100+ void Background_OnGUI () {
101+ // EngFuncs::FillRGBA(0, 0, ScreenWidth, ScreenHeight, 255, 255, 255, 255);
102+ int w = ScreenWidth;
103+ int h = ScreenHeight;
104+ auto drawlist = ImGui::GetBackgroundDrawList ();
105+
106+ drawlist->AddRectFilled (ImVec2 (0 * w, 0 * h), ImVec2 (1 * w, 1 * h), ImColor (255 , 100 , 100 , 255 ));
107+ drawlist->PathClear ();
108+ drawlist->PathLineTo (ImVec2 (1 * w, 0.5 * h));
109+ drawlist->PathBezierCurveTo (ImVec2 (0.5 * w, 0.65 * h), ImVec2 (0.35 * w, 0.8 * h), ImVec2 (0.25 * w, 0.9 * h));
110+ drawlist->PathBezierCurveTo (ImVec2 (0.15 * w, 1.00 * h), ImVec2 (0.025 * w, 1.0 * h), ImVec2 (0.0 * w, 0.9 * h));
111+ drawlist->PathLineTo (ImVec2 (0 * w, 0 * h));
112+ drawlist->PathLineTo (ImVec2 (1 * w, 0 * h));
113+ drawlist->PathFillConvex (ImColor (255 , 255 , 255 , 255 ));
114+
115+ drawlist->PathClear ();
116+ drawlist->PathLineTo (ImVec2 (0.2 * w, 0.8 * h));
117+ drawlist->PathBezierCurveTo (ImVec2 (0.15 * w, 0.9 * h), ImVec2 (0.1 * w, 0.92 * h), ImVec2 (0.0 * w, 0.88 * h));
118+ drawlist->PathLineTo (ImVec2 (0 * w, 0.7 * h));
119+ drawlist->PathFillConvex (ImColor (255 , 100 , 100 , 255 ));
120+
121+ drawlist->PathClear ();
122+ drawlist->PathLineTo (ImVec2 (0.2 * w, 0.8 * h));
123+ drawlist->PathBezierCurveTo (ImVec2 (0.125 * w, 0.85 * h), ImVec2 (0.1 * w, 0.86 * h), ImVec2 (0.0 * w, 0.82 * h));
124+ drawlist->PathLineTo (ImVec2 (0 * w, 0.7 * h));
125+ drawlist->PathFillConvex (ImColor (255 , 255 , 255 , 255 ));
126+
127+
128+ drawlist->PathClear ();
129+ drawlist->PathLineTo (ImVec2 (1.0 * w, 0.6 * h));
130+ drawlist->PathBezierCurveTo (ImVec2 (0.87 * w, 0.65 * h), ImVec2 (0.45 * w, 0.97 * h), ImVec2 (0.35 * w, 1 * h));
131+ drawlist->PathLineTo (ImVec2 (1 * w, 1 * h));
132+ drawlist->PathFillConvex (ImColor (255 , 50 , 50 , 200 ));
133+
134+ {
135+ // EngFuncs::PIC_Set( hPic, 255, 255, 255, 255 );
136+ // EngFuncs::PIC_DrawAdditive( w * 0.5, h * 0.3, w * 0.5, uiStatic.buttons_draw_height, &rects[BUTTON_FOCUS] );
137+ if (g_playerPIC)
138+ drawlist->AddImage ((ImTextureID) g_playerPIC, ImVec2 (0.45 * w, 0.2 * h), ImVec2 (1.05 * w, 1 * h));
139+ }
140+
141+
142+ {
143+ int x = 0.85 * w;
144+ int y = 0.05 * h;
145+ float fontsize = w / 1920 * 72 ;
146+ drawlist->AddText (NULL , fontsize, ImVec2 (x, y), ImColor (0 , 0 , 0 , 255 ), " * 搔 马 加 裙 *" );
147+ }
148+
149+ {
150+ int x0 = 0.825 * w;
151+ int y0 = 0.1 * h;
152+ float fontsize = w / 1920 * 10 ;
153+
154+ for (std::uint8_t y = 0 ; y < s_qrcode.size ; y++) {
155+ for (std::uint8_t x = 0 ; x < s_qrcode.size ; x++) {
156+ auto col = ImColor (255 , 255 , 255 , 255 );
157+ if (qrcode_getModule (&s_qrcode, x, y)) {
158+ col = ImColor (0 , 0 , 0 , 255 );
159+ }
160+ // drawlist->AddCircleFilled(ImVec2(x0 + x * fontsize, y0 + y * fontsize), fontsize / 2, col);
161+ drawlist->AddRectFilled ( ImVec2 (x0 + x * fontsize, y0 + y * fontsize), ImVec2 (x0 + x * fontsize + fontsize, y0 + y * fontsize + fontsize), col );
162+ }
163+ }
164+ }
165+
166+ {
167+ int x = 0.05 * w;
168+ int y = 0.05 * h;
169+ float fontsize = w / 1920 * 64 ;
170+ drawlist->AddText (NULL , fontsize, ImVec2 (x, y), ImColor (255 , 100 , 100 , 255 ), " 柑橘" );
171+ ImGuiUtils::AddCitrusLogo (drawlist, ImVec2 (x + fontsize * 2.5 , y + fontsize * 0.5 ), fontsize, 0 );
172+ drawlist->AddText (NULL , fontsize, ImVec2 (x + fontsize * 3.5 , y), ImColor (255 , 50 , 50 , 255 ), " CitruS" );
173+ }
174+
175+ {
176+ int x = 0.65 * w;
177+ int y = 0.85 * h;
178+ float fontsize = w / 1920 * 64 ;
179+ drawlist->AddRectFilled (ImVec2 (x, y), ImVec2 (x + fontsize * 15 , y + fontsize * 2 ),
180+ ImColor (255 , 255 , 0 , 255 ), fontsize / 2 );
181+ drawlist->AddText (NULL , fontsize, ImVec2 (x + fontsize / 2 , y + fontsize / 2 ), ImColor (0 , 0 , 0 , 255 ),
182+ " 唯 一 指 定 Q Q 群 : 7 0 6 7 1 1 4 2 0" );
183+ }
184+
185+ {
186+ const int x0 = 0.15 * w;
187+ const int y0 = 0.25 * h;
188+ const int x1 = 0.17 * w;
189+ const int y1 = 0.28 * h;
190+ static int x = x0;
191+ static int y = y0;
192+
193+ static float x_dir = 0 ;
194+ static float y_dir = 1 ;
195+
196+ if (x <= x0 || x >= x1 || y <= y0 || y >= y1) {
197+ x_dir = EngFuncs::RandomFloat (-1 , 1 );
198+ y_dir = EngFuncs::RandomFloat (-1 , 1 );
199+ }
200+ auto deltatime = ImGui::GetIO ().DeltaTime ;
201+ x += x_dir * deltatime * w / 3 ;
202+ y += y_dir * deltatime * h / 3 ;
203+ x = std::clamp (x, x0, x1);
204+ y = std::clamp (y, y0, y1);
205+
206+ float fontsize = w / 1920 * 64 ;
207+ drawlist->AddText (NULL , fontsize * 1.5 , ImVec2 (x, y + fontsize * 0 ), ImColor (255 , 150 , 0 , 255 ), " 香蕉诱惑套餐" );
208+ drawlist->AddText (NULL , fontsize, ImVec2 (x, y + fontsize * 1.5 ), ImColor (0 , 0 , 0 , 255 ),
209+ " ze_Ricardo_Milos_dp" );
210+ drawlist->AddText (NULL , fontsize * 1.5 , ImVec2 (x, y + fontsize * 3.5 ), ImColor (255 , 150 , 0 , 255 ), " 极限冲B套餐" );
211+ drawlist->AddText (NULL , fontsize, ImVec2 (x, y + fontsize * 5 ), ImColor (0 , 0 , 0 , 255 ), " ze_rushb_p90" );
212+ drawlist->AddText (NULL , fontsize * 1.5 , ImVec2 (x, y + fontsize * 7 ), ImColor (255 , 150 , 0 , 255 ), " 火星人套餐" );
213+ drawlist->AddText (NULL , fontsize, ImVec2 (x, y + fontsize * 8.5 ), ImColor (0 , 0 , 0 , 255 ),
214+ " ze_deadspace_final" );
215+ drawlist->AddText (NULL , fontsize * 1.5 , ImVec2 (x, y + fontsize * 10.5 ), ImColor (255 , 150 , 0 , 255 ), " 高血压套餐" );
216+ drawlist->AddText (NULL , fontsize, ImVec2 (x, y + fontsize * 12 ), ImColor (0 , 0 , 0 , 255 ),
217+ " ze_FFVII_Mako_Reactor_v1_1" );
218+
219+ drawlist->AddText (NULL , fontsize * 2 , ImVec2 (x + fontsize * 10 , y + fontsize * 0.25 ),
220+ ImColor (255 , 0 , 0 , 255 ), " 280.00" );
221+ drawlist->AddText (NULL , fontsize * 2 , ImVec2 (x + fontsize * 10 , y + fontsize * 3.75 ),
222+ ImColor (255 , 0 , 0 , 255 ), " 345.00" );
223+ drawlist->AddText (NULL , fontsize * 2 , ImVec2 (x + fontsize * 10 , y + fontsize * 7.25 ),
224+ ImColor (255 , 0 , 0 , 255 ), " 575.00" );
225+ drawlist->AddText (NULL , fontsize * 2 , ImVec2 (x + fontsize * 10 , y + fontsize * 10.75 ),
226+ ImColor (255 , 0 , 0 , 255 ), " 935.00" );
227+ }
228+ }
229+
230+ }
0 commit comments