Nombre del creador: romon_28.
Breve descripción de su función: Simula una textbox (caja de texto).
Versión GM utilizada: :GMS:
Código del Script "Crear_TextBox( x, y, Texto)":///Crear_TextBox( x, y, Texto)
var Id = instance_create(argument0,argument1,Obj_TextBox);
with(local.Id){RMN_T=argument2;}
return(Id);
Código del Script "Crear_TextBox_ext( x, y, Texto, Digitos Maximos, Color Normal, Color Seleccionado, Fuente,Sprite)":///Crear_TextBox_ext( x, y, Texto, Digitos Maximos, Color Normal, Color Seleccionado, Fuente,Sprite);
var Id = instance_create(argument0,argument1,Obj_TextBox);
with(local.Id)
{
RMN_T = argument2;
RMN_Largo = argument3;
RMN_ColorNormal = argument4;
RMN_ColorSelec = argument5;
RMN_Fuente = argument6;
sprite_index = argument7;
}
return(Id);
Código del Script "Atributos_TextBox()":///Atributos_TextBox()
/* Indica si el usuario puede escribir */
RMN_Foco = false;
/* Texto del TextBox */
RMN_T = "";
/* Logitud maxima del texto del TextBox */
RMN_Largo = 512;
/* Color del texto sin foco */
RMN_ColorNormal = c_black;
/* Color del texto con foco */
RMN_ColorSelec = c_black;
/* Fuente del texto */
RMN_Fuente = noone;
//No modificar
RMN_Ubic=0;RMN_De="";RMN_A=RMN_De;RMN_Parp=RMN_Ubic;RMN_KeyPress=noone;RMN_KeyTiempo=RMN_Ubic;
Código del Script "Draw_TextBox()":///Draw_TextBox()
//Dibujamos el TextBox
draw_set_color(RMN_ColorNormal);
draw_set_font(RMN_Fuente);
draw_set_halign(0);
draw_set_valign(1);
/////////////////////////
/////////////////////////
draw_text(x-50,y, string(RMN_Foco) );
if RMN_Foco
&& !keyboard_check_pressed(vk_enter)
{
with(object_index){if (id!=other.id) {RMN_Foco=false;};RMN_NoTab=true;}
RMN_B1=0;RMN_B2=RMN_B1;
if RMN_T==""{RMN_Ubic=0;}
//Ubicacion
//Mouse
if mouse_check_button_pressed(mb_left)
{
var H;H=string_height("|�AT1_jpgq1")/2;
if mouse_y>=y-H&&mouse_y<=y+H
{
var i;for(i=0;i<string_length(RMN_T);i+=1;)
{
if string_width( string_copy(RMN_T,0,i) ) > (mouse_x-x) {i-=1;break;}
}
RMN_Ubic = i;
}
}
//Key
if keyboard_check_pressed(vk_right)
|| (RMN_KeyPress==vk_right && RMN_KeyTiempo == 15)
{
if RMN_KeyPress!=vk_right{RMN_KeyTiempo = 0;}
RMN_KeyPress = vk_right;
RMN_Ubic=min(RMN_Ubic+1,string_length(RMN_T));
}
if keyboard_check_pressed(vk_left)
|| (RMN_KeyPress==vk_left && RMN_KeyTiempo == 15)
{
if RMN_KeyPress!=vk_left{RMN_KeyTiempo = 0;}
RMN_KeyPress = vk_left;
RMN_Ubic=max(RMN_Ubic-1,0);
}
//Borrado
if keyboard_check_pressed(vk_backspace)
|| (RMN_KeyPress==vk_backspace && RMN_KeyTiempo == 15)
{
if RMN_KeyPress!=vk_backspace{RMN_KeyTiempo = 0;}
RMN_KeyPress = vk_backspace;
RMN_B1=1;
keyboard_string="";
}
if RMN_Ubic<string_length(RMN_T)
&& (keyboard_check_pressed(vk_delete)
|| (RMN_KeyPress==vk_delete && RMN_KeyTiempo == 15))
{
if RMN_KeyPress!=vk_delete{RMN_KeyTiempo = 0;}
RMN_KeyPress = vk_delete;
RMN_B2=1;
keyboard_string="";
}
if (RMN_KeyPress!=noone)
{
if (keyboard_check(RMN_KeyPress))
{if RMN_KeyTiempo<15{RMN_KeyTiempo+=1;}}
else
{RMN_KeyPress=noone; RMN_KeyTiempo=0;}
}
//Adherir
RMN_De=string_copy(RMN_T,0,max(RMN_Ubic-RMN_B1,0));
if keyboard_string!=""
|| RMN_B1==1
|| RMN_B2==1
{
RMN_A=string_copy(RMN_T,RMN_Ubic+1+RMN_B2, string_length(RMN_T)-RMN_Ubic);
var T;
T = RMN_De+keyboard_string+RMN_A
if string_length(T)<RMN_Largo {RMN_T=T;}else{RMN_Ubic=max(RMN_Ubic-1,0);}
if RMN_B1==0
{
if RMN_B2==0 {RMN_Ubic=min(RMN_Ubic+1,string_length(RMN_T));}
}
else
{RMN_Ubic=max(RMN_Ubic-1,0);}
RMN_De=string_copy(RMN_T,0,RMN_Ubic);
RMN_Parp=2;
}
//Dibujar
draw_set_color(RMN_ColorSelec);
draw_text(x,y,RMN_T);
if round(RMN_Parp)>=1
{
draw_text(x+string_width(RMN_De),y-2,"|");
draw_text(x+string_width(RMN_De),y+2,"|");
}
if RMN_Parp>=1.2
{
RMN_Parp-=.025;
}
else
{
RMN_Parp+=.025;
if RMN_Parp>=1 {RMN_Parp=0;}
}
keyboard_string="";
}
else
{
if keyboard_check_pressed(vk_enter){RMN_Foco = false;}
draw_text(x,y,RMN_T);
}
Código del Script "Dar_Foco_TextBox()":///Dar_Foco_TextBox(Objeto_TextBox)
with(object_index){RMN_Foco=false;RMN_NoTab=false;}
RMN_Foco = true;
[-][-][-][-][-][-][-][-][-][-][-][-][-][-][-][-][-][-]
[Version anterior]
[-][-][-][-][-][-][-][-][-][-][-][-][-][-][-][-][-][-]
Nombre del creador: romon_28.
Breve descripción de su función: Simula una textbox (caja de texto).
Versión GM utilizada: :GM6: :GM7: :GM8:
Código del Script "Crear_TextBox()":/*
Crear_TextBox(): Retorna la Id de la TextBox creada.
Uso:
TextBox1 = Crear_TextBox();
*/
if (!variable_global_exists("RMN_TextBoxSelec"))
{
global.RMN_TextBoxSelec = noone;
global.RMN_TextBoxIdAsing = 0;
}
else
{
global.RMN_TextBoxIdAsing += 1;
}
global.RMN_T[global.RMN_TextBoxIdAsing] = "";
RMN_Ubic = 0;
RMN_De = "";
RMN_A = "";
RMN_Parp=0;
global.RMN_TextBoxId = global.RMN_TextBoxIdAsing;
return(global.RMN_TextBoxId)
Código del Script "Foco_TextBox(id)":/*
Foco_TextBox(id);
*/
global.RMN_TextBoxSelec = argument0;
keyboard_string="";
RMN_Parp=2;
Código del Script "Perder_Foco_TextBox()":global.RMN_TextBoxSelec = noone;
Código del Script "get_Foco_TextBox(id)":/*
get_Foco_TextBox(id)
*/
return (global.RMN_TextBoxSelec==argument0);
Código del Script "get_Texto_TextBox(id)":/*
get_Texto_TextBox(id)
*/
return (global.RMN_T[argument0])
Código del Script "Draw_TextBox(id,x,y,ColorFoco,Maxim. Caracteres);":/*
Draw_TextBox(id,x,y,ColorFoco,Maxim. Caracteres);
Uso:
Draw_TextBox( TextBox1 , x , y , c_red , 12 );
*/
if global.RMN_TextBoxSelec==argument0
&& !keyboard_check_pressed(vk_enter)
{
RMN_B1=0;
RMN_B2=0;
if global.RMN_T[argument0]=="" {RMN_Ubic=0;}
//Ubicacion
//Mouse
if mouse_check_button_pressed(mb_left)
{
var H;
H=string_height("|ÁAT1_jpgq1")/2;
if mouse_y>=argument2-H
&& mouse_y<=argument2+H
{
var i;
for(i=0;i<string_length(global.RMN_T[argument0]);i+=1;)
{
if string_width( string_copy(global.RMN_T[argument0],0,i) ) > (mouse_x-argument1)
{
i-=1
break;
}
}
RMN_Ubic = i;
}
}
//Key
if keyboard_check_pressed(vk_right) {RMN_Ubic=min(RMN_Ubic+1,string_length(global.RMN_T[argument0]));}
if keyboard_check_pressed(vk_left ) {RMN_Ubic=max(RMN_Ubic-1,0);}
//Borrado
if keyboard_check_pressed(vk_backspace)
{
RMN_B1=1;
keyboard_string="";
}
if keyboard_check_pressed(vk_delete)
{
RMN_B2=1;
keyboard_string="";
}
//Adherir
RMN_De=string_copy(global.RMN_T[argument0],0,max(RMN_Ubic-RMN_B1,0));
if keyboard_string!=""
|| RMN_B1==1
|| RMN_B2==1
{
RMN_A=string_copy(global.RMN_T[argument0],RMN_Ubic+1+RMN_B2,string_length(global.RMN_T[argument0])-RMN_Ubic);
var T;
T = RMN_De+keyboard_string+RMN_A
if string_length(T)<argument4 {global.RMN_T[argument0] = T};
if RMN_B1==0
{
if RMN_B2==0 {RMN_Ubic+=1;}
}
else
{RMN_Ubic=max(RMN_Ubic-1,0);}
RMN_De=string_copy(global.RMN_T[argument0],0,RMN_Ubic);
RMN_Parp=2;
}
//Dibujar
draw_set_color(argument3);
draw_text(argument1,argument2,global.RMN_T[argument0])
if round(RMN_Parp)>=1
{
draw_text(argument1+string_width(RMN_De),argument2,"|");
draw_text(argument1+string_width(RMN_De)+1,argument2,"|");
}
if RMN_Parp>=1.2
{
RMN_Parp-=.025;
}
else
{
RMN_Parp+=.025;
if RMN_Parp>=1 {RMN_Parp=0;}
}
keyboard_string="";
}
else
{
if keyboard_check_pressed(vk_enter){Perder_Foco_TextBox();}
draw_text(argument1,argument2,global.RMN_T[argument0]);
}
Nota: El metodo
no dibuja la textbox (
sprite) solo su contenido. No esta completo al 100% pero suficiente para un juego simple. Si mas de una persona me pide que lo termine lo voy a hacer, de otro modo lo dejare haci como esta. Preferentemente quisiera algo de credito en el juego que use estos metodos pero ustedes deciden.
Sobre la descargas:
La 1º descarga contiene los metodos anteriores.
El 2º contiene un mini ejemplo de lo que se puede hacer, este ultimo tambien contiene otros metodos que no son parte del mismo y no son obligatorios.
*Añadi una 3º descarga con un ejemplo un poco mas simple. Espero que le tiendan :D
Hola vendría bien si lo actualizas al GM:S ya que se necesitara con urgencia :-[
hola si lo preparas para Studio lo probare veo hasta donde me sirve que me faltaria como funciona y todos los detallas, si sirve como tengo pensado tendras tus creditos, y quien sabes quiza un poco mas