LSP Kit QoL Animated Menu Making.

Users who are viewing this thread

Today I wanted to teach those who do not know how to make an animated menu.

For Example






download and install them.


we'll use a few code and shaders for this.


Codes =

module_presentations

Code:
presentations = [
  ("game_start",prsntf_read_only,0,[
    (ti_on_presentation_load,
      [
        (presentation_set_duration, 999999),
        (set_fixed_point_multiplier, 1000),

        (store_div, reg1, mod_version, 1000),
        (store_mod, reg2, mod_version, 1000),
        (try_begin),
          (eq, reg2, 0),
          (str_store_string, s1, "@{reg1}.0"),
        (else_try),
          (lt, reg2, 10),
          (str_store_string, s1, "@{reg1}.00{reg2}"),
        (else_try),
          (lt, reg2, 100),
          (try_begin),
            (store_mod, ":result", reg2, 10),
            (eq,  ":result", 0),
            (val_div, reg2, 10),
          (try_end),
          (str_store_string, s1, "@{reg1}.0{reg2}"),
        (else_try),
          (try_begin),
            (store_mod, ":result", reg2, 100),
            (eq,  ":result", 0),
            (val_div, reg2, 100),
          (else_try),
            (store_mod, ":result", reg2, 10),
            (eq,  ":result", 0),
            (val_div, reg2, 10),
          (try_end),
          (str_store_string, s1, "@{reg1}.{reg2}"),
        (try_end),
    
      (create_mesh_overlay, reg0, "mesh_main_menu_dust"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (create_mesh_overlay, reg0, "mesh_main_menu_static"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (create_mesh_overlay, reg0, "mesh_main_menu_prs"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (create_mesh_overlay, reg0, "mesh_main_menu_move_1"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (assign, ":var0", 1400),
      (assign, ":var1", 145),
      (assign, ":var2", 452),
      (assign, ":var3", -40),
      (create_text_overlay, "$g_presentation_credits_obj_1", "str_mod_ui_new_game", tf_center_justify|tf_double_space|tf_vertical_align_center),
      (position_set_x, pos1, ":var0"),
      (position_set_y, pos1, ":var0"),
      (overlay_set_size, "$g_presentation_credits_obj_1", pos1),
      (position_set_x, pos1, ":var1"),
      (position_set_y, pos1, ":var2"),
      (overlay_set_position, "$g_presentation_credits_obj_1", pos1),
      (val_add, ":var2", ":var3"),
      (create_text_overlay, "$g_presentation_credits_obj_2", "str_mod_ui_load_saved_game", tf_center_justify|tf_double_space|tf_vertical_align_center),
      (position_set_x, pos1, ":var0"),
      (position_set_y, pos1, ":var0"),
      (overlay_set_size, "$g_presentation_credits_obj_2", pos1),
      (position_set_x, pos1, ":var1"),
      (position_set_y, pos1, ":var2"),
      (overlay_set_position, "$g_presentation_credits_obj_2", pos1),
      (val_add, ":var2", ":var3"),
      (create_text_overlay, "$g_presentation_credits_obj_3", "str_mod_ui_quick_battle", tf_center_justify|tf_double_space|tf_vertical_align_center),
      (position_set_x, pos1, ":var0"),
      (position_set_y, pos1, ":var0"),
      (overlay_set_size, "$g_presentation_credits_obj_3", pos1),
      (position_set_x, pos1, ":var1"),
      (position_set_y, pos1, ":var2"),
      (overlay_set_position, "$g_presentation_credits_obj_3", pos1),
      (val_add, ":var2", ":var3"),
      (create_text_overlay, "$g_presentation_credits_obj_4", "str_mod_ui_options", tf_center_justify|tf_double_space|tf_vertical_align_center),
      (position_set_x, pos1, ":var0"),
      (position_set_y, pos1, ":var0"),
      (overlay_set_size, "$g_presentation_credits_obj_4", pos1),
      (position_set_x, pos1, ":var1"),
      (position_set_y, pos1, ":var2"),
      (overlay_set_position, "$g_presentation_credits_obj_4", pos1),
      (val_add, ":var2", ":var3"),
      (create_text_overlay, "$g_presentation_credits_obj_5", "str_mod_ui_credits", tf_center_justify|tf_double_space|tf_vertical_align_center),
      (position_set_x, pos1, ":var0"),
      (position_set_y, pos1, ":var0"),
      (overlay_set_size, "$g_presentation_credits_obj_5", pos1),
      (position_set_x, pos1, ":var1"),
      (position_set_y, pos1, ":var2"),
      (overlay_set_position, "$g_presentation_credits_obj_5", pos1),
      (val_add, ":var2", ":var3"),
      (create_text_overlay, "$g_presentation_credits_obj_6", "str_mod_ui_exit", tf_center_justify|tf_double_space|tf_vertical_align_center),
      (position_set_x, pos1, ":var0"),
      (position_set_y, pos1, ":var0"),
      (overlay_set_size, "$g_presentation_credits_obj_6", pos1),
      (position_set_x, pos1, ":var1"),
      (position_set_y, pos1, ":var2"),
      (overlay_set_position, "$g_presentation_credits_obj_6", pos1),
    ]),
    (ti_on_presentation_mouse_enter_leave,
    [
      (store_trigger_param_1, ":var0"),
      (store_trigger_param_2, ":var1"),
      (this_or_next|eq, ":var0", "$g_presentation_credits_obj_1"),
      (this_or_next|eq, ":var0", "$g_presentation_credits_obj_2"),
      (this_or_next|eq, ":var0", "$g_presentation_credits_obj_3"),
      (this_or_next|eq, ":var0", "$g_presentation_credits_obj_4"),
      (this_or_next|eq, ":var0", "$g_presentation_credits_obj_5"),
      (eq, ":var0", "$g_presentation_credits_obj_6"),
      (try_begin),
        (eq, ":var1", 1),
        (overlay_set_color, ":var0", 0x000000),
        (assign, ":var2", 1400),
        (position_set_x, pos1, ":var2"),
        (position_set_y, pos1, ":var2"),
        (overlay_set_size, ":var0", pos1),
      (else_try),
        (overlay_set_color, ":var0", 0xAA0000),
        (assign, ":var2", 1600),
        (position_set_x, pos1, ":var2"),
        (position_set_y, pos1, ":var2"),
        (overlay_set_size, ":var0", pos1),
      (try_end),
    ]),
  ]),

module_strings
Code:
  ("mod_ui_new_game", "Start New Game"),
  ("mod_ui_load_saved_game", "Registered Games"),
  ("mod_ui_quick_battle", "Multiplayer"),
  ("mod_ui_options", "Quick Battle"),
  ("mod_ui_credits", "Options"),
  ("mod_ui_exit", "Exit"),

module_meshes
Code:
  ("main_menu_dust", 0, "main_menu_dust", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("main_menu_move_1", 0, "main_menu_move_1", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("main_menu_prs", 0, "main_menu_prs", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("main_menu_static", 0, "main_menu_static", 0, 0, 0, 0, 0, 0, 1, 1, 1),
  ("main_menu_background", 0, "main_menu_crusaders", 0, 0, 0, 0, 0, 0, 1, 1, 1),

If you use this code, give credit to the cwe mod team.
 
Last edited:
About shaders, you need to use the default native shader for static layers, and a duplicate for moving ones.
In which we will shift the texture by UV:
Code:
float vel = 1.05; // velocity
tc.x -= vel*time_var; // -  or + direction

You can create a pair of shaders with different speeds for the parallax effect.
Also, if you cut the picture to layers, then you can dust up between the static parts of the image. Render order is customizable in openBrf.
 
here is the shader part of this. Just a copy of no_shade shader. I dropped the velocity to a fair point. Menu was so fast that my eye have gone crazy.  :grin:
Code:
VS_OUTPUT_FONT vs_menu_move(float4 vPosition : POSITION, float4 vColor : COLOR, float2 tc : TEXCOORD0)
{
	VS_OUTPUT_FONT Out;
   \\animation starts
	float vel = 0.006; // velocity
   tc.x -= vel*time_var; // - direction

	Out.Pos = mul(matWorldViewProj, vPosition);

	float3 P = mul(matWorldView, vPosition).xyz; //position in view space

	Out.Tex0 = tc;
	Out.Color = vColor * vMaterialColor;

	//apply fog
	float d = length(P);
	float4 vWorldPos = (float4)mul(matWorld,vPosition);
	Out.Fog = get_fog_amount_new(d, vWorldPos.z);

	return Out;
}
VertexShader vs_menu_move_compiled_2_0 = compile vs_2_0 vs_menu_move();

VS_OUTPUT_FONT vs_menu_dust(float4 vPosition : POSITION, float4 vColor : COLOR, float2 tc : TEXCOORD0)
{
	VS_OUTPUT_FONT Out;
   \\animation starts
	float vel = 0.008; // velocity
   tc.x += vel*time_var; // + direction

	Out.Pos = mul(matWorldViewProj, vPosition);

	float3 P = mul(matWorldView, vPosition).xyz; //position in view space

	Out.Tex0 = tc;
	Out.Color = vColor * vMaterialColor;

	//apply fog
	float d = length(P);
	float4 vWorldPos = (float4)mul(matWorld,vPosition);
	Out.Fog = get_fog_amount_new(d, vWorldPos.z);

	return Out;
}
VertexShader vs_menu_dust_compiled_2_0 = compile vs_2_0 vs_menu_dust();


technique main_menu_move
{
	pass P0
	{
		VertexShader = vs_menu_move_compiled_2_0;
		PixelShader = compile ps_2_0 ps_no_shading();
	}
}


technique main_menu_dust
{
	pass P0
	{
		VertexShader = vs_menu_dust_compiled_2_0;
		PixelShader = compile ps_2_0 ps_no_shading();
	}
}

so if you have your own shaders, you don't need to replace your mb.fx file. You can add these to your custom mb_source.fx.

Thanks to CWE team for this generousity.  :smile:
 
kalarhan said:
[Bcw]Btm_Earendil said:
In case there is a video in the first spoiler, please add a link for fellows like me who can't see it  :oops:

https://www.youtube.com/watch?v=fi2-2S1VAHg

when that happens just quote the post and look at the content, you can extract the url from the text directly
I know I can look it up by quoting but others might not be aware of that. And it's also just easier to just click on a link than digging it out ^^
 
Anyone know why the game will just completely close after reaching the main menu. I have 2 moving smoke layers with a little message pop up, the message pops up but the smoke doesn't then after 2-5 seconds will just close. Looked at the rgl log and have been testing around and got some more things to change but want to see if someone might know what the issue might be.

Edit: Got a overlay to appear but it has another texture being overlayed. |
("game_start", prsntf_read_only, mesh_mp_score_a,
  [
    (ti_on_presentation_load,
    [
      (presentation_set_duration, 999999),
      (set_fixed_point_multiplier, 1000),
      (assign, ":var0", 1000),
      (store_div, reg1, ":var0", 1000),
      (store_mod, reg2, ":var0", 1000),
      (try_begin),
        (display_message, "@GoT texture pack | ported by Caskie"),
      (try_end),

      (create_mesh_overlay, reg0, "mesh_main_menu_dust"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (create_mesh_overlay, reg0, "mesh_main_menu_static"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (create_mesh_overlay, reg0, "mesh_main_menu_smoke_2"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
      (create_mesh_overlay, reg0, "mesh_main_menu_smoke"),
      (position_set_x, pos1, 0),
      (position_set_y, pos1, 0),
      (overlay_set_position, reg0, pos1),
    ]),
  ]),
I took out the option placement btw as i want to see how the menu is aligned but all im getting now is a white screen.


 
Back
Top Bottom