├── README.md └── index.js /README.md: -------------------------------------------------------------------------------- 1 | # rGUI - RAGE:MP 2 | 3 | A multifunctional GUI Library made for the GTA Multiplayer Modification RAGE:MP which is easy to use and understand. 4 | 5 | Currently not maintained. 6 | 7 | 8 | 9 | ## Table of Contents 10 | 11 | - [Functions](#functions) 12 | - [StyleVars](#stylevars) 13 | 14 | ## Functions 15 | 16 | Current functions: 17 | 18 | ```js 19 | 20 | // rGUI Functions 21 | let rGUI = new rGUIClass(); // rGUI's class has to be initalized now. 22 | rGUI.BeginWindow(title, bool, position, size, menuindex); // menuindex locks checkboxes etc to the window with the same menuindex, check the example 23 | rGUI.GetKey(key, type); // different types: JustPressed, JustReleased, IsPressed 24 | rGUI.BlurBackground(bool); 25 | rGUI.ShowCursor(bool); 26 | rGUI.Button(title, position, size, menuindex); 27 | rGUI.Checkbox(title, bool, position, menuindex); // object is your config for the checkbox, please check the example 28 | rGUI.Slider(title, object, position, size, menuindex); // object is your config for the slider, please check the example 29 | rGUI.EndWindow(menuindex); // always end your window 30 | rGUI.DrawRect(position, size, color, menuindex, outmenu); // outmenu is a bool which changes if the rect should be draw'd inside or outside of the menu 31 | 32 | // rGUI.RAGE Functions 33 | rGUI.RAGE.getAllOf(); // similar to mp.events.getAllOf 34 | rGUI.RAGE.AddDataHandler(); // similar to mp.events.addDataHandler 35 | rGUI.RAGE.Invoke(); // similar to mp.game.invoke 36 | rGUI.RAGE.CallRemote(); // similar to mp.events.callRemote 37 | rGUI.RAGE.CallRemoteU(); // similar to mp.events.callRemoteUnreliable 38 | rGUI.RAGE.CallLocal(); // similar to mp.events.callLocal 39 | rGUI.RAGE.Call(); // similar to mp.events.call 40 | rGUI.RAGE.AddEvent(); // similar to mp.events.add 41 | ``` 42 | 43 | ## StyleVars 44 | 45 | Current StyleVars: 46 | 47 | ```js 48 | rGUI.Styles.DrawTitlebar // true or false 49 | rGUI.Styles.TitleFont // get font number here: (https://wiki.rage.mp/index.php?title=Graphics::drawText) 50 | rGUI.Styles.TitleOutline // true or false 51 | rGUI.Styles.CenterTitleText // true or false 52 | rGUI.Styles.MainFont // get font number here: (https://wiki.rage.mp/index.php?title=Graphics::drawText) 53 | rGUI.Styles.MainFontOutline // true or false 54 | rGUI.Styles.EnableResize // true or false 55 | rGUI.Styles.WindowBg // {r: 42, g: 74, b: 123, a: 255} 56 | rGUI.Styles.TitleBg // {r: 42, g: 74, b: 123, a: 255} 57 | rGUI.Styles.Seperator // {r: 42, g: 74, b: 123, a: 255} 58 | rGUI.Styles.CheckboxNormal // {r: 42, g: 74, b: 123, a: 255} 59 | rGUI.Styles.CheckboxHovered // {r: 42, g: 74, b: 123, a: 255} 60 | rGUI.Styles.CheckboxTick // {r: 42, g: 74, b: 123, a: 255} 61 | rGUI.Styles.ButtonNormal // {r: 42, g: 74, b: 123, a: 255} 62 | rGUI.Styles.ButtonHovered // {r: 42, g: 74, b: 123, a: 255} 63 | rGUI.Styles.ButtonPressed // {r: 42, g: 74, b: 123, a: 255} 64 | rGUI.Styles.SliderGrab // {r: 42, g: 74, b: 123, a: 255} 65 | rGUI.Styles.SliderNormal // {r: 42, g: 74, b: 123, a: 255} 66 | rGUI.Styles.SliderHovered // {r: 42, g: 74, b: 123, a: 255} 67 | rGUI.Styles.SliderPressed // {r: 42, g: 74, b: 123, a: 255} 68 | ``` 69 | 70 | 71 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | ////////////////////// rGUI Internals ////////////////////// 2 | 3 | class rGUIClass { 4 | pos = []; 5 | currentMenuState = []; 6 | OldClickPos; 7 | guipressed = []; 8 | sliderpressedd = []; 9 | othersliderpressed = false; 10 | resizepressed = []; 11 | Init = []; // dev var 12 | winsize = []; 13 | 14 | RAGE = { 15 | getAllOf: (e) => { 16 | return mp.events.binded.hasOwnProperty(e) ? mp.events.binded[e].slice() : [] 17 | }, 18 | AddDataHandler: (e, t) => { 19 | mp._events.addDataHandler(e, t); 20 | }, 21 | Invoke: mp.game.invoke, 22 | CallRemote: mp._events.callRemote, 23 | CallRemoteU: mp._events.callRemoteUnreliable, 24 | CallLocal: mp._events.callLocal, 25 | Call: mp._events.call, 26 | AddEvent: mp._events.add, 27 | } 28 | 29 | Styles = { 30 | DrawTitlebar: true, 31 | TitleFont: 4, // font type for title (gta fonts) 32 | TitleOutline: false, // title text outline 33 | CenterTitleText: false, 34 | MainFont: 4, 35 | MainFontOutline: false, 36 | EnableResize: true, 37 | WindowBg: { // background color of the window 38 | r: 14, 39 | g: 14, 40 | b: 14, 41 | a: 255 42 | }, 43 | TitleBg: { // background color of the titlebar 44 | r: 229, 45 | g: 0, 46 | b: 25, 47 | a: 255 48 | }, 49 | Seperator: { 50 | r: 52, 51 | g: 52, 52 | b: 52, 53 | a: 255 54 | }, 55 | CheckboxNormal: { // background color of the checkbox when not checked and not hovered 56 | r: 35, 57 | g: 35, 58 | b: 35, 59 | a: 255 60 | }, 61 | CheckboxHovered: { // background color of the checkbox hovered 62 | r: 41, 63 | g: 41, 64 | b: 41, 65 | a: 255 66 | }, 67 | CheckboxTick: { 68 | r: 255, 69 | g: 255, 70 | b: 255, 71 | a: 220 72 | }, 73 | ButtonNormal: { 74 | r: 35, 75 | g: 35, 76 | b: 35, 77 | a: 255 78 | }, 79 | ButtonHovered: { 80 | r: 41, 81 | g: 41, 82 | b: 41, 83 | a: 255 84 | }, 85 | ButtonPressed:{ 86 | r: 35, 87 | g: 35, 88 | b: 35, 89 | a: 255 90 | }, 91 | SliderGrab: { 92 | r: 85, 93 | g: 85, 94 | b: 85, 95 | a: 255 96 | }, 97 | SliderNormal: { 98 | r: 35, 99 | g: 35, 100 | b: 35, 101 | a: 255 102 | }, 103 | SliderHovered: { 104 | r: 41, 105 | g: 41, 106 | b: 41, 107 | a: 255 108 | }, 109 | SliderPressed:{ 110 | r: 35, 111 | g: 35, 112 | b: 35, 113 | a: 255 114 | } 115 | 116 | } 117 | 118 | rVars = { 119 | WindowX: 0, 120 | WindowY: 0, 121 | } 122 | 123 | rText = { 124 | 125 | rVars: this.rVars, 126 | 127 | AddTextComponentSubstringPlayerName:function(text) { 128 | return mp.game.invoke("0x6C188BE134E074AA", text) 129 | }, 130 | BeginTextCommandGetWidth:function(text) { 131 | return mp.game.invoke("0x54CE8AC98E120CAB", text) 132 | }, 133 | SetTextFont:function(fontType) { 134 | return mp.game.invoke("0x66E0276CC5F6B9DA", fontType) 135 | }, 136 | SetTextScale:function(scale, size) { 137 | return mp.game.invoke("0x07C837F9A01C34C9", scale, size) 138 | }, 139 | EndTextCommandGetWidth: mp.game.ui.getTextScreenWidth, 140 | 141 | GetTextWidth:function(text, font, scale) { 142 | this.BeginTextCommandGetWidth("STRING"); 143 | this.AddTextComponentSubstringPlayerName(text); 144 | this.SetTextFont(font); 145 | this.SetTextScale(scale[0] * 1.25, scale[1]); 146 | return this.EndTextCommandGetWidth(true) * this.rVars.WindowX; 147 | } 148 | 149 | } 150 | 151 | rInternal = { 152 | 153 | rVars: this.rVars, 154 | rText: this.rText, 155 | 156 | DrawRect: function (x, y, w, h, r, g, b, a) { 157 | 158 | mp.game.graphics.drawRect((x + w / 2) / this.rVars.WindowX, (y + h / 2) / this.rVars.WindowY, w / this.rVars.WindowX, h / this.rVars.WindowY, r, g, b, a); 159 | }, 160 | DrawText: function (message, x, y, w, h, font, outline, r, g, b, a) { 161 | 162 | mp.game.ui.setTextEntry("STRING"); 163 | mp.game.ui.addTextComponentSubstringPlayerName(message.toString()); 164 | mp.game.ui.setTextFont(font); 165 | mp.game.ui.setTextScale(w, h); 166 | mp.game.ui.setTextColour(r, g, b, a); 167 | if (outline) { 168 | mp.game.graphics.drawText(message, [(x + (this.rText.GetTextWidth(message, font, [w, h]) / 2)) / this.rVars.WindowX, y / this.rVars.WindowY], { 169 | font: font, 170 | color: [r, g, b, a], 171 | scale: [w, h], 172 | outline: outline, 173 | centre: false 174 | }); 175 | return; 176 | } 177 | mp.game.ui.drawText((x + (this.rText.GetTextWidth(message, font, [w, h]) / 2)) / this.rVars.WindowX, y / this.rVars.WindowY); 178 | }, 179 | check_xy_in_xy: function (x, y, posX, posY, w, h) { 180 | return (posX + w > x && x > posX && posY + h > y && y > posY) 181 | }, 182 | StringID: function (keyString){ 183 | let hash = 0; 184 | for (let charIndex = 0; charIndex < keyString.length; ++charIndex) 185 | { 186 | hash += keyString.charCodeAt(charIndex); 187 | hash += hash << 10; 188 | hash ^= hash >> 6; 189 | } 190 | hash += hash << 3; 191 | hash ^= hash >> 11; 192 | return (((hash + (hash << 15)) & 4294967295) >>> 0) 193 | }, 194 | 195 | }; 196 | 197 | BeginWindow = (title, bool, poss, size, index) => { 198 | 199 | 200 | if (!this.Init[index]) { 201 | this.pos[index] = poss; 202 | this.Init[index] = true; 203 | } 204 | 205 | this.winsize[index] = size; 206 | size = this.winsize[index]; 207 | 208 | // update screen info 209 | this.rVars.WindowX = mp.game.graphics.getScreenActiveResolution(100, 100).x 210 | this.rVars.WindowY = mp.game.graphics.getScreenActiveResolution(100, 100).y 211 | 212 | this.currentMenuState[index] = bool; 213 | 214 | // visible or not 215 | if (!bool) return; 216 | 217 | // draw main rectangle 218 | this.rInternal.DrawRect(this.pos[index].x, this.pos[index].y, size.x, size.y, this.Styles.WindowBg.r, this.Styles.WindowBg.g, this.Styles.WindowBg.b, this.Styles.WindowBg.a); 219 | 220 | if(this.Styles.DrawTitlebar) 221 | { 222 | // draw title rectangle 223 | this.rInternal.DrawRect(this.pos[index].x, this.pos[index].y - 25, size.x, 25, this.Styles.TitleBg.r, this.Styles.TitleBg.g, this.Styles.TitleBg.b, this.Styles.TitleBg.a); 224 | 225 | // draw title text 226 | if(this.Styles.CenterTitleText) 227 | this.rInternal.DrawText(title, (this.pos[index].x - this.rText.GetTextWidth(title, this.Styles.TitleFont, [0.28, 0.28]) / 2) + (size.x / 2) , this.pos[index].y - 24, 0.28, 0.28, this.Styles.TitleFont, this.Styles.TitleOutline, 255, 255, 255, 220); 228 | else 229 | this.rInternal.DrawText(title, this.pos[index].x + 5 , this.pos[index].y - 24, 0.28, 0.28, this.Styles.TitleFont, this.Styles.TitleOutline, 255, 255, 255, 220); 230 | } 231 | 232 | } 233 | 234 | EndWindow = (index) => { 235 | 236 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x, this.pos[index].y - 25, this.winsize[index].x, 25) || this.guipressed[index]) 237 | { 238 | if (mp.game.controls.isDisabledControlJustPressed(0, 24)) this.OldClickPos = mp.gui.cursor.position; 239 | 240 | if(mp.game.controls.isDisabledControlPressed(0, 24)) 241 | { 242 | let newpos = mp.gui.cursor.position; 243 | this.guipressed[index] = true; 244 | this.pos[index].x += newpos[0] - this.OldClickPos[0]; 245 | this.pos[index].y += newpos[1] - this.OldClickPos[1]; 246 | this.OldClickPos = newpos; 247 | 248 | } 249 | 250 | } 251 | 252 | if (mp.game.controls.isDisabledControlJustReleased(0, 24)) 253 | { 254 | this.guipressed[index] = false; 255 | this.resizepressed[index] = false; 256 | 257 | } 258 | 259 | // resize shit 260 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x + this.winsize[index].x - (25 / 2), this.pos[index].y + this.winsize[index].y - (25 / 2), 20, 20) || this.resizepressed[index]) 261 | { 262 | 263 | if(!this.Styles.EnableResize) return; 264 | 265 | 266 | if (mp.game.controls.isDisabledControlJustPressed(0, 24)) this.OldClickPos = mp.gui.cursor.position; 267 | 268 | mp.gui.cursor.show(false, false); 269 | 270 | var x = mp.gui.cursor.position[0]; 271 | var y = mp.gui.cursor.position[1]; 272 | var w = 25; 273 | var h = 25; 274 | 275 | if (!mp.game.graphics.hasStreamedTextureDictLoaded("mp_freemode_mc")) { 276 | mp.game.graphics.requestStreamedTextureDict("mp_freemode_mc", true); 277 | } 278 | 279 | if (mp.game.graphics.hasStreamedTextureDictLoaded("mp_freemode_mc")) { 280 | mp.game.graphics.drawSprite("mp_freemode_mc", "mouse", (x + 5) / this.rVars.WindowX, (y + 5) / this.rVars.WindowY, w / this.rVars.WindowX, h / this.rVars.WindowY, 0, 255, 255, 255, 255); 281 | } 282 | 283 | if(mp.game.controls.isDisabledControlPressed(0, 24)) 284 | { 285 | 286 | 287 | let newposs = mp.gui.cursor.position; 288 | this.resizepressed[index] = true; 289 | this.winsize[index].x += newposs[0] - this.OldClickPos[0]; 290 | this.winsize[index].y += newposs[1] - this.OldClickPos[1]; 291 | this.OldClickPos = newposs; 292 | 293 | if(this.winsize[index].x <= 250) 294 | { 295 | this.winsize[index].x = 250; 296 | } 297 | if(this.winsize[index].y <= 250) 298 | { 299 | this.winsize[index].y = 250; 300 | } 301 | 302 | } 303 | 304 | } 305 | } 306 | 307 | DrawRect = (posSet, size, color, index, outmenu) => { 308 | 309 | if(!outmenu) 310 | if(!this.currentMenuState[index]) return; 311 | 312 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, color.r, color.g, color.b, color.a); 313 | } 314 | 315 | Button = (title, posSet, size, index) => { 316 | 317 | if(!this.currentMenuState[index]) return; 318 | 319 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y)) 320 | { 321 | if(mp.game.controls.isDisabledControlPressed(0, 24)) 322 | { 323 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, this.Styles.ButtonPressed.r, this.Styles.ButtonPressed.g, this.Styles.ButtonPressed.b, this.Styles.ButtonPressed.a); 324 | } 325 | else 326 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, this.Styles.ButtonHovered.r, this.Styles.ButtonHovered.g, this.Styles.ButtonHovered.b, this.Styles.ButtonHovered.a); 327 | } 328 | else 329 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, this.Styles.ButtonNormal.r, this.Styles.ButtonNormal.g, this.Styles.ButtonNormal.b, this.Styles.ButtonNormal.a); 330 | 331 | 332 | this.rInternal.DrawText(title, this.pos[index].x + posSet.x + (size.x / 2) - (this.rText.GetTextWidth(title, this.Styles.MainFont, [0.28, 0.28]) / 2), this.pos[index].y + posSet.y + (size.y / 2) - 11, 0.28, 0.28, this.Styles.MainFont, this.Styles.MainFontOutline, this.Styles.CheckboxTick.r, this.Styles.CheckboxTick.g, this.Styles.CheckboxTick.b, this.Styles.CheckboxTick.a); 333 | 334 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y)) 335 | { 336 | 337 | if(mp.game.controls.isDisabledControlJustPressed(0, 24)) 338 | { 339 | return true; 340 | } 341 | } 342 | 343 | } 344 | 345 | Slider = (title, variable, posSet, size, index) => { 346 | 347 | if(!this.currentMenuState[index]) return; 348 | 349 | 350 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y)) 351 | { 352 | if(mp.game.controls.isDisabledControlPressed(0, 24)) 353 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, this.Styles.SliderPressed.r, this.Styles.SliderPressed.g, this.Styles.SliderPressed.b, this.Styles.SliderPressed.a); 354 | else 355 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, this.Styles.SliderHovered.r, this.Styles.SliderHovered.g, this.Styles.SliderHovered.b, this.Styles.SliderHovered.a); 356 | } 357 | else 358 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y, this.Styles.SliderNormal.r, this.Styles.SliderNormal.g, this.Styles.SliderNormal.b, this.Styles.SliderNormal.a); 359 | 360 | 361 | this.rInternal.DrawText(variable.value.toString(), this.pos[index].x + posSet.x + (size.x / 2) - (this.rText.GetTextWidth(variable.value.toString(), this.Styles.MainFont, [0.28, 0.28]) / 2), this.pos[index].y + posSet.y + (size.y / 2) - 11, 0.28, 0.28, this.Styles.MainFont, this.Styles.MainFontOutline, 255, 255, 255, 220); 362 | 363 | var length = (variable.value - variable.min) / (variable.max - variable.min) * (size.x - 11); 364 | 365 | this.rInternal.DrawRect(this.pos[index].x + posSet.x + length + 2, this.pos[index].y + posSet.y + 2, 7, size.y - 4, this.Styles.SliderGrab.r, this.Styles.SliderGrab.g, this.Styles.SliderGrab.b, this.Styles.SliderGrab.a); 366 | 367 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, size.x, size.y) || this.sliderpressedd[this.rInternal.StringID(title)]) 368 | { 369 | 370 | if(mp.game.controls.isDisabledControlPressed(0, 24)) 371 | { 372 | 373 | this.sliderpressedd[this.rInternal.StringID(title)] = true; 374 | 375 | var value = (mp.gui.cursor.position[0] - this.pos[index].x - posSet.x) / size.x * (variable.max - variable.min) + variable.min; 376 | 377 | if(variable.value < variable.min) variable.value = variable.min; 378 | else if(variable.value > variable.max) variable.value = variable.max; 379 | else variable.value = Math.round(value); 380 | if(variable.value > variable.max) variable.value = variable.max; 381 | if(variable.value < variable.min) variable.value = variable.min; 382 | } 383 | 384 | } 385 | 386 | if (mp.game.controls.isDisabledControlJustReleased(0, 24)) 387 | { 388 | this.sliderpressedd[this.rInternal.StringID(title)] = false; 389 | 390 | } 391 | 392 | this.rInternal.DrawText(title, this.pos[index].x + posSet.x + size.x + 3, this.pos[index].y + posSet.y + (size.y / 2) - 11, 0.28, 0.28, this.Styles.MainFont, this.Styles.MainFontOutline, this.Styles.CheckboxTick.r, this.Styles.CheckboxTick.g, this.Styles.CheckboxTick.b, this.Styles.CheckboxTick.a); 393 | 394 | } 395 | 396 | Checkbox = (title, bool, posSet, index) => { 397 | 398 | if (!this.currentMenuState[index]) return; 399 | 400 | if(this.rInternal.check_xy_in_xy(mp.gui.cursor.position[0], mp.gui.cursor.position[1], this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, 28 + this.rText.GetTextWidth(title, this.Styles.MainFont, [0.28, 0.28]), 25)) 401 | { 402 | 403 | if (mp.game.controls.isDisabledControlJustPressed(0, 24)) 404 | { 405 | bool.value = !bool.value; 406 | } 407 | 408 | 409 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, 25, 25, this.Styles.CheckboxHovered.r, this.Styles.CheckboxHovered.g, this.Styles.CheckboxHovered.b, this.Styles.CheckboxHovered.a); 410 | } 411 | else 412 | { 413 | this.rInternal.DrawRect(this.pos[index].x + posSet.x, this.pos[index].y + posSet.y, 25, 25, this.Styles.CheckboxNormal.r, this.Styles.CheckboxNormal.g, this.Styles.CheckboxNormal.b, this.Styles.CheckboxNormal.a); 414 | } 415 | 416 | 417 | this.rInternal.DrawText(title, this.pos[index].x + posSet.x + 28, this.pos[index].y + posSet.y + 1, 0.28, 0.28, this.Styles.MainFont, this.Styles.MainFontOutline, this.Styles.CheckboxTick.r, this.Styles.CheckboxTick.g, this.Styles.CheckboxTick.b, this.Styles.CheckboxTick.a); 418 | 419 | if(bool.value) 420 | { 421 | var x = this.pos[index].x + posSet.x - 7; 422 | var y = this.pos[index].y + posSet.y - 7; 423 | var w = 40; 424 | var h = 40; 425 | 426 | if (!mp.game.graphics.hasStreamedTextureDictLoaded("commonmenu")) { 427 | mp.game.graphics.requestStreamedTextureDict("commonmenu", true); 428 | } 429 | 430 | if (mp.game.graphics.hasStreamedTextureDictLoaded("commonmenu")) { 431 | mp.game.graphics.drawSprite("commonmenu", "shop_tick_icon", (x + w / 2) / this.rVars.WindowX, (y + h / 2) / this.rVars.WindowY, w / this.rVars.WindowX, h / this.rVars.WindowY, 0, 255, 255, 255, 240); 432 | } 433 | 434 | } 435 | 436 | } 437 | 438 | ShowCursor = (bool) => { 439 | if (bool) { 440 | mp.game.controls.disableControlAction(0, 1, true); 441 | mp.game.controls.disableControlAction(0, 2, true); 442 | mp.game.controls.disableControlAction(0, 24, true); 443 | mp.game.controls.disableControlAction(0, 69, true); 444 | mp.game.controls.disableControlAction(0, 142, true); 445 | mp.game.controls.disableControlAction(0, 257, true); 446 | mp.game.controls.disableControlAction(0, 25, true); 447 | mp.game.controls.disableControlAction(0, 17, true); 448 | mp.game.controls.disableControlAction(0, 16, true); 449 | mp.game.controls.disableControlAction(0, 200, true); 450 | mp.game.controls.disableControlAction(0, 85, true); 451 | mp.game.controls.disableControlAction(0, 99, true); 452 | mp.game.controls.disableControlAction(0, 92, true); 453 | mp.gui.cursor.show(false, true); 454 | 455 | } 456 | else 457 | { 458 | mp.gui.cursor.show(false, false); 459 | } 460 | 461 | } 462 | 463 | BlurBackground = (bool) => { 464 | if(bool) 465 | mp.game.graphics.transitionToBlurred(150); 466 | else 467 | mp.game.graphics.transitionFromBlurred(150); 468 | } 469 | 470 | GetKey = (key, type) => { 471 | 472 | switch (type) { 473 | case "JustPressed": 474 | return mp.game.controls.isDisabledControlJustPressed(0, key); 475 | 476 | case "JustReleased": 477 | return mp.game.controls.isDisabledControlJustReleased(0, key); 478 | 479 | case "IsPressed": 480 | return mp.game.controls.isDisabledControlPressed(0, key); 481 | } 482 | 483 | } 484 | 485 | } 486 | ////////////////////// rGUI Internals ////////////////////// 487 | 488 | 489 | ////////////////////// rGUI Example ////////////////////// 490 | 491 | let rGUI = new rGUIClass(); 492 | 493 | var cfg = { 494 | menushow: false, 495 | boxexample: {value: true}, 496 | boxexample2: {value: true}, 497 | sliderint: {value: 100, min: 0, max: 100}, 498 | sliderint2: {value: 100, min: 10, max: 360}, 499 | menupos: {x: 250, y: 250}, 500 | menusize: {x: 640, y: 400}, 501 | 502 | tabindex: 0, 503 | } 504 | 505 | rGUI.Styles.CenterTitleText = true; 506 | rGUI.Styles.TitleBg = {r: 42, g: 74, b: 123, a: 255}; 507 | rGUI.Styles.EnableResize = false; 508 | 509 | 510 | rGUI.RAGE.AddEvent("render", () => { 511 | 512 | if(rGUI.GetKey(121, "JustReleased")) 513 | { 514 | cfg.menushow = !cfg.menushow; 515 | rGUI.BlurBackground(cfg.menushow); 516 | } 517 | 518 | 519 | rGUI.ShowCursor(cfg.menushow); 520 | 521 | rGUI.BeginWindow("rGUI Example Window", cfg.menushow, cfg.menupos, cfg.menusize, 0); // begin your window 522 | { 523 | if(rGUI.Button("First Tab", {x: 10, y: 10}, {x: 200, y: 30}, 0)) 524 | { 525 | cfg.tabindex = 0; 526 | } 527 | 528 | if(rGUI.Button("Second Tab", {x: 220, y: 10}, {x: 200, y: 30}, 0)) 529 | { 530 | cfg.tabindex = 1; 531 | } 532 | 533 | if(rGUI.Button("Third Tab", {x: 430, y: 10}, {x: 200, y: 30}, 0)) 534 | { 535 | cfg.tabindex = 2; 536 | } 537 | 538 | rGUI.DrawRect({x: 10, y: 48}, {x: cfg.menusize.x - 20, y: 2}, rGUI.Styles.Seperator, 0); 539 | 540 | if(cfg.tabindex == 0) 541 | { 542 | rGUI.Checkbox("Example Checkbox", cfg.boxexample, {x: 10, y: 60}, 0); 543 | 544 | rGUI.Checkbox("Example Checkbox 2", cfg.boxexample2, {x: 10, y: 95}, 0); 545 | 546 | rGUI.Slider("Example Slider", cfg.sliderint, {x: 10, y: 130}, {x: 150, y: 25}, 0); 547 | 548 | rGUI.Slider("Example Slider 2", cfg.sliderint2, {x: 10, y: 165}, {x: 150, y: 25}, 0); 549 | 550 | } 551 | } 552 | rGUI.EndWindow(0); 553 | }); 554 | 555 | ////////////////////// rGUI Example ////////////////////// --------------------------------------------------------------------------------