# POLITICAL (1.2) by Lazeras
# Released 1 December 2014
from header_common import *
from header_presentations import *
from header_mission_templates import *
from ID_meshes import *
from header_operations import *
from header_triggers import *
from module_constants import *
from header_items import *   # Added for Show all Items presentation.
from module_items import *   # Added for Show all Items presentation.
import string
from header_terrain_types import *

####################################################################################################################
#  Each presentation record contains the following fields:
#  1) Presentation id: used for referencing presentations in other files. The prefix prsnt_ is automatically added before each presentation id.
#  2) Presentation flags. See header_presentations.py for a list of available flags
#  3) Presentation background mesh: See module_meshes.py for a list of available background meshes
#  4) Triggers: Simple triggers that are associated with the presentation
####################################################################################################################

# Manualy add these to module_presentations add 
# these lines from `presentations` to bottom of the file
presentations = [

#Rubik World Map
      ("world_map", 0, mesh_load_window, [
        (ti_on_presentation_load,
          [
            (presentation_set_duration, 999999),
            (set_fixed_point_multiplier, 1000),
           
          ## initialization part begin
            # presentation obj: begin from top left corner
            (assign, ":init_pos_x", 20), # init x
            (assign, ":init_pos_y", 720), # init y
           
            # world map, X: -180 t0 180  Y: -145 t0 145
            (assign, ":min_map_x", -180*1000),
            (assign, ":max_map_x", 180*1000),
            (assign, ":min_map_y", -145*1000),
            (assign, ":max_map_y", 145*1000),
            # also begin from top left corner
            (assign, ":init_map_x", ":min_map_x"), # init map_x
            (assign, ":init_map_y", ":max_map_y"), # init map_y
           
            # move length of p_temp_party, total_cols and total_rows
            (assign, ":party_move_length", 2*1000),
            (store_sub, ":total_cols", ":max_map_x", ":min_map_x"),
            (store_sub, ":total_rows", ":max_map_y", ":min_map_y"),
            (val_div, ":total_cols", ":party_move_length"),
            (val_div, ":total_rows", ":party_move_length"),
           
            # color_block_length
            (assign, ":color_block_length", 4),
            (store_mul, ":color_block_size", ":color_block_length", 50),
            (position_set_x, pos2, ":color_block_size"),
            (position_set_y, pos2, ":color_block_size"),
          ## initialization part end
           
            (assign, ":pos_x", ":init_pos_x"), # assign to cur pos_x
            (assign, ":pos_y", ":init_pos_y"), # assign to cur pos_y
            (assign, ":map_x", ":init_map_x"), # assign to cur map_x
            (assign, ":map_y", ":init_map_y"), # assign to cur map_y
            ## draw whole map
            (try_for_range, ":unused_rows", 0, ":total_rows"),
              (try_for_range, ":unused_cols", 0, ":total_cols"),
                (assign, ":dest_color", 0xFFFFFF), # default
                (position_set_x, pos3, ":map_x"),
                (position_set_y, pos3, ":map_y"),
                (party_set_position, "p_temp_party", pos3),
                (party_get_current_terrain, ":current_terrain", "p_temp_party"),
                (try_begin),
                  (eq, ":current_terrain", rt_water),
                  (assign, ":dest_color", 0xFFFFFF), # default
                (else_try),
                  (call_script, "script_get_closest_center", "p_temp_party"),
                  (assign, ":nearest_center", reg0),
                  (try_begin),
                    (gt, ":nearest_center", -1),
                    (store_faction_of_party, ":center_faction", ":nearest_center"),
                    (is_between, ":center_faction", kingdoms_begin, kingdoms_end),
                    (faction_get_color, ":dest_color", ":center_faction"),
                  (try_end),
                (try_end),
                (create_mesh_overlay, reg0, "mesh_white_plane"),
                (overlay_set_color, reg0, ":dest_color"),
                (position_set_x, pos1, ":pos_x"),
                (position_set_y, pos1, ":pos_y"),
                (overlay_set_position, reg0, pos1),
                (overlay_set_size, reg0, pos2), # color block size
               
                ## draw borderlines begin [optional]
                # borderlines length and whidth
                (store_add, ":line_length", ":color_block_size", 1*50),
                (assign, ":line_whidth", 1*50),
                # find bound_center
                (try_begin),
                  (this_or_next|party_slot_eq, ":nearest_center", slot_party_type, spt_town),
                  (party_slot_eq, ":nearest_center", slot_party_type, spt_castle),
                  (assign, ":bound_center", ":nearest_center"), # itself
                (else_try),
                  (party_slot_eq, ":nearest_center", slot_party_type, spt_village),
                  (party_get_slot, ":bound_center", ":nearest_center", slot_village_bound_center),
                (try_end),
                # compare with the left side color block
                (try_begin),
                  (store_sub, ":map_x_2", ":map_x", ":party_move_length"),
                  (assign, ":map_y_2", ":map_y"),
                  (position_set_x, pos4, ":map_x_2"),
                  (position_set_y, pos4, ":map_y_2"),
                  (party_set_position, "p_temp_party", pos4),
                  (party_get_current_terrain, ":current_terrain_2", "p_temp_party"),
                  (try_begin),
                    (assign, ":continue", 0),
                    (try_begin),
                      (neq, ":current_terrain", rt_water),
                      (neq, ":current_terrain_2", rt_water),
                      (call_script, "script_get_closest_center", "p_temp_party"),
                      (assign, ":nearest_center_2", reg0),
                      (try_begin),
                        (gt, ":nearest_center_2", -1),
                        (try_begin),
                          (this_or_next|party_slot_eq, ":nearest_center_2", slot_party_type, spt_town),
                          (party_slot_eq, ":nearest_center_2", slot_party_type, spt_castle),
                          (assign, ":bound_center_2", ":nearest_center_2"), # itself
                        (else_try),
                          (party_slot_eq, ":nearest_center_2", slot_party_type, spt_village),
                          (party_get_slot, ":bound_center_2", ":nearest_center_2", slot_village_bound_center),
                        (try_end),
                        (neq, ":bound_center_2", ":bound_center"),
                        (assign, ":continue", 1),
                      (try_end),
                    (else_try),
                      (neq, ":current_terrain", ":current_terrain_2"),
                      (this_or_next|eq, ":current_terrain", rt_water),
                      (eq, ":current_terrain_2", rt_water),
                      (assign, ":continue", 1),
                    (try_end),
                    (eq, ":continue", 1),
                    (create_mesh_overlay, reg0, "mesh_white_plane"),
                    (overlay_set_color, reg0, 0),
                    (position_set_x, pos1, ":pos_x"),
                    (position_set_y, pos1, ":pos_y"),
                    (overlay_set_position, reg0, pos1),
                    (position_set_x, pos1, ":line_whidth"),
                    (position_set_y, pos1, ":line_length"),
                    (overlay_set_size, reg0, pos1),
                  (try_end),
                (try_end),
                # compare with the under color block
                (try_begin),
                  (assign, ":map_x_2", ":map_x"),
                  (store_sub, ":map_y_2", ":map_y", ":party_move_length"),
                  (position_set_x, pos4, ":map_x_2"),
                  (position_set_y, pos4, ":map_y_2"),
                  (party_set_position, "p_temp_party", pos4),
                  (party_get_current_terrain, ":current_terrain_2", "p_temp_party"),
                  (try_begin),
                    (assign, ":continue", 0),
                    (try_begin),
                      (neq, ":current_terrain", rt_water),
                      (neq, ":current_terrain_2", rt_water),
                      (call_script, "script_get_closest_center", "p_temp_party"),
                      (assign, ":nearest_center_2", reg0),
                      (try_begin),
                        (gt, ":nearest_center_2", -1),
                        (try_begin),
                          (this_or_next|party_slot_eq, ":nearest_center_2", slot_party_type, spt_town),
                          (party_slot_eq, ":nearest_center_2", slot_party_type, spt_castle),
                          (assign, ":bound_center_2", ":nearest_center_2"),
                        (else_try),
                          (party_slot_eq, ":nearest_center_2", slot_party_type, spt_village),
                          (party_get_slot, ":bound_center_2", ":nearest_center_2", slot_village_bound_center),
                        (try_end),
                        (neq, ":bound_center_2", ":bound_center"),
                        (assign, ":continue", 1),
                      (try_end),
                    (else_try),
                      (neq, ":current_terrain", ":current_terrain_2"),
                      (this_or_next|eq, ":current_terrain", rt_water),
                      (eq, ":current_terrain_2", rt_water),
                      (assign, ":continue", 1),
                    (try_end),
                    (eq, ":continue", 1),
                    (create_mesh_overlay, reg0, "mesh_white_plane"),
                    (overlay_set_color, reg0, 0),
                    (position_set_x, pos1, ":pos_x"),
                    (position_set_y, pos1, ":pos_y"),
                    (overlay_set_position, reg0, pos1),
                    (position_set_x, pos1, ":line_length"),
                    (position_set_y, pos1, ":line_whidth"),
                    (overlay_set_size, reg0, pos1),
                  (try_end),
                (try_end),
                ## draw borderlines end [optional]
               
                # offset
                (val_add, ":pos_x", ":color_block_length"),
                (val_add, ":map_x", ":party_move_length"),
              (try_end),
              # offset
              (assign, ":pos_x", ":init_pos_x"),
              (val_sub, ":pos_y", ":color_block_length"),
              (assign, ":map_x", ":init_map_x"),
              (val_sub, ":map_y", ":party_move_length"),
            (try_end),
           
            ## blocks of centers
            (assign, ":slot_no", 0),
            (try_for_range, ":center_no", centers_begin, centers_end),
              (party_is_active, ":center_no"),
              (party_get_position, pos4, ":center_no"),
              (position_get_x, ":center_x", pos4),
              (position_get_y, ":center_y", pos4),
              (val_sub, ":center_x", ":init_map_x"),
              (val_sub, ":center_y", ":init_map_y"),
              (val_mul, ":center_x", ":color_block_length"),
              (val_mul, ":center_y", ":color_block_length"),
              (val_div, ":center_x", ":party_move_length"),
              (val_div, ":center_y", ":party_move_length"),
              (val_add, ":center_x", ":init_pos_x"),
              (val_add, ":center_y", ":init_pos_y"),
              # offset and size
              (try_begin),
                (party_slot_eq, ":center_no", slot_party_type, spt_town),
                (assign, ":block_size", 8),
                (assign, ":center_type", spt_town),
              (else_try),
                (party_slot_eq, ":center_no", slot_party_type, spt_castle),
                (assign, ":block_size", 4),
                (assign, ":center_type", spt_castle),
              (else_try),
                (party_slot_eq, ":center_no", slot_party_type, spt_village),
                (assign, ":block_size", 2),
                (assign, ":center_type", spt_village),
              (try_end),
              (store_div, ":half_block_size", ":block_size", 2),
              (val_sub, ":center_x", ":half_block_size"),
              (val_sub, ":center_y", ":half_block_size"),
              (val_mul, ":block_size", 50),
              # block
              (create_mesh_overlay, reg0, "mesh_white_plane"),
              (overlay_set_color, reg0, 0),
              (position_set_x, pos1, ":center_x"),
              (position_set_y, pos1, ":center_y"),
              (overlay_set_position, reg0, pos1),
              (position_set_x, pos1, ":block_size"),
              (position_set_y, pos1, ":block_size"),
              (overlay_set_size, reg0, pos1),
              # name
              (str_store_party_name, s1, ":center_no"),
              (create_text_overlay, reg1, s1, tf_center_justify),
              (store_add, ":text_x", ":center_x", 0),
              (store_add, ":text_y", ":center_y", 10),
              (position_set_x, pos1, ":text_x"),
              (position_set_y, pos1, ":text_y"),
              (overlay_set_position, reg1, pos1),
              (overlay_set_display, reg1, 0),
              # slots
              (troop_set_slot, "trp_temp_array_a", ":slot_no", reg0), # overlay id
              (troop_set_slot, "trp_temp_array_b", ":slot_no", ":center_type"), # center type
              (troop_set_slot, "trp_temp_array_c", ":slot_no", reg1), # center name
              (val_add, ":slot_no", 1),
            (try_end),
            (assign, "$temp", ":slot_no"), # record num of slots
           
            ## blocks of kingdoms
            (create_text_overlay, reg0, "@Factions", tf_vertical_align_center),
            (position_set_x, pos1, 790),
            (position_set_y, pos1, 700),
            (overlay_set_position, reg0, pos1),
           
            (assign, ":pos_x", 750),
            (assign, ":pos_y", 650),
            (try_for_range, ":cur_kingdom", kingdoms_begin, kingdoms_end),
              (faction_slot_eq, ":cur_kingdom", slot_faction_state, sfs_active),
              # color block
              (create_mesh_overlay, reg0, "mesh_white_plane"),
              (faction_get_color, ":dest_color", ":cur_kingdom"),
              (overlay_set_color, reg0, ":dest_color"),
              (position_set_x, pos1, ":pos_x"),
              (position_set_y, pos1, ":pos_y"),
              (overlay_set_position, reg0, pos1),
              # size: 35*25
              (position_set_x, pos1, 35*50),
              (position_set_y, pos1, 25*50),
              (overlay_set_size, reg0, pos1),
              # kingdom name
              (store_add, ":text_x", ":pos_x", 40),
              (store_add, ":text_y", ":pos_y", 12),
              (str_store_faction_name, s1, ":cur_kingdom"),
              (create_text_overlay, reg0, s1, tf_vertical_align_center),
              (position_set_x, pos1, ":text_x"),
              (position_set_y, pos1, ":text_y"),
              (overlay_set_position, reg0, pos1),
              (position_set_x, pos1, 900),
              (position_set_y, pos1, 900),
              (overlay_set_size, reg0, pos1),
              (val_sub, ":pos_y", 40),
            (try_end),
           
            ## show centers or not
            # towns
            (create_check_box_overlay, "$g_presentation_obj_1", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_x, pos1, 50),
            (position_set_y, pos1, 110),
            (overlay_set_position, "$g_presentation_obj_1", pos1),
            (overlay_set_val, "$g_presentation_obj_1", 1),
            (create_text_overlay, reg0, "@Show towns", tf_vertical_align_center),
            (position_set_x, pos1, 80),
            (position_set_y, pos1, 120),
            (overlay_set_position, reg0, pos1),
            # castles
            (create_check_box_overlay, "$g_presentation_obj_2", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_x, pos1, 250),
            (position_set_y, pos1, 110),
            (overlay_set_position, "$g_presentation_obj_2", pos1),
            (overlay_set_val, "$g_presentation_obj_2", 1),
            (create_text_overlay, reg0, "@Show castles", tf_vertical_align_center),
            (position_set_x, pos1, 280),
            (position_set_y, pos1, 120),
            (overlay_set_position, reg0, pos1),
            # villages
            (create_check_box_overlay, "$g_presentation_obj_3", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_x, pos1, 450),
            (position_set_y, pos1, 110),
            (overlay_set_position, "$g_presentation_obj_3", pos1),
            (overlay_set_val, "$g_presentation_obj_3", 1),
            (create_text_overlay, reg0, "@Show villages", tf_vertical_align_center),
            (position_set_x, pos1, 480),
            (position_set_y, pos1, 120),
            (overlay_set_position, reg0, pos1),
           
            (create_text_overlay, reg0, "@Tip: move the mouse onto the black blocks to show their names.", tf_vertical_align_center),
            (position_set_x, pos1, 50),
            (position_set_y, pos1, 95),
            (overlay_set_position, reg0, pos1),
            (position_set_x, pos1, 750),
            (position_set_y, pos1, 750),
            (overlay_set_size, reg0, pos1),
           
            (create_text_overlay, reg0, "@The World Map", tf_double_space|tf_center_justify),
            (position_set_x, pos1, 380),
            (position_set_y, pos1, 30),
            (overlay_set_position, reg0, pos1),
            (position_set_x, pos1, 2000),
            (position_set_y, pos1, 2000),
            (overlay_set_size, reg0, pos1),
           
            # Done
            (create_game_button_overlay, "$g_presentation_obj_5", "@Done"),
            (position_set_x, pos1, 900),
            (position_set_y, pos1, 25),
            (overlay_set_position, "$g_presentation_obj_5", pos1),
          ]),
       
        (ti_on_presentation_mouse_enter_leave,
          [
            (store_trigger_param_1, ":object"),
            (store_trigger_param_2, ":enter_leave"),
           
            # show center name when mouse on it
            (try_for_range, ":slot_no", 0, "$temp"),
              (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
              (store_sub, ":display_overlay", 1, ":enter_leave"),
              (troop_get_slot, ":cur_overlay", "trp_temp_array_c", ":slot_no"),
              (overlay_set_display, ":cur_overlay", ":display_overlay"),
            (try_end),
          ]),
     
        (ti_on_presentation_event_state_change,
          [
            (store_trigger_param_1, ":object"),
            (store_trigger_param_2, ":value"),
           
            (try_begin),
              (eq, ":object", "$g_presentation_obj_1"), # show towns
              (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_b", ":slot_no", spt_town),
                (troop_get_slot, ":cur_overlay", "trp_temp_array_a", ":slot_no"),
                (overlay_set_display, ":cur_overlay", ":value"),
              (try_end),
            (else_try),
              (eq, ":object", "$g_presentation_obj_2"), # show castles
              (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_b", ":slot_no", spt_castle),
                (troop_get_slot, ":cur_overlay", "trp_temp_array_a", ":slot_no"),
                (overlay_set_display, ":cur_overlay", ":value"),
              (try_end),
            (else_try),
              (eq, ":object", "$g_presentation_obj_3"), # show villages
              (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_b", ":slot_no", spt_village),
                (troop_get_slot, ":cur_overlay", "trp_temp_array_a", ":slot_no"),
                (overlay_set_display, ":cur_overlay", ":value"),
              (try_end),
            (else_try),
              (eq, ":object", "$g_presentation_obj_5"),
              (presentation_set_duration, 0),
            (try_end),
          ]),
      ]),
#Rubik World Map


#Caba`drin Custom Player Party Name
  ("set_party_name",0,mesh_load_window,[
     (ti_on_presentation_load,
       [(set_fixed_point_multiplier, 1000),
        (str_store_string, s1, "@What will your party be known as?"),
        (create_text_overlay, reg1, s1, tf_center_justify),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 500),
        (overlay_set_position, reg1, pos1),
        (overlay_set_text, reg1, s1),
        (create_simple_text_box_overlay, "$g_presentation_obj_name_kingdom_1"),
        (position_set_x, pos1, 400),
        (position_set_y, pos1, 400),
        (overlay_set_position, "$g_presentation_obj_name_kingdom_1", pos1),        
        (str_store_party_name, s7, "p_main_party"),
        (overlay_set_text, "$g_presentation_obj_name_kingdom_1", s7),
        
        (create_button_overlay, "$g_presentation_obj_name_kingdom_2", "@By the name entered above."),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 300),
        (overlay_set_position, "$g_presentation_obj_name_kingdom_2", pos1),
          
        (str_store_troop_name, s5, "trp_player"),
        (create_button_overlay, reg1, "@Simply by my name: {s5}."),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 275),
        (overlay_set_position, reg1, pos1),  
          
        (presentation_set_duration, 999999),
        ]),
      (ti_on_presentation_event_state_change,
       [(store_trigger_param_1, ":object"),
        (try_begin),
          (eq, ":object", "$g_presentation_obj_name_kingdom_1"),
          (str_store_string, s7, s0),
        (else_try),
          (eq, ":object", "$g_presentation_obj_name_kingdom_2"),
          (party_set_name, "p_main_party", s7),
          (party_set_slot, 0, 1, 1),
          (presentation_set_duration, 0),
        (else_try),
          (store_add, ":overlay", "$g_presentation_obj_name_kingdom_2", 1),
          (eq, ":overlay", ":object"),
          (party_set_name, "p_main_party", s5),
          (party_set_slot, 0, 1, 0),
          (presentation_set_duration, 0),
        (try_end),
        ]),
      ]),    
#Caba`drin Custom Player Party Name

#Caba`drin Custom Player Kingdom Vassal Titles
## Player Faction begin
# Set your vassals' titles - made by Caba'drin
("set_vassal_title",0,mesh_load_window,[
      (ti_on_presentation_load,
       [

        (presentation_set_duration, 999999),
        (set_fixed_point_multiplier, 1000),

        (str_clear, s11),
        (str_clear, s12),
        (str_clear, s21),
        (str_clear, s3),
        (str_clear, s4),
        (str_clear, s5),
        (str_clear, s6),
        (str_clear, s7),
        (str_clear, s8),
        (str_clear, s9),
        (str_clear, s10),

        ## done
        (create_game_button_overlay, "$g_presentation_obj_1", "@Use Custom"),
        (position_set_x, pos1, 900),
        (position_set_y, pos1, 25),
        (overlay_set_position, "$g_presentation_obj_1", pos1),

        (create_game_button_overlay, "$g_presentation_obj_2", "@Use Default"),
        (position_set_x, pos1, 730),
        (position_set_y, pos1, 25),
        (overlay_set_position, "$g_presentation_obj_2", pos1),
	
        (create_text_overlay, reg0, s0, tf_scrollable),
        (position_set_x, pos1, 50),
        (position_set_y, pos1, 50),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 550),
        (position_set_y, pos1, 650),
        (overlay_set_area_size, reg0, pos1),
        (set_container_overlay, reg0),
		
		(assign, ":num_options", 40),
		(val_add, ":num_options", 2), #For extra space for headings
		(assign, ":cur_y_shift", 40),
		(store_mul, ":headings_y", ":cur_y_shift", ":num_options"),
		(store_sub, ":inputs_y", ":headings_y", 5),
		
		(position_set_x, pos1, 50),
        (create_text_overlay, reg0, "@Custom Titles:", tf_vertical_align_center),
        (position_set_y, pos1, ":headings_y"),
        (overlay_set_position, reg0, pos1),

        ############################################################################################
        (position_set_x, pos1, 220),
		(val_sub, ":inputs_y", 45),

        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@MALE TITLES:", tf_center_justify),
        (overlay_set_position, reg1, pos1),


        (position_set_x, pos1, 110),
		(val_sub, ":inputs_y", 30),

        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Landless Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_20"),
        (overlay_set_position, "$g_presentation_obj_20", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_1", 0, 1), #Pick a slot
          (str_store_troop_name, s0, "trp_dummy_1"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_male_player"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_20", s0),

		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Village holder Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_21"),
        (overlay_set_position, "$g_presentation_obj_21", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_2_village", 0, 1), #Pick a slot
          (str_store_troop_name, s0, "trp_dummy_2_village"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_male_player_village"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_21", s0),

		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Castle holder Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_22"),
        (overlay_set_position, "$g_presentation_obj_22", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_3_castle", 0, 1), #Pick a slot
          (str_store_troop_name, s0, "trp_dummy_3_castle"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_male_player_castle"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_22", s0),

		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Town holder Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_23"),
        (overlay_set_position, "$g_presentation_obj_23", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_4_town", 0, 1), #Pick a slot
          (str_store_troop_name, s0, "trp_dummy_4_town"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_male_player_town"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_23", s0),


		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@King Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_24"),
        (overlay_set_position, "$g_presentation_obj_24", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_5_king", 0, 1), #Pick a slot
          (str_store_troop_name, s0, "trp_dummy_5_king"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_male_player_king"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_24", s0),



        #########################################################################################################
        (position_set_x, pos1, 220),
		(val_sub, ":inputs_y", 50),

        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@FEMALE TITLES:", tf_center_justify),
        (overlay_set_position, reg1, pos1),


		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Landless Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_26"),
        (overlay_set_position, "$g_presentation_obj_26", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_1", 0, 1), #Pick a slot
          (str_store_troop_name_plural, s0, "trp_dummy_1"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_female_player"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_26", s0),


		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Village Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_27"),
        (overlay_set_position, "$g_presentation_obj_27", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_2_village", 1, 1), #Pick a slot
          (str_store_troop_name_plural, s0, "trp_dummy_2_village"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_female_player_village"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_27", s0),


		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Castle Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_28"),
        (overlay_set_position, "$g_presentation_obj_28", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_3_castle", 1, 1), #Pick a slot
          (str_store_troop_name_plural, s0, "trp_dummy_3_castle"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_female_player_castle"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_28", s0),


		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Town Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_29"),
        (overlay_set_position, "$g_presentation_obj_29", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_4_town", 1, 1), #Pick a slot
          (str_store_troop_name_plural, s0, "trp_dummy_4_town"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_female_player_town"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_29", s0),


		(val_sub, ":inputs_y", 30),
        (position_set_x, pos1, 110),
        (position_set_y, pos1, ":inputs_y"),
        (create_text_overlay, reg1, "@Queen Title:", tf_center_justify),
        (overlay_set_position, reg1, pos1),
        
        (position_set_x, pos1, 260),
        (create_simple_text_box_overlay, "$g_presentation_obj_30"),
        (overlay_set_position, "$g_presentation_obj_30", pos1),
        (try_begin),
          (troop_slot_eq, "trp_dummy_5_king", 1, 1), #Pick a slot
          (str_store_troop_name_plural, s0, "trp_dummy_5_king"),
        (else_try),
          (str_store_string, s0, "@{!}"),
          (str_store_string, s0, "str_new_faction_title_female_player_queen"),
        (try_end),
        (overlay_set_text, "$g_presentation_obj_30", s0),


		#(val_sub, ":inputs_y", 30),
        #(position_set_x, pos1, 110),
        #(position_set_y, pos1, ":inputs_y"),
        #(create_text_overlay, reg1, "@Unmarried female Title:", tf_center_justify),
        #(overlay_set_position, reg1, pos1),
        
        #(position_set_x, pos1, 260),
        #(create_simple_text_box_overlay, "$g_presentation_obj_31"),
        #(overlay_set_position, "$g_presentation_obj_31", pos1),
        #(try_begin),
        #  (troop_slot_eq, "trp_dummy_6_unmarried", 1, 1), #Pick a slot
        #  (str_store_troop_name_plural, s0, "trp_dummy_6_unmarried"),
        #(else_try),
        #  (str_store_string, s0, "@{!}"),
        #  (str_store_string, s0, "str_new_faction_title_female_player_unmarried"),
        #(try_end),
        #(overlay_set_text, "$g_presentation_obj_31", s0),


        #(val_sub, ":inputs_y", 20),
        #(position_set_y, pos1, ":inputs_y"),
        #(position_set_y, pos1, 430),

        #(val_sub, ":inputs_y", 20),
        #(position_set_x, pos1, 110),
        #(position_set_x, pos1, ":label_x"),
        #(position_set_y, pos1, ":inputs_y"),




        ##########################################################################################
        (position_set_y, pos1, ":inputs_y"),
        #(position_set_x, pos1, 350),
        (val_sub, ":inputs_y", ":cur_y_shift"),	
		
        (set_container_overlay, -1),

		(create_text_overlay, reg1, "@Kaos Mod^Options", tf_center_justify),
		(overlay_set_color, reg1, 0xFFFFFFFF),
		(position_set_x, pos1, 800),
        (position_set_y, pos1, 600),
        (overlay_set_position, reg1, pos1),
        (position_set_x, pos1, 2000),
        (position_set_y, pos1, 2000),
        (overlay_set_size, reg1, pos1),

       ]),

    (ti_on_presentation_run,
      [
        ####### mouse fix pos system #######
        #(call_script, "script_mouse_fix_pos_run"),
        ####### mouse fix pos system #######
        (try_begin),
        (this_or_next|key_clicked, key_escape),
	        (key_clicked, key_right_mouse_button),
	        (presentation_set_duration, 0),
	        (assign, "$faction_display", 0),
	        (jump_to_menu, "mnu_camp_political"), # I asume it's called from report menu, you can modify it to any menus or using $next_menu declarated by menu that call this presentation
    	(try_end), 
    ]),



      (ti_on_presentation_event_state_change,
       [
        (store_trigger_param_1, ":object"),

        (try_begin),
	          (eq, ":object", "$g_presentation_obj_20"),
              (neg|str_is_empty, s0),
              (troop_set_name, "trp_dummy_1", s0),
              (troop_set_slot, "trp_dummy_1", 0, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_21"),
              (neg|str_is_empty, s0),
              (troop_set_name, "trp_dummy_2_village", s0),
              (troop_set_slot, "trp_dummy_2_village", 0, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_22"),
              (neg|str_is_empty, s0),
              (troop_set_name, "trp_dummy_3_castle", s0),
              (troop_set_slot, "trp_dummy_3_castle", 0, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_23"),
              (neg|str_is_empty, s0),
              (troop_set_name, "trp_dummy_4_town", s0),
              (troop_set_slot, "trp_dummy_4_town", 0, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_24"),
              (neg|str_is_empty, s0),
              (troop_set_name, "trp_dummy_5_king", s0),
              (troop_set_slot, "trp_dummy_5_king", 0, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_26"),
            (neg|str_is_empty, s0),
            (troop_set_plural_name, "trp_dummy_1", s0),
            (troop_set_slot, "trp_dummy_1", 1, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_27"),
            (neg|str_is_empty, s0),
            (troop_set_plural_name, "trp_dummy_2_village", s0),
            (troop_set_slot, "trp_dummy_2_village", 1, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_28"),
            (neg|str_is_empty, s0),
            (troop_set_plural_name, "trp_dummy_3_castle", s0),
            (troop_set_slot, "trp_dummy_3_castle", 1, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_29"),
            (neg|str_is_empty, s0),
            (troop_set_plural_name, "trp_dummy_4_town", s0),
            (troop_set_slot, "trp_dummy_4_town", 1, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_30"),
            (neg|str_is_empty, s0),
            (troop_set_plural_name, "trp_dummy_5_king", s0),
            (troop_set_slot, "trp_dummy_5_king", 1, 1),
        #(else_try),
        #  	(eq, ":object", "$g_presentation_obj_31"),
        #    (neg|str_is_empty, s0),
        #    (troop_set_plural_name, "trp_dummy_6_unmarried", s0),
        #    (troop_set_slot, "trp_dummy_6_unmarried", 1, 1),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_1"),
            (assign, "$kaos_has_custom_title", 1),
            (presentation_set_duration, 0),
            (jump_to_menu, "mnu_camp_political"),
        (else_try),
          	(eq, ":object", "$g_presentation_obj_2"),
          	(str_store_string, s0, "@{!}"),
            (troop_set_slot, "trp_dummy_1", 1, 0),
            (troop_set_slot, "trp_dummy_1", 0, 0),
            (troop_set_slot, "trp_dummy_2_village", 1, 0),
            (troop_set_slot, "trp_dummy_2_village", 0, 0),
            (troop_set_slot, "trp_dummy_3_castle", 1, 0),
            (troop_set_slot, "trp_dummy_3_castle", 0, 0),
            (troop_set_slot, "trp_dummy_4_town", 1, 0),
            (troop_set_slot, "trp_dummy_4_town", 0, 0),
            (troop_set_slot, "trp_dummy_5_king", 1, 0),
            (troop_set_slot, "trp_dummy_5_king", 0, 0),
            (troop_set_slot, "trp_dummy_6_unmarried", 1, 0),
            (troop_set_slot, "trp_dummy_6_unmarried", 0, 0),
            (assign, "$kaos_has_custom_title", 0),
            (presentation_set_duration, 0),
            (jump_to_menu, "mnu_camp_political"),
        (try_end),

        ]),
      ]),
#Caba`drin Custom Player Kingdom Vassal Titles


# Lav modifications start (custom lord notes)
    ("custom_lord_notes", prsntf_manual_end_only, 0,
        [
            (ti_on_presentation_load, [
                (call_script, "script_lco_create_container", 200, 275, 600, 201, 1),
                (call_script, "script_lco_create_mesh", "mesh_mp_ui_welcome_panel", 0, 0, 1000, 1000),
                (call_script, "script_lco_create_troop_portrait", "$g_cln_troop", 410, 12, 520, 520),
                (str_store_troop_name, s41, "$g_cln_troop"),
                (call_script, "script_lco_create_label", "str_s41", 300, 163, 1000, tf_center_justify),
                (overlay_set_color, reg0, 0x00FFFFFF),
                (call_script, "script_lco_create_label", "str_lcn_prompt", 25, 37, 750, 0),
                (overlay_set_color, reg0, 0x00FFFFFF),
                (store_troop_faction, ":faction", "$g_cln_troop"),
                (str_store_faction_name, s41, ":faction"),
                (call_script, "script_lco_create_label", "str_lcn_faction", 25, 137, 750, 0),
                (overlay_set_color, reg0, 0x00FFFFFF),
                (troop_get_slot, reg60, "$g_cln_troop", slot_troop_renown),
                (troop_get_slot, reg61, "$g_cln_troop", slot_troop_controversy),
                (call_script, "script_lco_create_label", "str_lcn_stats", 25, 112, 750, 0),
                (overlay_set_color, reg0, 0x00FFFFFF),
                (call_script, "script_lco_create_textbox", 25, 12, 400, 800),
                (assign, "$g_cln_edit", reg0),
                (overlay_obtain_focus, reg0),
                (set_container_overlay, -1),
                (presentation_set_duration, 999999),
            ]),
            (ti_on_presentation_event_state_change, [
                (store_trigger_param_1, ":overlay"),
                (store_trigger_param_2, ":value"),
                (try_begin),
                    (eq, ":overlay", "$g_cln_edit"),
                    (try_begin),
                        (neq, ":value", 0),
                        (add_troop_note_from_sreg, "$g_cln_troop", 15, "str_s0", 0),
                        (display_message, "@{!}Custom note added."),
                    (try_end),
                    (presentation_set_duration, 0),
                (try_end),
            ]),
        ]
    ),

# Lav modifications end (custom lord notes)



  ("kaos_political_options", 0, mesh_load_window, [ 
    (ti_on_presentation_load,
      [
            (presentation_set_duration, 999999),
            (set_fixed_point_multiplier, 1000),


            ## done
            #(create_game_button_overlay, "$g_presentation_obj_1", "@Done"),
            #(position_set_x, pos1, 900),
            #(position_set_y, pos1, 25),
            #(overlay_set_position, "$g_presentation_obj_1", pos1),

            #(create_game_button_overlay, "$g_presentation_obj_2", "@Default"),
            #(position_set_x, pos1, 730),
            #(position_set_y, pos1, 25),
            #(overlay_set_position, "$g_presentation_obj_2", pos1),
        
            (str_clear, s0),

            (create_text_overlay, reg0, s0, tf_scrollable),
            (position_set_x, pos1, 50),
            (position_set_y, pos1, 50),
            (overlay_set_position, reg0, pos1),
            (position_set_x, pos1, 550),
            (position_set_y, pos1, 650),
            (overlay_set_area_size, reg0, pos1),
            (set_container_overlay, reg0),
            
            (assign, ":num_options", 40),
            (val_add, ":num_options", 2), 
            (assign, ":cur_y_shift", 40),
            (store_mul, ":headings_y", ":cur_y_shift", ":num_options"),
            (store_sub, ":inputs_y", ":headings_y", 5),
            (position_set_x, pos1, 50),
            (assign, ":label_x", 50),

            ## Inputs        

            ## Heading
            #(create_text_overlay, reg0, "@KAOS: Political WARS Options:", tf_vertical_align_center),
            #(position_set_y, pos1, ":inputs_y"),
            #(overlay_set_position, reg0, pos1),
            #(val_sub, ":inputs_y", 50),

            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, 180),
            (position_set_y, pos1, ":inputs_y"),
            (create_text_overlay, reg1, "@Dynamic Titles:", tf_left_align),
            (overlay_set_position, reg1, pos1),


            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, 220),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 430),

            (position_set_y, pos1, ":inputs_y"),
            (create_text_overlay, reg1, "@Swadian Tittles:", tf_right_align),
            (overlay_set_position, reg1, pos1),

            ## combo button
            (position_set_x, pos1, 110),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 350),
           #(create_combo_label_overlay, "$g_presentation_obj_11"),
            (create_combo_button_overlay, "$g_presentation_obj_10"),
            (overlay_set_position, "$g_presentation_obj_10", pos1),
            (overlay_add_item, "$g_presentation_obj_10", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_10", 0),
            (overlay_add_item, "$g_presentation_obj_10", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_10", 1),
            (overlay_add_item, "$g_presentation_obj_10", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_10", 2),
            (overlay_add_item, "$g_presentation_obj_10", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_10", 3),
            (overlay_add_item, "$g_presentation_obj_10", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_10", 4),
            (overlay_add_item, "$g_presentation_obj_10", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_10", 5),
            (overlay_add_item, "$g_presentation_obj_10", "@Player"),
            (overlay_set_val, "$g_presentation_obj_10", 6),

            (faction_get_slot, ":faction", "fac_kingdom_1", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_10", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_10", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_10", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_10", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_10", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_10", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_10", 6),
            (try_end),

            (val_sub, ":inputs_y", 20),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 430),

            (val_sub, ":inputs_y", 20),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 150),
            (create_text_overlay, reg1, "@Vaegirs Tittles:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_11"),
            (overlay_set_position, "$g_presentation_obj_11", pos1),
            (overlay_add_item, "$g_presentation_obj_11", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_11", 0),
            (overlay_add_item, "$g_presentation_obj_11", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_11", 1),
            (overlay_add_item, "$g_presentation_obj_11", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_11", 2),
            (overlay_add_item, "$g_presentation_obj_11", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_11", 3),
            (overlay_add_item, "$g_presentation_obj_11", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_11", 4),
            (overlay_add_item, "$g_presentation_obj_11", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_11", 5),
            (overlay_add_item, "$g_presentation_obj_11", "@Player"),
            (overlay_set_val, "$g_presentation_obj_11", 6),

            (faction_get_slot, ":faction", "fac_kingdom_2", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_11", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_11", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_11", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_11", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_11", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_11", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_11", 6),
            (try_end),

            (val_sub, ":inputs_y", 20),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 350),

            (val_sub, ":inputs_y", 20),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 140),
            (create_text_overlay, reg1, "@Khanate Tittles:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_12"),
            (overlay_set_position, "$g_presentation_obj_12", pos1),
            (overlay_add_item, "$g_presentation_obj_12", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_12", 0),
            (overlay_add_item, "$g_presentation_obj_12", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_12", 1),
            (overlay_add_item, "$g_presentation_obj_12", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_12", 2),
            (overlay_add_item, "$g_presentation_obj_12", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_12", 3),
            (overlay_add_item, "$g_presentation_obj_12", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_12", 4),
            (overlay_add_item, "$g_presentation_obj_12", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_12", 5),
            (overlay_add_item, "$g_presentation_obj_12", "@Player"),
            (overlay_set_val, "$g_presentation_obj_12", 6),

            (faction_get_slot, ":faction", "fac_kingdom_3", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_12", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_12", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_12", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_12", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_12", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_12", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_12", 6),
            (try_end),

            (val_sub, ":inputs_y", 20),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 270),

            (val_sub, ":inputs_y", 20),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 150),
            (create_text_overlay, reg1, "@Nords Tittles:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_13"),
            (overlay_set_position, "$g_presentation_obj_13", pos1),
            (overlay_add_item, "$g_presentation_obj_13", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_13", 0),
            (overlay_add_item, "$g_presentation_obj_13", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_13", 1),
            (overlay_add_item, "$g_presentation_obj_13", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_13", 2),
            (overlay_add_item, "$g_presentation_obj_13", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_13", 3),
            (overlay_add_item, "$g_presentation_obj_13", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_13", 4),
            (overlay_add_item, "$g_presentation_obj_13", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_13", 5),
            (overlay_add_item, "$g_presentation_obj_13", "@Player"),
            (overlay_set_val, "$g_presentation_obj_13", 6),

            (faction_get_slot, ":faction", "fac_kingdom_4", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_13", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_13", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_13", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_13", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_13", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_13", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_13", 6),
            (try_end),

            (val_sub, ":inputs_y", 20),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 190),

            (val_sub, ":inputs_y", 20),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 140),
            (create_text_overlay, reg1, "@Rhodoks Tittles:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_14"),
            (overlay_set_position, "$g_presentation_obj_14", pos1),
            (overlay_add_item, "$g_presentation_obj_14", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_14", 0),
            (overlay_add_item, "$g_presentation_obj_14", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_14", 1),
            (overlay_add_item, "$g_presentation_obj_14", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_14", 2),
            (overlay_add_item, "$g_presentation_obj_14", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_14", 3),
            (overlay_add_item, "$g_presentation_obj_14", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_14", 4),
            (overlay_add_item, "$g_presentation_obj_14", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_14", 5),
            (overlay_add_item, "$g_presentation_obj_14", "@Player"),
            (overlay_set_val, "$g_presentation_obj_14", 6),

            (faction_get_slot, ":faction", "fac_kingdom_5", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_14", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_14", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_14", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_14", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_14", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_14", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_14", 6),
            (try_end),

            (val_sub, ":inputs_y", 20),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 110),

            (val_sub, ":inputs_y", 20),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 140),
            (create_text_overlay, reg1, "@Sultanate Tittles:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_15"),
            (overlay_set_position, "$g_presentation_obj_15", pos1),
            (overlay_add_item, "$g_presentation_obj_15", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_15", 0),
            (overlay_add_item, "$g_presentation_obj_15", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_15", 1),
            (overlay_add_item, "$g_presentation_obj_15", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_15", 2),
            (overlay_add_item, "$g_presentation_obj_15", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_15", 3),
            (overlay_add_item, "$g_presentation_obj_15", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_15", 4),
            (overlay_add_item, "$g_presentation_obj_15", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_15", 5),
            (overlay_add_item, "$g_presentation_obj_15", "@Player"),
            (overlay_set_val, "$g_presentation_obj_15", 6),

            (faction_get_slot, ":faction", "fac_kingdom_6", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_15", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_15", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_15", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_15", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_15", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_15", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_15", 6),
            (try_end),


            (val_sub, ":inputs_y", 20),
            (position_set_y, pos1, ":inputs_y"),
            #(position_set_y, pos1, 110),

            (val_sub, ":inputs_y", 20),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 150),
            (create_text_overlay, reg1, "@Player Tittles:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_16"),
            (overlay_set_position, "$g_presentation_obj_16", pos1),
            (overlay_add_item, "$g_presentation_obj_16", "@Swadian"),
            (overlay_set_val, "$g_presentation_obj_16", 0),
            (overlay_add_item, "$g_presentation_obj_16", "@Vaegirs"),
            (overlay_set_val, "$g_presentation_obj_16", 1),
            (overlay_add_item, "$g_presentation_obj_16", "@Khanate"),
            (overlay_set_val, "$g_presentation_obj_16", 2),
            (overlay_add_item, "$g_presentation_obj_16", "@Nords"),
            (overlay_set_val, "$g_presentation_obj_16", 3),
            (overlay_add_item, "$g_presentation_obj_16", "@Rhodoks"),
            (overlay_set_val, "$g_presentation_obj_16", 4),
            (overlay_add_item, "$g_presentation_obj_16", "@Sultanate"),
            (overlay_set_val, "$g_presentation_obj_16", 5),
            (overlay_add_item, "$g_presentation_obj_16", "@Player"),
            (overlay_set_val, "$g_presentation_obj_16", 6),

            (faction_get_slot, ":faction", "fac_player_supporters_faction", slot_kaoses_faction_title_type),
            (try_begin),
                (eq, ":faction", "fac_kingdom_1"),
                (overlay_set_val, "$g_presentation_obj_16", 0),
            (else_try),
                (eq, ":faction", "fac_kingdom_2"),
                (overlay_set_val, "$g_presentation_obj_16", 1),
            (else_try),
                (eq, ":faction", "fac_kingdom_3"),
                (overlay_set_val, "$g_presentation_obj_16", 2),
            (else_try),
                (eq, ":faction", "fac_kingdom_4"),
                (overlay_set_val, "$g_presentation_obj_16", 3),
            (else_try),
                (eq, ":faction", "fac_kingdom_5"),
                (overlay_set_val, "$g_presentation_obj_16", 4),
            (else_try),
                (eq, ":faction", "fac_kingdom_6"),
                (overlay_set_val, "$g_presentation_obj_16", 5),
            (else_try),
                (eq, ":faction", "fac_player_supporters_faction"),
                (overlay_set_val, "$g_presentation_obj_16", 6),
            (try_end),


            (val_sub, ":inputs_y", 20),
            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 110),
            (create_text_overlay, reg1, "@Titles Types:", tf_center_justify),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 350),
            (create_combo_button_overlay, "$g_presentation_obj_26"),
            (overlay_set_position, "$g_presentation_obj_26", pos1),
            (overlay_add_item, "$g_presentation_obj_26", "@Default"),
            (overlay_set_val, "$g_presentation_obj_26", 0),
            (overlay_add_item, "$g_presentation_obj_26", "@Dynamic"),
            (overlay_set_val, "$g_presentation_obj_26", 1),
            (overlay_add_item, "$g_presentation_obj_26", "@Custom"),
            (overlay_set_val, "$g_presentation_obj_26", 2),
            (try_begin),
                (eq, "$kaos_king_titles", 0),
                (eq, "$kaos_use_custom_title", 0),
                (overlay_set_val, "$g_presentation_obj_26", 0),
            (else_try),
                (eq, "$kaos_king_titles", 1),
                (overlay_set_val, "$g_presentation_obj_26", 1),
            (else_try),
                (eq, "$kaos_use_custom_title", 1),
                (overlay_set_val, "$g_presentation_obj_26", 2),
            (try_end),

            
            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 120),
            (create_text_overlay, "$g_presentation_obj_22", "@Royal Children Titles:", tf_center_justify),
            (overlay_set_position, "$g_presentation_obj_22", pos1),
            (overlay_set_tooltip, "$g_presentation_obj_22", "@Toggle Royal Children titles eg Prince and Princess"),

            (position_set_x, pos1, 350),
            (create_check_box_overlay, "$g_presentation_obj_22", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_y, pos1, ":inputs_y"),
            (overlay_set_position, "$g_presentation_obj_22", pos1),
            (overlay_set_val, "$g_presentation_obj_22", "$kaos_royal_children"),
            (val_sub, ":inputs_y", ":cur_y_shift"),
          

            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, 180),
            (position_set_y, pos1, ":inputs_y"),
            (create_text_overlay, reg1, "@Faction Options:", tf_center_justify),
            (overlay_set_position, reg1, pos1),


            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 120),
            (create_text_overlay, "$g_presentation_obj_18", "@Claimants Home Town:", tf_center_justify),
            (overlay_set_position, "$g_presentation_obj_18", pos1),
            (overlay_set_tooltip, "$g_presentation_obj_18", "@Toggle to give claimants their home towns eg Lady Isolla of Suno gets Suno when the rebellion starts"),

            (position_set_x, pos1, 350),
            (create_check_box_overlay, "$g_presentation_obj_18", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_y, pos1, ":inputs_y"),
            (overlay_set_position, "$g_presentation_obj_18", pos1),
            (overlay_set_val, "$g_presentation_obj_18", "$kaos_rebellion_home"),
            (val_sub, ":inputs_y", ":cur_y_shift"),

            
            (val_sub, ":inputs_y", 5),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 120),
            (create_text_overlay, "$g_presentation_obj_20", "@Civial War:", tf_center_justify),
            (overlay_set_position, "$g_presentation_obj_20", pos1),
            (overlay_set_tooltip, "$g_presentation_obj_20", "@Toggle to allow civial war within factions"),

            (position_set_x, pos1, 350),
            (create_check_box_overlay, "$g_presentation_obj_20", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_y, pos1, ":inputs_y"),
            (overlay_set_position, "$g_presentation_obj_20", pos1),
            (overlay_set_val, "$g_presentation_obj_20", "$kaos_civil_war"),
            (val_sub, ":inputs_y", ":cur_y_shift"),

            (val_sub, ":inputs_y", 5),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 120),
            (create_text_overlay, "$g_presentation_obj_24", "@Faction Restore:", tf_center_justify),
            (overlay_set_position, "$g_presentation_obj_24", pos1),
            (overlay_set_tooltip, "$g_presentation_obj_24", "@Toggle defeated Faction Restore"),

            (position_set_x, pos1, 350),
            (create_check_box_overlay, "$g_presentation_obj_24", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_y, pos1, ":inputs_y"),
            (overlay_set_position, "$g_presentation_obj_24", pos1),
            (overlay_set_val, "$g_presentation_obj_24", "$kaos_restore"),
            (val_sub, ":inputs_y", ":cur_y_shift"),

            
            #(val_sub, ":inputs_y", 5),
            #(position_set_x, pos1, ":label_x"),
            #(position_set_y, pos1, ":inputs_y"),
            #(position_set_x, pos1, 120),
            #(create_text_overlay, "$g_presentation_obj_26", "@Dynamic King Titles:", tf_center_justify),
            #(overlay_set_position, "$g_presentation_obj_26", pos1),
            #(overlay_set_tooltip, "$g_presentation_obj_26", "@Toggle Dynamic King Titles depending on faction size"),

            #(position_set_x, pos1, 350),
            #(create_check_box_overlay, "$g_presentation_obj_26", "mesh_checkbox_off", "mesh_checkbox_on"),
            #(position_set_y, pos1, ":inputs_y"),
            #(overlay_set_position, "$g_presentation_obj_26", pos1),
            #(overlay_set_val, "$g_presentation_obj_26", "$kaos_king_titles"),
            #(val_sub, ":inputs_y", ":cur_y_shift"),

            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, 180),
            (position_set_y, pos1, ":inputs_y"),
            (create_text_overlay, reg1, "@Party:", tf_center_justify),
            (overlay_set_position, reg1, pos1),

            (val_sub, ":inputs_y", 30),
            (position_set_x, pos1, ":label_x"),
            (position_set_y, pos1, ":inputs_y"),
            (position_set_x, pos1, 120),
            (create_text_overlay, "$g_presentation_obj_22", "@Custom Party Name:", tf_center_justify),
            (overlay_set_position, "$g_presentation_obj_22", pos1),
            (overlay_set_tooltip, "$g_presentation_obj_22", "@Toggle Custom Party Name"),

            (position_set_x, pos1, 350),
            (create_check_box_overlay, "$g_presentation_obj_22", "mesh_checkbox_off", "mesh_checkbox_on"),
            (position_set_y, pos1, ":inputs_y"),
            (overlay_set_position, "$g_presentation_obj_22", pos1),
            (overlay_set_val, "$g_presentation_obj_22", "$kaos_use_custom_name"),
            (val_sub, ":inputs_y", ":cur_y_shift"),


            #(val_sub, ":inputs_y", 5),
            #(position_set_x, pos1, ":label_x"),
            #(position_set_y, pos1, ":inputs_y"),
            #(position_set_x, pos1, 120),
            #(create_text_overlay, "$g_presentation_obj_28", "@Custom Title:", tf_center_justify),
            #(overlay_set_position, "$g_presentation_obj_28", pos1),
            #(overlay_set_tooltip, "$g_presentation_obj_28", "@Toggle Custom Titles"),

            #(position_set_x, pos1, 350),
            #(create_check_box_overlay, "$g_presentation_obj_28", "mesh_checkbox_off", "mesh_checkbox_on"),
            #(position_set_y, pos1, ":inputs_y"),
            #(overlay_set_position, "$g_presentation_obj_28", pos1),
            #(overlay_set_val, "$g_presentation_obj_28", "$kaos_use_custom_title"),
            #(val_sub, ":inputs_y", ":cur_y_shift"),

            (set_container_overlay, -1),

            (create_text_overlay, reg1, "@KAOS Political^Options", tf_center_justify|tf_with_outline),
            (overlay_set_color, reg1, 0x00000000),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 600),
            (overlay_set_position, reg1, pos1),
            (position_set_x, pos1, 2000),
            (position_set_y, pos1, 2000),
            (overlay_set_size, reg1, pos1),
            
            (str_store_string, s0, "@This will set the faction to use the titles for nobles from the selected faction"),
            (create_text_overlay, "$g_presentation_obj_17", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_17", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_17", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_17", pos1),
            (overlay_set_display, "$g_presentation_obj_17", 0),
          
            (str_store_string, s0, "@Toggle to give claimants their home towns eg Lady Isolla of Suno gets Suno when the rebellion starts. Otherwise they get a city removed from the capital"),
            (create_text_overlay, "$g_presentation_obj_19", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_19", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_19", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_19", pos1),
            (overlay_set_display, "$g_presentation_obj_19", 0),

            (str_store_string, s0, "@Toggle to allow civial war within factions, the chance of a civial war is tied to the fracturing of a faction."),
            (create_text_overlay, "$g_presentation_obj_21", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_21", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_21", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_21", pos1),
            (overlay_set_display, "$g_presentation_obj_21", 0),    

            (str_store_string, s0, "@Toggle Royal Children titles eg Prince and Princess for all the children of King's or queens. Is applied to all factions as a single set of titles."),
            (create_text_overlay, "$g_presentation_obj_23", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_23", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_23", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_23", pos1),
            (overlay_set_display, "$g_presentation_obj_23", 0),    

            (str_store_string, s0, "@Toggle Defeated Faction Restore. if set to on a defeated faction can come back when one of its old lords aquire a center with the old king and lords"),
            (create_text_overlay, "$g_presentation_obj_25", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_25", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_25", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_25", pos1),
            (overlay_set_display, "$g_presentation_obj_25", 0),    

            (str_store_string, s0, "@Select Dynamic King Titles depending on faction size as a faction grows or shrinks the faction leader title and faction name are dynamically changed.^Select custom titles that the player can specify for the faction to use. Must select player_supporter_faction for this option"),
            (create_text_overlay, "$g_presentation_obj_27", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_27", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_27", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_27", pos1),
            (overlay_set_display, "$g_presentation_obj_27", 0),    

            (str_store_string, s0, "@Select Dynamic King Titles depending on faction size as a faction grows or shrinks the faction leader title and faction name are dynamically changed.^Select custom titles that the player can specify for the faction to use. Must select player_supporter_faction for this option"),
            (create_text_overlay, "$g_presentation_obj_29", s0, tf_double_space|tf_scrollable),
            (position_set_x, pos1, 680),
            (position_set_y, pos1, 400),
            (overlay_set_position, "$g_presentation_obj_29", pos1),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, "$g_presentation_obj_29", pos1),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 120),
            (overlay_set_area_size, "$g_presentation_obj_29", pos1),
            (overlay_set_display, "$g_presentation_obj_29", 0),  

            ## Buttons
 
            ## Buttons
            (create_game_button_overlay, "$g_presentation_obj_2", "@Done"),
            (position_set_x, pos1, 900),
            (position_set_y, pos1, 25),
            (overlay_set_position, "$g_presentation_obj_2", pos1),  
        

      ]),

    (ti_on_presentation_event_state_change,
      [
            (store_trigger_param_1, ":object"),
            (store_trigger_param_2, ":value"),

(assign, reg52, ":object"),
(assign, reg53, ":object"),
#(display_log_message, "@{!} object {reg52} value {reg53}", 0xFF0000),

            (try_begin),
                  (eq, ":object", "$g_presentation_obj_10"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_kingdom_1", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_11"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_kingdom_2", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_12"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_kingdom_3", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_13"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_kingdom_4", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_14"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_kingdom_5", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_15"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_kingdom_6", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_16"),
                  (try_begin),
                    (eq, ":value", 0),
                    (assign, ":faction", "fac_kingdom_1"),
                  (else_try),
                    (eq, ":value", 1),
                    (assign, ":faction", "fac_kingdom_2"),
                  (else_try),
                    (eq, ":value", 2),
                    (assign, ":faction", "fac_kingdom_3"),
                  (else_try),
                    (eq, ":value", 3),
                    (assign, ":faction", "fac_kingdom_4"),
                  (else_try),
                    (eq, ":value", 4),
                    (assign, ":faction", "fac_kingdom_5"),
                  (else_try),
                    (eq, ":value", 5),
                    (assign, ":faction", "fac_kingdom_6"),
                  (else_try),
                    (eq, ":value", 6),
                    (assign, ":faction", "fac_player_supporters_faction"),
                  (try_end),
                  (faction_set_slot, "fac_player_supporters_faction", slot_kaoses_faction_title_type, ":faction"),
                  (call_script, "script_kaos_update_titles"),

            (else_try),#kaos_rebellion_home
                (eq, ":object", "$g_presentation_obj_18"),
                (assign, "$kaos_rebellion_home", ":value"),
            (else_try),#kaos_civil_war
                (eq, ":object", "$g_presentation_obj_20"),
                (assign, "$kaos_civil_war", ":value"),
            (else_try),#kaos_royal_children
                (eq, ":object", "$g_presentation_obj_22"),
                (assign, "$kaos_royal_children", ":value"),
                (call_script, "script_kaos_update_titles"),
            (else_try),#kaos_restore
                (eq, ":object", "$g_presentation_obj_24"),
                (assign, "$kaos_restore", ":value"),
                (call_script, "script_kaos_update_titles"),
            (else_try),#kaos_king_titles
                (eq, ":object", "$g_presentation_obj_26"),
                (try_begin),#default
                    (eq, ":value", 0),
                    (assign, "$kaos_king_titles", 0),
                    (assign, "$kaos_use_custom_title", 0),
                (else_try),#dynamic
                    (eq, ":value", 1),
                    (assign, "$kaos_king_titles", 1),
                (else_try),#custom
                    (eq, ":value", 2),
                    (assign, "$kaos_use_custom_title", 1),
                (try_end),
                (call_script, "script_kaos_update_titles"),
            (else_try),#kaos_use_custom_name
                (eq, ":object", "$g_presentation_obj_22"),
                (assign, "$kaos_use_custom_name", ":value"),
            (else_try),#kaos_use_suffixes
                (eq, ":object", "$g_presentation_obj_30"),
                (assign, "$kaos_use_suffixes", ":value"),
                (call_script, "script_kaos_update_titles"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_3"),
                #(presentation_set_duration, 0),
                (start_presentation, "prsnt_kaos_political_options"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_1"),
                (presentation_set_duration, 0),
                (jump_to_menu, "mnu_camp_political"),
            (else_try),
                (eq, ":object", "$g_presentation_obj_2"),
                (presentation_set_duration, 0),
                (jump_to_menu, "mnu_camp_political"),
            (try_end),

    ]),

    (ti_on_presentation_run,
      [
        (try_begin),
        (this_or_next|key_clicked, key_escape),
            (key_clicked, key_right_mouse_button),
            (presentation_set_duration, 0),
            (assign, "$faction_display", 0),
            (jump_to_menu, "mnu_camp_political"), 
        (try_end), 
    ]),



    ## Mouse-over
    (ti_on_presentation_mouse_enter_leave,
      [

          (store_trigger_param_1, ":object"),
          (store_trigger_param_2, ":enter_leave"),

(assign, reg52, ":object"),
#(display_log_message, "@{!} object {reg52}", 0xFF0000),

          (overlay_set_display, "$g_presentation_obj_17", 0),
          (overlay_set_display, "$g_presentation_obj_19", 0),
          (overlay_set_display, "$g_presentation_obj_21", 0),
          (overlay_set_display, "$g_presentation_obj_23", 0),
          (overlay_set_display, "$g_presentation_obj_25", 0),
          (overlay_set_display, "$g_presentation_obj_27", 0),
          (overlay_set_display, "$g_presentation_obj_29", 0),

          (try_begin),#Faction title selection
              (this_or_next|eq, ":object", 4),
              (this_or_next|eq, ":object", 5),
              (this_or_next|eq, ":object", 6),
              (this_or_next|eq, ":object", 7),
              (this_or_next|eq, ":object", 8),
              (this_or_next|eq, ":object", 9),
              (this_or_next|eq, ":object", 10),
              (this_or_next|eq, ":object", 11),
              (this_or_next|eq, ":object", 12),
              (this_or_next|eq, ":object", 13),
              (this_or_next|eq, ":object", 14),
              (this_or_next|eq, ":object", 15),
              (eq, ":object", 16),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  (overlay_set_display, "$g_presentation_obj_17", 0),
              (else_try),
                    (overlay_set_display, "$g_presentation_obj_17", 1),
              (try_end),
          (else_try),#Dynamic king titles
              (this_or_next|eq, ":object", 17),
              (eq, ":object", 18),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  (overlay_set_display, "$g_presentation_obj_27", 0),
              (else_try),
                    (overlay_set_display, "$g_presentation_obj_27", 1),
              (try_end),
          (else_try), # Royal children title
              (this_or_next|eq, ":object", 19),
              (eq, ":object", 20),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  (overlay_set_display, "$g_presentation_obj_23", 0),
              (else_try),
                    (overlay_set_display, "$g_presentation_obj_23", 1),
              (try_end),
          (else_try),# claimants home town
              (this_or_next|eq, ":object", 22),
              (eq, ":object", 23),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  (overlay_set_display, "$g_presentation_obj_19", 0),
              (else_try),
                    (overlay_set_display, "$g_presentation_obj_19", 1),
              (try_end),
          (else_try), # Civil War
              (this_or_next|eq, ":object", 24),
              (eq, ":object", 25),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  (overlay_set_display, "$g_presentation_obj_21", 0),
              (else_try),
                    (overlay_set_display, "$g_presentation_obj_21", 1),
              (try_end),
          (else_try),# Faction restore
              (this_or_next|eq, ":object", 26),
              (eq, ":object", 27),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  (overlay_set_display, "$g_presentation_obj_25", 0),
              (else_try),
                    (overlay_set_display, "$g_presentation_obj_25", 1),
              (try_end),
          (else_try),#custom party name
              (this_or_next|eq, ":object", 29),
              (eq, ":object", 30),
              (try_begin),
                  (eq, ":enter_leave", 0),
                  #(overlay_set_display, "$g_presentation_obj_29", 0),
              (else_try),
                  #(overlay_set_display, "$g_presentation_obj_29", 1),
              (try_end),
          (else_try),
                  #(overlay_set_display, "$g_presentation_obj_12", 0),
          (try_end),
    ]),
    # end mouseover






  ]),



  ("change_all_factions_color", 0, mesh_load_window, [
    (ti_on_presentation_load,
      [
        (presentation_set_duration, 999999),
        (set_fixed_point_multiplier, 1000),
        
        (create_combo_button_overlay, "$g_presentation_obj_1"),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 680),
        (overlay_set_position, "$g_presentation_obj_1", pos1),
        
        # faction list
        (troop_set_slot, "trp_temp_array_a", 0, "fac_deserters"),
        (troop_set_slot, "trp_temp_array_a", 1, "fac_outlaws"),
        (troop_set_slot, "trp_temp_array_a", 2, "fac_player_supporters_faction"),
        (troop_set_slot, "trp_temp_array_a", 3, "fac_kingdom_6"),
        (troop_set_slot, "trp_temp_array_a", 4, "fac_kingdom_5"),
        (troop_set_slot, "trp_temp_array_a", 5, "fac_kingdom_4"),
        (troop_set_slot, "trp_temp_array_a", 6, "fac_kingdom_3"),
        (troop_set_slot, "trp_temp_array_a", 7, "fac_kingdom_2"),
        (troop_set_slot, "trp_temp_array_a", 8, "fac_kingdom_1"),
        (troop_set_slot, "trp_temp_array_a", 9, "fac_kingdom_7"),
        (troop_set_slot, "trp_temp_array_a", 10, "fac_kingdom_8"),
        (troop_set_slot, "trp_temp_array_a", 11, "fac_kingdom_9"),
        (troop_set_slot, "trp_temp_array_a", 12, "fac_kingdom_10"),
        (troop_set_slot, "trp_temp_array_a", 13, "fac_kingdom_11"),
        (troop_set_slot, "trp_temp_array_a", 14, "fac_kingdom_12"),
        (troop_set_slot, "trp_temp_array_a", 15, "fac_kingdom_13"),
        (troop_set_slot, "trp_temp_array_a", 16, "fac_kingdom_14"),
        (troop_set_slot, "trp_temp_array_a", 17, "fac_kingdom_15"),
        (troop_set_slot, "trp_temp_array_a", 18, "fac_kingdom_16"),
        (troop_set_slot, "trp_temp_array_a", 19, "fac_kingdom_17"),
        (troop_set_slot, "trp_temp_array_a", 20, "fac_kingdom_18"),

        # default color list
        (troop_set_slot, "trp_temp_array_b", 0, 0x888888),
        (troop_set_slot, "trp_temp_array_b", 1, 0x888888),
        (troop_set_slot, "trp_temp_array_b", 2, 0xFF4433),
        (troop_set_slot, "trp_temp_array_b", 3, 0xDDDD33),
        (troop_set_slot, "trp_temp_array_b", 7, 0x33DD33),
        (troop_set_slot, "trp_temp_array_b", 5, 0x33DDDD),
        (troop_set_slot, "trp_temp_array_b", 6, 0xCC99FF),
        (troop_set_slot, "trp_temp_array_b", 7, 0xCCBB99),
        (troop_set_slot, "trp_temp_array_b", 8, 0xEE7744),
        (troop_set_slot, "trp_temp_array_b", 9, 0xCC9900),
        (troop_set_slot, "trp_temp_array_b", 10, 0x669999),
        (troop_set_slot, "trp_temp_array_b", 11, 0xCC66FF),
        (troop_set_slot, "trp_temp_array_b", 12, 0x3333FF),
        (troop_set_slot, "trp_temp_array_b", 13, 0x99FF66),
        (troop_set_slot, "trp_temp_array_b", 14, 0xCCFF66),
        (troop_set_slot, "trp_temp_array_b", 15, 0xCC9900),
        (troop_set_slot, "trp_temp_array_b", 16, 0x669999),
        (troop_set_slot, "trp_temp_array_b", 17, 0xCC66FF),
        (troop_set_slot, "trp_temp_array_b", 18, 0x3333FF),
        (troop_set_slot, "trp_temp_array_b", 19, 0x99FF66),
        (troop_set_slot, "trp_temp_array_b", 20, 0xCCFF66),
##
        
        (try_for_range, ":cur_slot", 0, 20),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", ":cur_slot"),
          (str_store_faction_name, s0, ":cur_faction"),
          (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active),
          (overlay_add_item, "$g_presentation_obj_1", s0),
        (try_end),
		(val_clamp, "$temp", 0, 20),
        (overlay_set_val, "$g_presentation_obj_1", "$temp"),
        
        ## name and color
        (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
        (str_store_faction_name, s0, ":cur_faction"),
        (create_text_overlay, reg1, "@Sovereign color of the {s0}:", tf_center_justify),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 600),
        (overlay_set_position, reg1, pos1),
        (create_mesh_overlay, "$g_presentation_obj_2", "mesh_white_plane"),
        (position_set_x, pos1, 450),
        (position_set_y, pos1, 480),
        (overlay_set_position, "$g_presentation_obj_2", pos1),
        (position_set_x, pos1, 5000),
        (position_set_y, pos1, 5000),
        (overlay_set_size, "$g_presentation_obj_2", pos1),
        (faction_get_color, ":faction_color", ":cur_faction"),
        (overlay_set_color, "$g_presentation_obj_2", ":faction_color"),
        
        ## sliders
        (position_set_x, pos1, 500),
        (create_slider_overlay, "$g_presentation_obj_3", 0, 255),
        (position_set_y, pos1, 400),
        (overlay_set_position, "$g_presentation_obj_3", pos1),
        (create_slider_overlay, "$g_presentation_obj_4", 0, 255),
        (position_set_y, pos1, 350),
        (overlay_set_position, "$g_presentation_obj_4", pos1),
        (create_slider_overlay, "$g_presentation_obj_5", 0, 255),
        (position_set_y, pos1, 300),
        (overlay_set_position, "$g_presentation_obj_5", pos1),
        (store_mod, ":blue", ":faction_color", 0x100),
        (val_div, ":faction_color", 0x100),
        (store_mod, ":green", ":faction_color", 0x100),
        (val_div, ":faction_color", 0x100),
        (store_mod, ":red", ":faction_color", 0x100),
        (overlay_set_val, "$g_presentation_obj_3", ":red"),
        (overlay_set_val, "$g_presentation_obj_4", ":green"),
        (overlay_set_val, "$g_presentation_obj_5", ":blue"),
        ## num boxes
        (position_set_x, pos1, 650),
        (create_number_box_overlay, "$g_presentation_obj_6", 0, 256),
        (position_set_y, pos1, 400),
        (overlay_set_position, "$g_presentation_obj_6", pos1),
        (create_number_box_overlay, "$g_presentation_obj_7", 0, 256),
        (position_set_y, pos1, 350),
        (overlay_set_position, "$g_presentation_obj_7", pos1),
        (create_number_box_overlay, "$g_presentation_obj_8", 0, 256),
        (position_set_y, pos1, 300),
        (overlay_set_position, "$g_presentation_obj_8", pos1),
        (overlay_set_val, "$g_presentation_obj_6", ":red"),
        (overlay_set_val, "$g_presentation_obj_7", ":green"),
        (overlay_set_val, "$g_presentation_obj_8", ":blue"),
        (assign, reg2, ":red"),
        (assign, reg3, ":green"),
        (assign, reg4, ":blue"),
        ## text: r g b
        (position_set_x, pos1, 330),
        (create_text_overlay, reg1, "@Red:", tf_center_justify),
        (position_set_y, pos1, 400),
        (overlay_set_position, reg1, pos1),
        (create_text_overlay, reg1, "@Green:", tf_center_justify),
        (position_set_y, pos1, 350),
        (overlay_set_position, reg1, pos1),
        (create_text_overlay, reg1, "@Blue:", tf_center_justify),
        (position_set_y, pos1, 300),
        (overlay_set_position, reg1, pos1),
        
        ## HTML code
        (create_text_overlay, "$g_presentation_obj_9", "@ ", tf_center_justify),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 450),
        (overlay_set_position, "$g_presentation_obj_9", pos1),
        (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
        (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        
        ## default and random
        (create_game_button_overlay, "$g_presentation_obj_11", "@Default"),
        (position_set_x, pos1, 420),
        (position_set_y, pos1, 230),
        (overlay_set_position, "$g_presentation_obj_11", pos1),
        (create_game_button_overlay, "$g_presentation_obj_12", "@Randomize"),
        (position_set_x, pos1, 580),
        (position_set_y, pos1, 230),
        (overlay_set_position, "$g_presentation_obj_12", pos1),
        
        ## color picker
        (create_mesh_overlay, reg1, "mesh_white_plane"),
        (position_set_x, pos1, 138),
        (position_set_y, pos1, 78),
        (overlay_set_position, reg1, pos1),
        (position_set_x, pos1, 36100),
        (position_set_y, pos1, 6100),
        (overlay_set_size, reg1, pos1),
        (overlay_set_color, reg1, 0),
        
        (assign, ":pos_x", 140),
        (assign, ":pos_y", 80),
        (try_for_range, ":cur_slot", 0, 216),
          (create_image_button_overlay, reg1, "mesh_white_plane", "mesh_white_plane"),
          (position_set_x, pos1, ":pos_x"),
          (position_set_y, pos1, ":pos_y"),
          (overlay_set_position, reg1, pos1),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg1, pos1),
          (assign, ":cur_color", ":cur_slot"),
          (call_script, "script_convert_slot_no_to_color", ":cur_color"),
          (assign, ":dest_color", reg0),
          (overlay_set_color, reg1, ":dest_color"),
          (val_add, ":pos_x", 20),
          (try_begin),
            (eq, ":pos_x", 860),
            (assign, ":pos_x", 140),
            (val_add, ":pos_y", 20),
          (try_end),
          (troop_set_slot, "trp_temp_array_c", ":cur_slot", reg1),
        (try_end),
        
        ## done
        (create_game_button_overlay, "$g_presentation_obj_10", "@Done"),
        (position_set_x, pos1, 900),
        (position_set_y, pos1, 25),
        (overlay_set_position, "$g_presentation_obj_10", pos1),
        ####### mouse fix pos system #######
        #(call_script, "script_mouse_fix_pos_ready"),
        ####### mouse fix pos system #######
      ]),

      #(ti_on_presentation_run,
        #[
        ####### mouse fix pos system #######
        #(call_script, "script_mouse_fix_pos_run"),
        ####### mouse fix pos system #######
      #]),
  
    (ti_on_presentation_run,
      [
        ####### mouse fix pos system #######
        #(call_script, "script_mouse_fix_pos_run"),
        ####### mouse fix pos system #######
        (try_begin),
        (this_or_next|key_clicked, key_escape),
	        (key_clicked, key_right_mouse_button),
	        (presentation_set_duration, 0),
	        (assign, "$faction_display", 0),
	        (jump_to_menu, "mnu_camp_political"), # I asume it's called from report menu, you can modify it to any menus or using $next_menu declarated by menu that call this presentation
    	(try_end), 
    ]),

    (ti_on_presentation_event_state_change,
      [
        (store_trigger_param_1, ":object"),
        (store_trigger_param_2, ":value"),
        
        (try_for_range, ":cur_slot", 0, 216),
          (troop_slot_eq, "trp_temp_array_c", ":cur_slot", ":object"),
          (assign, ":cur_color", ":cur_slot"),
          (call_script, "script_convert_slot_no_to_color", ":cur_color"),
          (assign, ":dest_color", reg0),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
          (faction_set_color, ":cur_faction", ":dest_color"),
          (overlay_set_color, "$g_presentation_obj_2", ":dest_color"),
          (store_mod, ":blue", ":dest_color", 0x100),
          (val_div, ":dest_color", 0x100),
          (store_mod, ":green", ":dest_color", 0x100),
          (val_div, ":dest_color", 0x100),
          (store_mod, ":red", ":dest_color", 0x100),
          (overlay_set_val, "$g_presentation_obj_3", ":red"),
          (overlay_set_val, "$g_presentation_obj_4", ":green"),
          (overlay_set_val, "$g_presentation_obj_5", ":blue"),
          (overlay_set_val, "$g_presentation_obj_6", ":red"),
          (overlay_set_val, "$g_presentation_obj_7", ":green"),
          (overlay_set_val, "$g_presentation_obj_8", ":blue"),
          (assign, reg2, ":red"),
          (assign, reg3, ":green"),
          (assign, reg4, ":blue"),
          (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
          (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        (try_end),
        
        (try_begin),
          (eq, ":object", "$g_presentation_obj_1"),
          (assign, "$temp", ":value"),
          (start_presentation, "prsnt_change_all_factions_color"),
        (else_try),
          (this_or_next|eq, ":object", "$g_presentation_obj_3"),
          (eq, ":object", "$g_presentation_obj_6"),
          (overlay_set_val, "$g_presentation_obj_3", ":value"),
          (overlay_set_val, "$g_presentation_obj_6", ":value"),
          (assign, reg2, ":value"),
          (call_script, "script_get_dest_color_from_rgb", reg2, reg3, reg4),
          (assign, ":cur_color", reg0),
          (overlay_set_color, "$g_presentation_obj_2", ":cur_color"),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
          (faction_set_color, ":cur_faction", ":cur_color"),
          (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
          (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        (else_try),
          (this_or_next|eq, ":object", "$g_presentation_obj_4"),
          (eq, ":object", "$g_presentation_obj_7"),
          (overlay_set_val, "$g_presentation_obj_4", ":value"),
          (overlay_set_val, "$g_presentation_obj_7", ":value"),
          (assign, reg3, ":value"),
          (call_script, "script_get_dest_color_from_rgb", reg2, reg3, reg4),
          (assign, ":cur_color", reg0),
          (overlay_set_color, "$g_presentation_obj_2", ":cur_color"),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
          (faction_set_color, ":cur_faction", ":cur_color"),
          (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
          (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        (else_try),
          (this_or_next|eq, ":object", "$g_presentation_obj_5"),
          (eq, ":object", "$g_presentation_obj_8"),
          (overlay_set_val, "$g_presentation_obj_5", ":value"),
          (overlay_set_val, "$g_presentation_obj_8", ":value"),
          (assign, reg4, ":value"),
          (call_script, "script_get_dest_color_from_rgb", reg2, reg3, reg4),
          (assign, ":cur_color", reg0),
          (overlay_set_color, "$g_presentation_obj_2", ":cur_color"),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
          (faction_set_color, ":cur_faction", ":cur_color"),
          (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
          (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_11"),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
          (troop_get_slot, ":default_color", "trp_temp_array_b", "$temp"),
          (faction_set_color, ":cur_faction", ":default_color"),
          (overlay_set_color, "$g_presentation_obj_2", ":default_color"),
          (store_mod, ":blue", ":default_color", 0x100),
          (val_div, ":default_color", 0x100),
          (store_mod, ":green", ":default_color", 0x100),
          (val_div, ":default_color", 0x100),
          (store_mod, ":red", ":default_color", 0x100),
          (overlay_set_val, "$g_presentation_obj_3", ":red"),
          (overlay_set_val, "$g_presentation_obj_4", ":green"),
          (overlay_set_val, "$g_presentation_obj_5", ":blue"),
          (overlay_set_val, "$g_presentation_obj_6", ":red"),
          (overlay_set_val, "$g_presentation_obj_7", ":green"),
          (overlay_set_val, "$g_presentation_obj_8", ":blue"),
          (assign, reg2, ":red"),
          (assign, reg3, ":green"),
          (assign, reg4, ":blue"),
          (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
          (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_12"),
          (store_random_in_range, reg2, 0, 256),
          (store_random_in_range, reg3, 0, 256),
          (store_random_in_range, reg4, 0, 256),
          (overlay_set_val, "$g_presentation_obj_3", reg2),
          (overlay_set_val, "$g_presentation_obj_4", reg3),
          (overlay_set_val, "$g_presentation_obj_5", reg4),
          (overlay_set_val, "$g_presentation_obj_6", reg2),
          (overlay_set_val, "$g_presentation_obj_7", reg3),
          (overlay_set_val, "$g_presentation_obj_8", reg4),
          (call_script, "script_get_dest_color_from_rgb", reg2, reg3, reg4),
          (assign, ":cur_color", reg0),
          (overlay_set_color, "$g_presentation_obj_2", ":cur_color"),
          (troop_get_slot, ":cur_faction", "trp_temp_array_a", "$temp"),
          (faction_set_color, ":cur_faction", ":cur_color"),
          (call_script, "script_convert_rgb_code_to_html_code", reg2, reg3, reg4),
          (overlay_set_text, "$g_presentation_obj_9", "@HTML code: {s0}"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_10"),
          (presentation_set_duration, 0),
        (try_end),
    ]),
  ]),












 ]
	
def modmerge_presentations(orig_presentations, check_duplicates = False):
    if( not check_duplicates ):
        orig_presentations.extend(presentations) # Use this only if there are no replacements (i.e. no duplicated item names)
    else:
    # Use the following loop to replace existing entries with same id
        for i in range (0,len(presentations)-1):
          find_index = find_object(orig_presentations, presentations[i][0]); # find_object is from header_common.py
          if( find_index == -1 ):
            orig_presentations.append(presentations[i])
          else:
            orig_presentations[find_index] = presentations[i]

# Used by modmerger framework version >= 200 to merge stuff
def modmerge(var_set):
    try:
        var_name_1 = "presentations"
        orig_presentations = var_set[var_name_1]
        modmerge_presentations(orig_presentations)
    except KeyError:
        errstring = "Variable set does not contain expected variable: \"%s\"." % var_name_1
        raise ValueError(errstring)