Post: Compact Menu Code. (goes in Engine.c)
06-21-2013, 12:43 AM #1
Default Avatar
DeNo
Guest
(adsbygoogle = window.adsbygoogle || []).push({}); Replace this with your current menu in 'engine.c'


    #define start_y 0.25
#define spacing 0.025
float pos_y = start_y;
drawWindow();
s_a = 255;
set_up_draw(4,0.35,0.35,s_r,s_g,s_b,255);
//if(!display) draw_text("STRING",pos_x,start_y-.02,footer);
draw_text("STRING",pos_x,start_y-.02,footer);
uint i = 1;
for(i;i <= item_count;i++){
r = 255;g = 255;b = 255;a = 255;
pos_y = pos_y + spacing;
/**
if(item_select == i){
r = s_r; g = s_g; b = s_b; a = s_a;
//DRAW_RECT(pos_x+0.11, pos_y+0.013, 0.25 ,0.019,s_r,s_g,s_b, 100);
DRAW_RECT(pos_x+0.05, pos_y+0.013, 0.25 ,0.019,s_r,s_g,s_b, 100);
}
**/
if(item_select == i){
r = s_r;
g = s_g;
b = s_b;
}
if(menu[i].type == 1){
if(menu[i].value){
set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a);
//draw_text("STRING",(pos_x + 0.2),pos_y,"On");
draw_text("STRING",(pos_x + 0.26),pos_y,"On");
}
}
if(menu[i].type == 2){
set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a);
draw_text("STRING",(pos_x + 0.19),pos_y,"(");
set_up_draw(3,0.35,0.35,255,255,255,a);
draw_number("NUMBR",(pos_x + 0.205),pos_y,menu[i].value);
set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a);
if(menu[i].value > 99) draw_text("STRING",(pos_x + 0.245),pos_y,")");
else if(menu[i].value > 9) draw_text("STRING",(pos_x + 0.23),pos_y,")");
else draw_text("STRING",(pos_x + 0.215),pos_y,")");
}
if(menu[i].type == 3){
set_up_draw(3,0.35,0.35,r,g,b,a);
//draw_text("STRING",pos_x,pos_y,GET_STRING_FROM_TEXT_FILE(GET_DISPLAY_NAME_FROM_VEHICLE_MODEL(menu[i].value)));
draw_text("STRING",pos_x,pos_y,GET_STRING_FROM_TEXT_FILE(GET_DISPLAY_NAME_FROM_VEHICLE_MODEL(menu[i].value)));
}
if(menu[i].type == 4){
if(item_select == i){
r = s_r;
g = s_g;
b = s_b;
}
else GET_PLAYER_RGB_COLOUR(menu[i].value,&r,&g,&b);
set_up_draw(3,0.35,0.35,r,g,b,a);
draw_text("STRING", pos_x, pos_y, menu[i].item_name);
}
else{
set_up_draw(3,0.35,0.35,r,g,b,a);
//draw_text("STRING",pos_x,pos_y,menu[i].item_name);
draw_text("STRING",pos_x,pos_y,menu[i].item_name);
}
}

///Buttons
if(IS_BUTTON_JUST_PRESSED(0,DPAD_UP)){
if(item_select == 1){
item_select = item_count;
}
else item_select--;
}
else if(IS_BUTTON_JUST_PRESSED(0,DPAD_DOWN)){
if(item_select == item_count){
item_select = 1;
}
else item_select++;
}
else if(IS_BUTTON_JUST_PRESSED(0,DPAD_RIGHT) && menu[item_select].type == 2){
if(menu[item_select].value == menu[item_select].maxval)
menu[item_select].value = 1;
else
menu[item_select].value += 1;
}
else if(IS_BUTTON_JUST_PRESSED(0,DPAD_LEFT) && menu[item_select].type == 2){
if(menu[item_select].value == 1)
menu[item_select].value = menu[item_select].maxval;
else
menu[item_select].value -= 1;
}
else if(IS_BUTTON_JUST_PRESSED(0,BUTTON_A)){
if(menu[item_select].action){
menu_functions();
}
else{
uint i = 1;
for(i;i <= item_count;i++){
menu[i].action = false;
menu[i].type = 0;
}
last_selected[menu_level] = item_select;
menu_level++;
menu_setup();
item_select = 1;
}
}
else if(IS_BUTTON_JUST_PRESSED(0,BUTTON_B)){
if(menu_level > 0){
uint i = 1;
for(i;i <= item_count;i++){
menu[i].action = false;
menu[i].type = 0;
}
menu_level--;
item_select = last_selected[menu_level];
menu_setup();
}
else menu_shutdown();
}
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo