OSP Code QoL Full Party Stacks List (scrollable)

Users who are viewing this thread

Are you tired of unscrollable huge armies with member list so long it goes even beyond the screen, not allowing you to view prisoners (even though the counter by the party name suggests there are tons of them)? I, for one, am tired as hell (and has been for quite a decade now). About time someone does something about this.

Introducing... a comprehensive scrollable list of all party stacks via right-click! Yes, the solution is as simple as it sounds, behold:

Xzqzcfi.jpeg

aCRxaDG.jpeg

Ce8zPbz.jpeg

bW7zAUg.jpeg

fRhnnmL.jpeg

PHOTOSENSITIVITY WARNING:
If this window hasn't covered the context menu fully, the remaining part will start flickering until you close this one, which may potentially trigger seizures for people with photosensitive epilepsy. User discretion is advised, try to center the camera on the context menu of your target party, to make sure this screen will cover it fully when called.

Now for the implementation, this goes to module_presentations.py:
Code:
("party_stacks_scrollable", prsntf_read_only|prsntf_manual_end_only, 0,
  [
    (ti_on_presentation_load,
    [
      (presentation_set_duration, 999999),
      (set_fixed_point_multiplier, 1000),
      (party_collect_attachments_to_party, "$pss_party", "p_temp_party"),
      (assign, ":party", "p_temp_party"),
      (assign, ":source_party", "$pss_party"),
      (create_mesh_overlay, ":pss_bg_mesh", "mesh_white_plane"),
      (overlay_set_color, ":pss_bg_mesh", 0),
      (position_set_x, pos1, 16100), # Increase if your mod has long character names
      (position_set_y, pos1, 31300),
      (overlay_set_size, ":pss_bg_mesh", pos1),
      (position_set_x, pos1, 333),
      (position_set_y, pos1, 120),
      (overlay_set_position, ":pss_bg_mesh", pos1),
      (store_faction_of_party, ":faction", ":source_party"),
      (str_store_party_name, s1, ":source_party"),
      (str_store_faction_name, s2, ":faction"),
      (faction_get_color, ":color", ":faction"),
      (str_clear, s4),
      (str_clear, s7),
      (party_get_num_companion_stacks, ":num_stacks", ":party"),
      (assign, ":wounded", 0),
      (try_for_range, ":stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":troop", ":party", ":stack"),
        (party_stack_get_size, reg3, ":party", ":stack"),
        (party_stack_get_num_wounded, reg4, ":party", ":stack"),
        (str_store_string, s5, "@{reg3}"),
        (try_begin),
          (gt, reg4, 0),
          (val_add, ":wounded", reg4),
          (store_sub, reg5, reg3, reg4),
          (str_store_string, s5, "@{reg5}/{reg3}"),
        (try_end),
        (str_store_troop_name, s6, ":troop"),
        (try_begin),
          (troop_is_hero, ":troop"),
          (store_troop_health, reg6, ":troop"),
          (str_store_string, s5, "@{reg6}%"),
        (try_end),
        (str_store_string, s4, "@{s4}^{s6} ({s5})"),
      (try_end),
      (party_get_num_companions, reg1, ":party"),
      (party_get_num_prisoners, reg2, ":party"),
      (str_store_string, s10, "@{reg1}"),
      (try_begin),
        (gt, ":wounded", 0),
        (store_sub, reg9, reg1, ":wounded"),
        (str_store_string, s10, "@{reg9}/{reg1}"),
      (try_end),
      (try_begin),
        (eq, reg2, 0),
        (str_store_string, s3, "@{s1} ({s10})^({s2})"),
      (else_try),
        (str_store_string, s3, "@{s1} ({s10} + {reg2})^({s2})"),
        (party_get_num_prisoner_stacks, ":num_stacks", ":party"),
        (try_for_range, ":stack", 0, ":num_stacks"),
          (party_prisoner_stack_get_troop_id, ":troop", ":party", ":stack"),
          (party_prisoner_stack_get_size, reg7, ":party", ":stack"),
          (str_store_string, s8, "@{reg7}"),
          (str_store_troop_name, s9, ":troop"),
          (try_begin),
            (troop_is_hero, ":troop"),
            (store_troop_health, reg6, ":troop"),
            (str_store_string, s8, "@{reg8}%"),
          (try_end),
          (str_store_string, s7, "@{s7}^{s9} ({s8})"),
        (try_end),
      (try_end),
      (create_text_overlay, ":pss_party_name", s3, tf_center_justify),
      (create_text_overlay, ":pss_categories", "@Troops:^^^^^^^^^^^^^^^^Prisoners:", tf_center_justify),
      (create_text_overlay, ":pss_troops", s4, tf_left_align|tf_scrollable_style_2),
      (create_text_overlay, ":pss_prisoners", s7, tf_left_align|tf_scrollable_style_2),
      (create_button_overlay, "$pss_continue", "@Continue...", tf_center_justify),
      (create_button_overlay, "$pss_switch", "@Switch battle opponent", tf_center_justify),
      (overlay_set_color, ":pss_party_name", ":color"),
      (overlay_set_color, ":pss_categories", 0xB1812F),
      (overlay_set_color, ":pss_troops", 0xC2AFCB),
      (overlay_set_color, ":pss_prisoners", 0xB8A86D),
      (overlay_set_color, "$pss_continue", 0xFFFFFF),
      (overlay_set_color, "$pss_switch", 0xFFFFFF),
      (overlay_set_hilight_color, "$pss_continue", 0xFF0000),
      (overlay_set_hilight_color, "$pss_switch", 0xFF0000),
      (position_set_x, pos1, 950),
      (position_set_y, pos1, 950),
      (overlay_set_size, ":pss_party_name", pos1),
      (overlay_set_size, "$pss_continue", pos1),
      (overlay_set_size, "$pss_switch", pos1),
      (position_set_x, pos1, 880),
      (position_set_y, pos1, 880),
      (overlay_set_size, ":pss_troops", pos1),
      (overlay_set_size, ":pss_prisoners", pos1),
      (position_set_x, pos1, 488),
      (position_set_y, pos1, 700),
      (overlay_set_position, ":pss_party_name", pos1),
      (position_set_y, pos1, 330),
      (overlay_set_position, ":pss_categories", pos1),
      (position_set_y, pos1, 155),
      (overlay_set_position, "$pss_switch", pos1),
      (position_set_y, pos1, 130),
      (overlay_set_position, "$pss_continue", pos1),
      (position_set_x, pos1, 363),
      (position_set_y, pos1, 360),
      (overlay_set_position, ":pss_troops", pos1),
      (position_set_y, pos1, 190),
      (overlay_set_position, ":pss_prisoners", pos1),
      (position_set_x, pos1, 300),
      (position_set_y, pos1, 310),
      (overlay_set_area_size, ":pss_troops", pos1),
      (position_set_y, pos1, 140),
      (overlay_set_area_size, ":pss_prisoners", pos1),
      (party_get_battle_opponent, ":oppo", "$pss_party"),
      (eq, ":oppo", -1),
      (overlay_set_display, "$pss_switch", 0),
      ]), 
 
    (ti_on_presentation_event_state_change,
    [
      (store_trigger_param_1, ":object"),
      (try_begin),
        (eq, ":object", "$pss_switch"),
        (party_get_battle_opponent, ":oppo", "$pss_party"),
        (assign, "$pss_party", ":oppo"),
        (start_presentation, "prsnt_party_stacks_scrollable"),
      (else_try),
        (presentation_set_duration, 0),
      (try_end),
    ]),
  ]),


This part goes to module_scripts.py, specifically inside game_context_menu_get_buttons script
Code:
 (try_begin),  
    (neq, ":party_no", "p_main_party"),
    (party_collect_attachments_to_party, ":party_no", "p_temp_party"),
    (party_get_num_companion_stacks, ":list1", "p_temp_party"),
    (party_get_num_prisoner_stacks, ":list2", "p_temp_party"),
    (store_add, ":stack_list", ":list1", ":list2"),
    (ge, ":stack_list", 20), # we don't need this for every party so let's display it only when the list is large enough
    (context_menu_add_item, "@Full members list (scrollable)", 5),
  (end_try),


And finally in the script below, namely game_event_context_menu_button_clicked , add this:
Code:
(else_try),
    (eq, ":button_value", 5),
    (assign, "$pss_party", ":party_no"),
    (start_presentation, "prsnt_party_stacks_scrollable"),

That's it, here goes another annoying native aspect solved.
 
Last edited:
Back
Top Bottom