本帖最后由 路过的罗格 于 2023-6-8 12:23 编辑
module_presentations.py
("book_management"里的
reference books部分,try_for_range改成try_for_range_backwards,别从前往后遍历了,改成从后往前。提升使用体验,新加入的书直接显示在最上面,方便分配。(代码块里加不了加粗,页内搜一下try_for_range_backwards,来找到代码里改了什么)
如果进行了导出书籍,会略微失效,需要点一次整理来保证正常使用。因为这个导出的格子被空出来了,所以下次添加时,会先填上这个格子,所以会乱,而整理功能可以把之前的格子都填满。
- # reference books
- # background
- (call_script, "script_prsnt_line", 320, 665, 20, 70, 0),
- (overlay_set_alpha, reg1, 0x33),
- # background
- (assign, ":reference_books", 0),
- (assign, ":reference_book_holders", 0),
- (troop_get_inventory_capacity, ":inv_cap", "trp_bookcase"),
- (try_for_range, ":i_slot", 10, ":inv_cap"),
- (troop_get_inventory_slot, ":item", "trp_bookcase", ":i_slot"),
- (gt, ":item", -1),
- (is_between, ":item", reference_books_begin, reference_books_end),
- (val_add, ":reference_books", 1),
- (troop_get_slot, ":book_holder", "trp_bookcase", ":i_slot"),
- (gt, ":book_holder", -1),
- (val_add, ":reference_book_holders", 1),
- (try_end),
- (assign, reg4, ":reference_books"),
- (assign, reg3, ":reference_book_holders"),
-
- (create_text_overlay, reg1, "@Reference Books({reg3}/{reg4})", tf_center_justify|tf_double_space),
- (position_set_x, pos1, 1200),
- (position_set_y, pos1, 1200),
- (overlay_set_size, reg1, pos1),
- (position_set_x, pos1, 175),
- (position_set_y, pos1, 700),
- (overlay_set_position, reg1, pos1),
-
- (str_clear, s0),
- (create_text_overlay, reg1, s0, tf_scrollable_style_2),
- (position_set_x, pos1, 20),
- (position_set_y, pos1, 70),
- (overlay_set_position, reg1, pos1),
- (position_set_x, pos1, 300),
- (position_set_y, pos1, 630),
- (overlay_set_area_size, reg1, pos1),
- (set_container_overlay, reg1),
-
- (store_div, ":num_rows", ":reference_books", 2),
- (store_mod, ":col_mod", ":reference_books", 2),
- (val_min, ":col_mod", 1),
- (val_add, ":num_rows", ":col_mod"),
- (store_mul, ":pos_y", ":num_rows", 125),
- (val_max, ":pos_y", 625),
- (val_sub, ":pos_y", 80),
- (assign, ":pos_x", 40),
- (assign, ":slot_no", 0),
- (troop_get_inventory_capacity, ":inv_cap", "trp_bookcase"),
- (<b><i>try_for_range_backwards</i></b>, ":i_slot", 10, ":inv_cap"),
- (troop_get_inventory_slot, ":item", "trp_bookcase", ":i_slot"),
- (gt, ":item", -1),
- (is_between, ":item", reference_books_begin, reference_books_end),
- # item slot
- (create_image_button_overlay, reg1, "mesh_mp_inventory_choose", "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 mesh
- (create_mesh_overlay_with_item_id, reg1, ":item"),
- (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", ":i_slot"),
- # text
- (str_store_item_name, s1, ":item"),
- (troop_get_slot, ":book_holder", "trp_bookcase", ":i_slot"),
- (try_begin),
- (eq, ":book_holder", -1),
- (str_store_string, s2, "@None"),
- (else_try),
- (str_store_troop_name, s2, ":book_holder"),
- (try_end),
- (create_text_overlay, reg1, "@{s1}^Holder: {s2}", tf_center_justify|tf_double_space),
- (position_set_x, pos1, 800),
- (position_set_y, pos1, 800),
- (overlay_set_size, reg1, pos1),
- (store_add, ":text_x", ":pos_x", 40),
- (store_add, ":text_y", ":pos_y", -40),
- (position_set_x, pos1, ":text_x"),
- (position_set_y, pos1, ":text_y"),
- (overlay_set_position, reg1, pos1),
- (val_add, ":pos_x", 150),
- (val_add, ":slot_no", 1),
- (try_begin),
- (ge, ":pos_x", 40+150*2),
- (assign, ":pos_x", 40),
- (val_sub, ":pos_y", 125),
- (try_end),
- (try_end),
- (set_container_overlay, -1),
复制代码
|