Пример #1
0
void slot_button::draw(
	const viewing_game_gui_context context, 
	const const_this_in_container this_id
) {
	if (!this_id->get_flag(augs::gui::flag::ENABLE_DRAWING)) {
		return;
	}

	const auto& cosm = context.get_cosmos();

	const auto slot_handle = cosm[this_id.get_location().slot_id];
	const auto hand_index = slot_handle.get_hand_index();
	const auto& detector = this_id->detector;
	const auto output = context.get_output();
	const auto& necessarys = context.get_necessary_images();

	rgba inside_col, border_col;
	
	if (slot_handle->category_allowed == item_category::GENERAL) {
		inside_col = cyan;
	}
	else {
		inside_col = violet;
	}

	border_col = inside_col;
	inside_col.a = 4 * 5;
	border_col.a = 220;

	if (detector.is_hovered || detector.current_appearance == augs::gui::appearance_detector::appearance::pushed) {
		inside_col.a = 12 * 5;
		border_col.a = 255;
	}

	using namespace assets;

	const auto inside_tex = necessarys.at(necessary_image_id::ATTACHMENT_CIRCLE_FILLED);
	const auto border_tex = necessarys.at(necessary_image_id::ATTACHMENT_CIRCLE_BORDER);

	const auto slot_type = slot_handle.get_type();

	auto draw_icon = [&](necessary_image_id id, const vec2i offset = vec2i(0, 0)) {
		output.gui_box_center_tex(inside_tex, context, this_id, inside_col);
		output.gui_box_center_tex(border_tex, context, this_id, border_col);

		output.gui_box_center_tex(necessarys.at(id), context, this_id, border_col, offset);
	};

	if (slot_handle->always_allow_exactly_one_item) {
		if (hand_index == 0) {
			draw_icon(necessary_image_id::PRIMARY_HAND_ICON, vec2(1, 0));
		}

		if (hand_index == 1) {
			draw_icon(necessary_image_id::SECONDARY_HAND_ICON);
		}

		if (slot_type == slot_function::BACK) {
			draw_icon(necessary_image_id::BACK_SLOT_ICON);
		}

		if (slot_type == slot_function::OVER_BACK) {
			draw_icon(necessary_image_id::BACK_SLOT_ICON);
		}

		if (slot_type == slot_function::SHOULDER) {
			draw_icon(necessary_image_id::SHOULDER_SLOT_ICON);
		}

		if (slot_type == slot_function::BELT) {
			draw_icon(necessary_image_id::BELT_SLOT_ICON);
		}

		if (slot_type == slot_function::TORSO_ARMOR) {
			draw_icon(necessary_image_id::ARMOR_SLOT_ICON);
		}

		if (slot_type == slot_function::GUN_CHAMBER) {
			draw_icon(necessary_image_id::CHAMBER_SLOT_ICON);
		}

		if (slot_type == slot_function::GUN_MUZZLE) {
			draw_icon(necessary_image_id::GUN_MUZZLE_SLOT_ICON);
		}

		if (slot_type == slot_function::GUN_DETACHABLE_MAGAZINE) {
			draw_icon(necessary_image_id::DETACHABLE_MAGAZINE_SLOT_ICON);
		}

		if (slot_type == slot_function::GUN_CHAMBER_MAGAZINE) {
			draw_icon(necessary_image_id::DETACHABLE_MAGAZINE_SLOT_ICON);
		}

		if (slot_type == slot_function::PERSONAL_DEPOSIT) {
			draw_icon(necessary_image_id::DETACHABLE_MAGAZINE_SLOT_ICON);
		}
	}

	const bool is_child_of_root = slot_handle.get_container() == context.get_subject_entity();

	if (!is_child_of_root) {
		const auto child_item_button = context.const_dereference_location(item_button_in_item{ slot_handle.get_container().get_id() });

		draw_pixel_line_connector(
			output,
			context.get_tree_entry(this_id).get_absolute_rect(),
			context.get_tree_entry(child_item_button).get_absolute_rect(),
			border_col
		);
	}
}
Пример #2
0
void slot_button::draw(const viewing_gui_context& context, const const_this_in_container& this_id, augs::gui::draw_info info) {
	if (!this_id->get_flag(augs::gui::flag::ENABLE_DRAWING)) {
		return;
	}

	const auto& step = context.get_step();
	const auto& cosmos = step.get_cosmos();

	const auto slot_id = cosmos[this_id.get_location().slot_id];
	const bool is_hand_slot = slot_id.is_hand_slot();
	const auto& detector = this_id->detector;

	rgba inside_col, border_col;
	
	if (slot_id->for_categorized_items_only) {
		inside_col = violet;
	}
	else {
		inside_col = cyan;
	}

	border_col = inside_col;
	inside_col.a = 4 * 5;
	border_col.a = 220;

	if (detector.is_hovered || detector.current_appearance == augs::gui::appearance_detector::appearance::pushed) {
		inside_col.a = 12 * 5;
		border_col.a = 255;
	}

	const auto inside_tex = assets::texture_id::ATTACHMENT_CIRCLE_FILLED;
	const auto border_tex = assets::texture_id::ATTACHMENT_CIRCLE_BORDER;

	const augs::gui::material inside_mat(inside_tex, inside_col);
	const augs::gui::material border_mat(border_tex, border_col);

	if (slot_id->always_allow_exactly_one_item) {
		draw_centered_texture(context, this_id, info, inside_mat);
		draw_centered_texture(context, this_id, info, border_mat);

		const auto slot_type = slot_id.get_id().type;

		if (slot_type == slot_function::PRIMARY_HAND) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::PRIMARY_HAND_ICON, border_col), vec2i(1, 0));
		}

		if (slot_type == slot_function::SECONDARY_HAND) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::SECONDARY_HAND_ICON, border_col));
		}

		if (slot_type == slot_function::SHOULDER_SLOT) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::SHOULDER_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::TORSO_ARMOR_SLOT) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::ARMOR_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::GUN_CHAMBER) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::CHAMBER_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::GUN_MUZZLE) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::GUN_MUZZLE_SLOT_ICON, border_col));
		}

		if (slot_type == slot_function::GUN_DETACHABLE_MAGAZINE) {
			draw_centered_texture(context, this_id, info, augs::gui::material(assets::texture_id::DETACHABLE_MAGAZINE_ICON, border_col));
		}
	}
	else {
		draw_centered_texture(context, this_id, info, inside_mat);
		draw_centered_texture(context, this_id, info, border_mat);

		const auto space_available_text = augs::gui::text::format(to_wstring(slot_id.calculate_free_space_with_parent_containers() / long double(SPACE_ATOMS_PER_UNIT), 2, true)
			, augs::gui::text::style(assets::font_id::GUI_FONT, border_col));

		augs::gui::text_drawer space_caption;
		space_caption.set_text(space_available_text);
		space_caption.center(context.get_tree_entry(this_id).get_absolute_rect());
		space_caption.draw(info);

		draw_children(context, this_id, info);
	}

	if (slot_id.get_container().get_owning_transfer_capability() != slot_id.get_container()) {
		const_dereferenced_location<item_button_in_item> child_item_button 
			= context.dereference_location(item_button_in_item{ slot_id.get_container().get_id() });

		draw_pixel_line_connector(context.get_tree_entry(this_id).get_absolute_rect(), context.get_tree_entry(child_item_button).get_absolute_rect(), info, border_col);
	}
}