indexing description: "[ Block for Level Editor ]" date: "$Date$" revision: "$Revision$" class BB_LEVELEDIT_BLOCK inherit EM_LABEL create make feature {NONE} -- Initialization make (a_y: INTEGER; a_x: INTEGER) is -- Initialize `Current'. do create not_selected_border.make (create {EM_COLOR}.make_black, 1) create selected_border.make (create {EM_COLOR}.make_black, 3) create block_colors.make (-1, 9) block_colors.put (create {EM_COLOR}.make_with_rgb (164, 164, 164), -1) block_colors.put (create {EM_COLOR}.make_white, 0) block_colors.put (create {EM_COLOR}.make_with_rgb (120, 209, 134), 1) block_colors.put (create {EM_COLOR}.make_with_rgb (251, 191, 70), 2) block_colors.put (create {EM_COLOR}.make_with_rgb (116, 211, 209), 3) block_colors.put (create {EM_COLOR}.make_with_rgb (72, 158, 255), 4) block_colors.put (create {EM_COLOR}.make_with_rgb (73, 102, 251), 5) block_colors.put (create {EM_COLOR}.make_with_rgb (207, 74, 253), 6) block_colors.put (create {EM_COLOR}.make_with_rgb (255, 73, 217), 7) block_colors.put (create {EM_COLOR}.make_with_rgb (254, 73, 70), 8) block_colors.put (create {EM_COLOR}.make_with_rgb (200, 128, 129), 9) make_from_text ("") set_dimension (40, 20) set_position ((a_x - 1) * 40, (a_y - 1) * 20) set_border (not_selected_border) align_center set_foreground_color (create {EM_COLOR}.make_black) create item_indicator.make_from_dimension (4, 4) item_indicator.set_position (31, 8) item_indicator.set_background_color (create {EM_COLOR}.make_black) item_indicator.hide add_widget (item_indicator) set_hits (0) end feature -- Status report hits: INTEGER -- hits needed to destroy item: INTEGER -- embedded item feature -- Status setting mouse_click_event_subscribe (an_action: PROCEDURE [ANY, TUPLE [EM_MOUSEBUTTON_EVENT]]) is -- subscribe mouse click event do mouse_clicked_event.subscribe (an_action) end set_hits (a_hits: INTEGER) is -- set hits needed to destroy do hits := a_hits set_background_color (block_colors.item (hits)) if hits /= 0 then set_text (hits.out) else set_text ("") end end set_item (an_item: INTEGER) is -- set embedded item do item := an_item if item /= 0 then item_indicator.show else item_indicator.hide end end set_border_selected is -- set border for selected block do set_border (selected_border) end set_border_not_selected is -- set border for not selected block do set_border (not_selected_border) end feature {NONE} -- Implementation selected_border: EM_LINE_BORDER -- border for selected block not_selected_border: EM_LINE_BORDER -- border for not selected block block_colors: ARRAY[EM_COLOR] -- colors to show hits item_indicator: EM_PANEL -- panel showing an item is attached to the block end