OSP Code SP [WB] A presentation for viewing all items directly

Users who are viewing this thread

rubik

Squire
The main section is a presentation, paste this presentation into module_presentations.py.

CSS:
  ("all_items", 0, mesh_load_window, [
    (ti_on_presentation_load,
      [
        (presentation_set_duration, 999999),
        (set_fixed_point_multiplier, 1000),
        (create_combo_label_overlay, "$g_presentation_obj_1"),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 675),
        (overlay_set_position, "$g_presentation_obj_1", pos1),
        (overlay_add_item, "$g_presentation_obj_1", "@Weapons"),
        (overlay_add_item, "$g_presentation_obj_1", "@Armors"),
        (overlay_add_item, "$g_presentation_obj_1", "@Others"),
        (overlay_set_val, "$g_presentation_obj_1", "$temp"),

        ## back
        (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),

        (str_clear, s0),
        (create_text_overlay, "$g_presentation_obj_6", s0, tf_scrollable),
        (position_set_x, pos1, 50),
        (position_set_y, pos1, 100),
        (overlay_set_position, "$g_presentation_obj_6", pos1),
        (position_set_x, pos1, 890),
        (position_set_y, pos1, 560),
        (overlay_set_area_size, "$g_presentation_obj_6", pos1),
        (set_container_overlay, "$g_presentation_obj_6"),

        (assign, ":num_items", len(items)),
        (assign, "$temp_2", 0),
        ## types
        (try_begin),
          (eq, "$temp", 0), # weapons
          (try_for_range, ":item_no", 0, ":num_items"),
            (item_get_type, ":type", ":item_no"),
            (this_or_next|is_between, ":type", itp_type_one_handed_wpn, itp_type_goods),
            (is_between, ":type", itp_type_pistol, itp_type_animal),
            (val_add, "$temp_2", 1),
          (try_end),
        (else_try),
          (eq, "$temp", 1), # armors
          (try_for_range, ":item_no", 0, ":num_items"),
            (item_get_type, ":type", ":item_no"),
            (is_between, ":type", itp_type_head_armor, itp_type_pistol),
            (val_add, "$temp_2", 1),
          (try_end),
        (else_try),
          (eq, "$temp", 2), # others
          (try_for_range, ":item_no", 0, ":num_items"),
            (item_get_type, ":type", ":item_no"),
            (this_or_next|eq, ":type", itp_type_horse),
            (this_or_next|eq, ":type", itp_type_goods),
            (this_or_next|eq, ":type", itp_type_animal),
            (eq, ":type", itp_type_book),
            (val_add, "$temp_2", 1),
          (try_end),
        (try_end),

        (store_div, ":height", "$temp_2", 11),
        (store_mod, ":offset", "$temp_2", 11),
        (val_min, ":offset", 1),
        (val_add, ":height", ":offset"),
        (store_mul, ":pos_y", ":height", 80),
        (val_sub, ":pos_y", 80),
        (assign, ":pos_x", 0),
        (assign, ":slot_no", 0),
        (try_for_range, ":item_no", 0, ":num_items"),
          (item_get_type, ":type", ":item_no"),
          (try_begin),
            (eq, "$temp", 0), # weapons
            (try_begin),
              (this_or_next|is_between, ":type", itp_type_one_handed_wpn, itp_type_goods),
              (is_between, ":type", itp_type_pistol, itp_type_animal),
              (assign, ":continue", 1),
            (else_try),
              (assign, ":continue", 0),
            (try_end),
          (else_try),
            (eq, "$temp", 1), # armors
            (try_begin),
              (is_between, ":type", itp_type_head_armor, itp_type_pistol),
              (assign, ":continue", 1),
            (else_try),
              (assign, ":continue", 0),
            (try_end),
          (else_try),
            (eq, "$temp", 2), # others
            (try_begin),
              (this_or_next|eq, ":type", itp_type_horse),
              (this_or_next|eq, ":type", itp_type_goods),
              (this_or_next|eq, ":type", itp_type_animal),
              (eq, ":type", itp_type_book),
              (assign, ":continue", 1),
            (else_try),
              (assign, ":continue", 0),
            (try_end),
          (try_end),
          (eq, ":continue", 1),
          ## item slot
          (create_mesh_overlay, reg1, "mesh_inv_slot"),
          (position_set_x, pos1, 800),
          (position_set_y, pos1, 800),
          (overlay_set_size, reg1, pos1),
          (position_set_x, pos1, ":pos_x"),
          (position_set_y, pos1, ":pos_y"),
          (overlay_set_position, reg1, pos1),
          (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"),
          (position_set_x, pos1, 640),
          (position_set_y, pos1, 640),
          (overlay_set_size, reg1, pos1),
          (position_set_x, pos1, ":pos_x"),
          (position_set_y, pos1, ":pos_y"),
          (overlay_set_position, reg1, pos1),
          (troop_set_slot, "trp_temp_array_a", ":slot_no", reg1),
          ## item
          (create_mesh_overlay_with_item_id, reg1, ":item_no"),
          (position_set_x, pos1, 800),
          (position_set_y, pos1, 800),
          (overlay_set_size, reg1, pos1),
          (store_add, ":item_x", ":pos_x", 40),
          (store_add, ":item_y", ":pos_y", 40),
          (position_set_x, pos1, ":item_x"),
          (position_set_y, pos1, ":item_y"),
          (overlay_set_position, reg1, pos1),
          (troop_set_slot, "trp_temp_array_b", ":slot_no", reg1),
          (troop_set_slot, "trp_temp_array_c", ":slot_no", ":item_no"),
          (val_add, ":pos_x", 80),
          (val_add, ":slot_no", 1),
          (try_begin),
            (ge, ":pos_x", 880),
            (assign, ":pos_x", 0),
            (val_sub, ":pos_y", 80),
          (try_end),
        (try_end),

        (set_container_overlay, -1),
        ## items
      ]),

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

      (try_begin),
        (eq, ":enter_leave", 0),
        (try_for_range, ":slot_no", 0, "$temp_2"),
          (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
          (troop_get_slot, ":item_no", "trp_temp_array_c", ":slot_no"),
          (troop_get_slot, ":target_obj", "trp_temp_array_b", ":slot_no"),
          (overlay_get_position, pos0, ":target_obj"),
          (show_item_details, ":item_no", pos0, 100),
          (assign, "$g_current_opened_item_details", ":slot_no"),
        (try_end),
      (else_try),
        (try_for_range, ":slot_no", 0, "$temp_2"),
          (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
          (try_begin),
            (eq, "$g_current_opened_item_details", ":slot_no"),
            (close_item_details),
          (try_end),
        (try_end),
      (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"),
          (assign, "$temp", ":value"),
          (start_presentation, "prsnt_all_items"),
        (else_try),
          (eq, ":object", "$g_presentation_obj_5"),
          (presentation_set_duration, 0),
        (try_end),
    ]),
  ]),

      ("action_view_all_items",[],"View all items.",
       [
        (assign, "$temp", 0),
        (start_presentation, "prsnt_all_items"),
        ]
       ),
      ## CC
      ("view_character_report",[],"View character report.",
       [(jump_to_menu, "mnu_character_report"),
        ]
       ),

Then add these two lines at the beginning of module_presentations.py, it's for including some constants from these two files:
CSS:
from header_items import *
from module_items import *

At last, you need to call this presentation at somewhere. For me, I call it in the reports menu which in module_game_menus.py.
For example:
CSS:
      ("cheat_faction_orders",[(ge,"$cheat_mode",1)],"{!}Cheat: Faction orders.",
       [(jump_to_menu, "mnu_faction_orders"),
        ]
       ),
      ## CC
      ("action_view_all_items",[],"View all items.",
       [
        (assign, "$temp", 0),
        (start_presentation, "prsnt_all_items"),
        ]
       ),
      ## CC
      ("view_character_report",[],"View character report.",
       [(jump_to_menu, "mnu_character_report"),
        ]
       ),

Screenshot:
54726830201008142342382285178975518_000_640.jpg
 
Last edited by a moderator:
Just found out one interesting use of this: checking for missing mesh/texture etc.  Just go page through all the items and if you don't get red message complaining about missing mesh/textures, you're good.  Otherwise, it's resource messing time :wink:
 
Back
Top Bottom