//This actually updates a hell of a lot more than mouse info. It's the central function for //Clicking and dragging stuff into inventory slots / equip slots public void update_mouse_info(Vector2 mousePos, Player pl, bool holdingmouse, bool clickedmouse, out bool bad_turn) { mousePosition = mousePos; is_holding_mouse = holdingmouse; is_click_mouse = clickedmouse; //On the click, snap the rectangle to the mouse spot, and then pick an icon to draw in it. if (is_click_mouse) { draggable_item_rect.X = (int)mousePosition.X - 24; draggable_item_rect.Y = (int)mousePosition.Y - 24; for (int i = 0; i < pair_list.Count; i++) { if (item_icon_rects[pair_list[i].item_rect].Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_mouse_selected_item = pair_list[i].corr_item; } } if (main_hand_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 1; } if (off_hand_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 2; } if (over_armor_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 3; } if (under_armor_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 4; } if (helmet_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 5; } if (BGElement_equipmentTab.Contains((int)mousePosition.X, (int)mousePosition.Y)) { current_tab_selected = Current_Tab.Equipment; } if (BGElement_healthTab.Contains((int)mousePosition.X, (int)mousePosition.Y)) { current_tab_selected = Current_Tab.Injuries; } if (injSummary_scroll_up_max_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(-1000); } if (injSummary_scroll_up_one_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(-1); } if (injSummary_scroll_down_one_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(1); } if (injSummary_scroll_down_max_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(1000); } if (inv_left_scroll_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { item_start_index--; if (item_start_index < 0) { item_start_index = 0; } } if (inv_right_scroll_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { item_start_index++; if (item_start_index + number_of_items_shown >= player_inv.Count) { item_start_index = Math.Max(0, player_inv.Count - number_of_items_shown); } } } //On the hold, move the rectangle. if (is_holding_mouse) { draggable_item_rect.X = (int)mousePosition.X - 24; draggable_item_rect.Y = (int)mousePosition.Y - 24; } //On the release, try and equip the item. If it's a talisman and over another item //Try to add it to the item bool equipped_new_item = false; bool equipped_talisman = false; if (!is_holding_mouse && !is_click_mouse) { if (index_of_mouse_selected_item != -1) { if (player_inv[index_of_mouse_selected_item] is Talisman) { Talisman T = (Talisman)player_inv[index_of_mouse_selected_item]; Item attach_to = null; for (int i = 0; i < item_icon_rects.Count; i++) { if (check_overlap(item_icon_rects[i], draggable_item_rect) && i < player_inv.Count) { attach_to = player_inv[i]; } } if (check_overlap(main_hand_equip_slot, draggable_item_rect)) { attach_to = pl.show_main_hand(); } else if (check_overlap(off_hand_equip_slot, draggable_item_rect)) { attach_to = pl.show_off_hand(); } else if (check_overlap(helmet_equip_slot, draggable_item_rect)) { attach_to = pl.show_helmet(); } else if (check_overlap(over_armor_equip_slot, draggable_item_rect)) { attach_to = pl.show_over_armor(); } else if (check_overlap(under_armor_equip_slot, draggable_item_rect)) { attach_to = pl.show_under_armor(); } if (attach_to != null && (attach_to is Armor || attach_to is Scroll || attach_to is Weapon)) { if (attach_to is Armor && T.armor_talisman() && attach_to.can_add_talisman(T)) { attach_to.add_talisman(T); equipped_talisman = true; } else if ((attach_to is Weapon || attach_to is Scroll) && !T.armor_talisman() && attach_to.can_add_talisman(T)) { attach_to.add_talisman(T); equipped_talisman = true; } if (equipped_talisman) { player_inv.RemoveAt(index_of_mouse_selected_item); } } } if (check_overlap(main_hand_equip_slot, draggable_item_rect) && !equipped_new_item && !equipped_talisman) { if (player_inv[index_of_mouse_selected_item] is Weapon) { pl.equip_main_hand((Weapon)player_inv[index_of_mouse_selected_item]); equipped_new_item = true; } } if (check_overlap(off_hand_equip_slot, draggable_item_rect) && !equipped_new_item && !equipped_talisman) { if (player_inv[index_of_mouse_selected_item] is Weapon) { pl.equip_off_hand((Weapon)player_inv[index_of_mouse_selected_item]); equipped_new_item = true; } } for (int i = 0; i < armor_equip_slots.Count; i++) { if (check_overlap(armor_equip_slots[i], draggable_item_rect) && !equipped_new_item && !equipped_talisman) { if (player_inv[index_of_mouse_selected_item] is Armor) { pl.equip_armor((Armor)player_inv[index_of_mouse_selected_item]); equipped_new_item = true; } } } //spot to check if I should put it in the icobar bool done = false; for (int i = 0; i < the_icoBar.get_number_of_icons(); i++) { if (check_overlap(the_icoBar.get_ico_rects_by_slot(i), draggable_item_rect) && !done) { the_icoBar.assign_id_number_to_slot(player_inv[index_of_mouse_selected_item].get_my_IDno(), i); the_icoBar.assign_icon_to_slot(player_inv[index_of_mouse_selected_item].get_my_texture(), i); if (player_inv[index_of_mouse_selected_item] is Potion) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Potion, i); } else if (player_inv[index_of_mouse_selected_item] is Armor) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); } else if (player_inv[index_of_mouse_selected_item] is Weapon) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Weapon, i); } else if (player_inv[index_of_mouse_selected_item] is Scroll) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Scroll, i); } the_icoBar.update_cooldown_and_quant(pl); done = true; } } } if (index_of_c_equipped_selected_item != -1) { //try to put it back in the inventory. It will go back in on any item rect slot for (int i = 0; i < item_icon_rects.Count; i++) { if (check_overlap(item_icon_rects[i], draggable_item_rect)) { //Do something depending on the slot. switch (index_of_c_equipped_selected_item) { case 1: pl.unequip(Player.Equip_Slot.Mainhand); equipped_new_item = true; break; case 2: pl.unequip(Player.Equip_Slot.Offhand); equipped_new_item = true; break; case 3: pl.unequip(Player.Equip_Slot.Overarmor); equipped_new_item = true; break; case 4: pl.unequip(Player.Equip_Slot.Underarmor); equipped_new_item = true; break; case 5: pl.unequip(Player.Equip_Slot.Helmet); equipped_new_item = true; break; } } } bool done = false; for (int i = 0; i < the_icoBar.get_number_of_icons(); i++) { if (check_overlap(the_icoBar.get_ico_rects_by_slot(i), draggable_item_rect) && !done) { switch (index_of_c_equipped_selected_item) { case 1: the_icoBar.assign_id_number_to_slot(pl.show_main_hand().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_main_hand().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Weapon, i); done = true; break; case 2: the_icoBar.assign_id_number_to_slot(pl.show_off_hand().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_off_hand().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Weapon, i); done = true; break; case 3: the_icoBar.assign_id_number_to_slot(pl.show_over_armor().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_over_armor().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); done = true; break; case 4: the_icoBar.assign_id_number_to_slot(pl.show_under_armor().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_under_armor().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); done = true; break; case 5: the_icoBar.assign_id_number_to_slot(pl.show_helmet().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_helmet().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); done = true; break; } the_icoBar.update_cooldown_and_quant(pl); } } } if (equipped_new_item || equipped_talisman) { update_player_info(ref pl); } index_of_mouse_selected_item = -1; index_of_c_equipped_selected_item = -1; } bad_turn = equipped_new_item; if (String.Compare(pl.my_chara_as_string(), "Halephon") == 0) { bad_turn = false; } }
//There's gonna have to be fonts and stuff here too for now, but this will be okay //FOR THE TIME BEING... public InvAndHealthScreen(Texture2D my_default_backTex, SpriteFont smallFont, SpriteFont largeFont, SpriteFont pname_font, ref ContentManager cm, ref IconBar s_icoBar) { cManager = cm; visible = false; mode = 0; section_titleFont = largeFont; stdFont = smallFont; player_name_font = pname_font; my_size = new Rectangle(my_xPosition, my_yPosition, width, height); BGElement_portraitBackground = new Rectangle(my_xPosition + ptBG_xPos, my_yPosition + ptBG_yPos, ptBG_width, ptBG_height); int player_portrait_xpos = my_xPosition + ptBG_xPos + BGElement_portraitBackground.Width - plPT_width_height - 10; int player_portrait_ypos = my_yPosition + ptBG_yPos + 10; BGElement_playerPortrait = new Rectangle(player_portrait_xpos, player_portrait_ypos, plPT_width_height, plPT_width_height); player_name_pos = new Vector2(my_xPosition + ptBG_xPos + 10, my_yPosition + ptBG_yPos + 10); goldmsg_pos = new Vector2(player_name_pos.X, player_name_pos.Y + player_name_font.LineSpacing + 5); BGElement_backpackBackground = new Rectangle(my_xPosition + bpbBG_xPos, my_yPosition + bpbBG_yPos, bpbBG_width, bpbBG_height); inj_title = "Health:"; equips_title = "Armor:"; //Equip stuff //equip_start_X = my_xPosition + ptBG_xPos + ptBG_width + esbBG_xPos; //equip_start_Y = my_yPosition + esbBG_yPos; //Rectangles for various equip slots. int e_rects_start_Y = my_yPosition + ptBG_yPos; main_hand_equip_slot = new Rectangle(my_xPosition + ptBG_xPos + 10, e_rects_start_Y + 225, 48, 48); off_hand_equip_slot = new Rectangle(my_xPosition + ptBG_xPos + 140, e_rects_start_Y + 225, 48, 48); over_armor_equip_slot = new Rectangle(my_xPosition + ptBG_xPos + ((ptBG_width - 48) / 2), e_rects_start_Y + 180, 48, 48); under_armor_equip_slot = new Rectangle(my_xPosition + ptBG_xPos + ((ptBG_width - 48) / 2), e_rects_start_Y + 250, 48, 48); helmet_equip_slot = new Rectangle(my_xPosition + ptBG_xPos + ((ptBG_width - 48) / 2), e_rects_start_Y + 115, 48, 48); draggable_item_rect = new Rectangle(0, 0, 48, 48); index_of_mouse_selected_item = -1; armor_equip_slots = new List <Rectangle>(); armor_equip_slots.Add(over_armor_equip_slot); armor_equip_slots.Add(under_armor_equip_slot); armor_equip_slots.Add(helmet_equip_slot); //Tab system. Better than the other stuff. current_tab_selected = Current_Tab.Equipment; ctab_xPos = my_xPosition + ptBG_xPos + ptBG_width + 10; ctab_yPos = my_yPosition + 40; BGElement_ctabBackground = new Rectangle(ctab_xPos, ctab_yPos, ctab_width, ctab_height); ctab_msg_pos = new Vector2(BGElement_ctabBackground.X + 10, BGElement_ctabBackground.Y + 10); //Tab 1 + related things. BGElement_equipmentTab = new Rectangle(ctab_xPos, ctab_yPos - 30, 20 + (int)stdFont.MeasureString(equips_title).X, tab_index_height); equip_title_pos = new Vector2(BGElement_equipmentTab.X + 10, BGElement_equipmentTab.Y + 10); equip_msg_start_index = 0; //Tab 2 + related things. int h_tab_start_X = ctab_xPos + BGElement_equipmentTab.Width + 10; BGElement_healthTab = new Rectangle(h_tab_start_X, ctab_yPos - 30, 20 + (int)stdFont.MeasureString(inj_title).X, tab_index_height); inj_title_pos = new Vector2(BGElement_healthTab.X + 10, BGElement_healthTab.Y + 10); //General tab stuff inj_start_index = 0; total_messages_shown = (int)((BGElement_ctabBackground.Height - 10) / stdFont.LineSpacing); //Scrollbox options. int scrollElements_x = ctab_xPos + BGElement_ctabBackground.Width - 20; int spacing = 4; int first_y = BGElement_ctabBackground.Y + spacing; int second_y = BGElement_ctabBackground.Y + 18 + (spacing * 2); int third_y = BGElement_ctabBackground.Y + BGElement_ctabBackground.Height - 18 - spacing; int fourth_y = BGElement_ctabBackground.Y + BGElement_ctabBackground.Height - (18 * 2) - (spacing * 2); injSummary_scroll_up_max_rect = new Rectangle(scrollElements_x, first_y, 18, 18); injSummary_scroll_up_one_rect = new Rectangle(scrollElements_x, second_y, 18, 18); injSummary_scroll_down_max_rect = new Rectangle(scrollElements_x, third_y, 18, 18); injSummary_scroll_down_one_rect = new Rectangle(scrollElements_x, fourth_y, 18, 18); //Item stuff item_start_position = new Vector2(my_xPosition + bpbBG_xPos + 40, my_yPosition + bpbBG_yPos + 10); Vector2 item_start_position2 = new Vector2(item_start_position.X, item_start_position.Y); item_icon_rects = new List <Rectangle>(); pair_list = new List <rect_inv_item_pair>(); for (int i = item_start_index; i < number_of_items_shown; i++) { item_icon_rects.Add(new Rectangle((int)item_start_position2.X, (int)item_start_position2.Y, 48, 48)); item_start_position2.X += 60; } inv_left_scroll_rect = new Rectangle(my_xPosition + bpbBG_xPos + 10, my_yPosition + bpbBG_yPos + 10, 16, 48); inv_right_scroll_rect = new Rectangle(my_xPosition + bpbBG_width - 26, my_yPosition + bpbBG_yPos + 10, 16, 48); my_dark_color = new Color(0, 0, 0); my_grey_color = new Color(100, 100, 100); my_red_color = new Color(255, 0, 0); my_text_color = new Color(255, 255, 255); my_d_grey_color = new Color(70, 70, 70); my_back_texture = my_default_backTex; my_back_texture.SetData(new[] { Color.White }); pl_injury_report = new List <string>(); the_icoBar = s_icoBar; }