draw and give tooltips for more map features

This commit is contained in:
2025-08-06 13:45:40 -05:00
parent b64f5fc814
commit a5cc323f00
5 changed files with 86 additions and 20 deletions

View File

@@ -600,3 +600,15 @@ void alter_space(short i,short j,ter_num_t ter) {
univ.town->set_up_lights();
}
}
bool vehicle_is_here(const cVehicle& vehicle) {
if(!vehicle.exists) return false;
if(is_out()){
location party_sector = univ.party.outdoor_corner;
party_sector.x += univ.party.i_w_c.x;
party_sector.y += univ.party.i_w_c.y;
return vehicle.which_town == 200 && vehicle.sector == party_sector;
}else{
return vehicle.which_town == univ.party.town_num;
}
}

View File

@@ -1,6 +1,7 @@
#include <functional>
#include "location.hpp"
#include "vehicle.hpp"
bool is_explored(short i,short j);
void make_explored(short i,short j);
@@ -43,3 +44,5 @@ location push_loc(location from_where,location to_where);
bool spot_impassable(short i,short j);
void swap_ter(short i,short j,ter_num_t ter1,ter_num_t ter2);
void alter_space(short i,short j,ter_num_t ter);
// Whether a vehicle is in the current town/outdoor section shown on the map
bool vehicle_is_here(const cVehicle& vehicle);

View File

@@ -1456,12 +1456,43 @@ void handle_one_minimap_event(const sf::Event& event) {
std::string tooltip_text = "";
if(is_explored(tile.x, tile.y)){
// Area rectangle hovered
const std::vector<info_rect_t>& area_desc = is_out() ? univ.out->area_desc : univ.town->area_desc;
for(info_rect_t area : area_desc){
if(area.contains(tile)){
tooltip_text += area.descr + " |";
}
}
// Sign hovered
const std::vector<sign_loc_t>& sign_locs = is_out() ? univ.out->sign_locs : univ.town->sign_locs;
for(sign_loc_t sign : sign_locs){
if(sign == tile){
tooltip_text += "Sign: " + sign.text + " |";
}
}
// Town entrance hovered
if(is_out()){
const std::vector<spec_loc_t>& city_locs = univ.out->city_locs;
for(spec_loc_t city : city_locs){
if(city == tile){
tooltip_text += univ.scenario.towns[city.spec]->name + " |";
}
}
}
// Vehicle hovered
for(auto& boat : univ.party.boats) {
if(!vehicle_is_here(boat)) continue;
if(boat.loc == tile){
tooltip_text += (boat.property ? "Boat (Not Yours)" : "Your Boat");
}
}
for(auto& horse : univ.party.horses) {
if(!vehicle_is_here(horse)) continue;
if(horse.loc == tile){
tooltip_text += (horse.property ? "Horses (Not Yours)" : "Your Horses");
}
}
}
if(tooltip_text != last_tooltip_text)
draw_map(false, tooltip_text);

View File

@@ -62,7 +62,7 @@ location town_force_loc;
bool shop_button_active[12];
rectangle map_title_rect = {3,50,15,300};
rectangle map_bar_rect = {15,50,27,300};
rectangle map_tooltip_rect = {270,50,307,350};
rectangle map_tooltip_rect = {270,50,307,300};
void force_town_enter(short which_town,location where_start) {
town_force = which_town;
@@ -1510,37 +1510,56 @@ void draw_map(bool need_refresh, std::string tooltip_text) {
if(canMap) {
rect_draw_some_item(map_gworld().getTexture(),the_rect,mini_map(),area_to_draw_on);
auto mark_loc = [view_rect, &draw_rect, area_to_draw_on](location where, sf::Color inner, sf::Color outer) -> void {
if((is_explored(where.x,where.y)) &&
((where.x >= view_rect.left) && (where.x < view_rect.right)
&& where.y >= view_rect.top && where.y < view_rect.bottom)){
draw_rect.left = area_to_draw_on.left + 6 * (where.x - view_rect.left);
draw_rect.top = area_to_draw_on.top + 6 * (where.y - view_rect.top);
draw_rect.right = draw_rect.left + 6;
draw_rect.bottom = draw_rect.top + 6;
fill_rect(mini_map(), draw_rect, inner);
frame_circle(mini_map(), draw_rect, outer);
}
};
// Now place PCs and monsters
if(draw_pcs) {
if((is_town()) && (univ.party.status[ePartyStatus::DETECT_LIFE] > 0))
for(short i = 0; i < univ.town.monst.size(); i++)
if(univ.town.monst[i].is_alive()) {
where = univ.town.monst[i].cur_loc;
if((is_explored(where.x,where.y)) &&
((where.x >= view_rect.left) && (where.x < view_rect.right)
&& where.y >= view_rect.top && where.y < view_rect.bottom)){
draw_rect.left = area_to_draw_on.left + 6 * (where.x - view_rect.left);
draw_rect.top = area_to_draw_on.top + 6 * (where.y - view_rect.top);
draw_rect.right = draw_rect.left + 6;
draw_rect.bottom = draw_rect.top + 6;
fill_rect(mini_map(), draw_rect, Colours::GREEN);
frame_circle(mini_map(), draw_rect, Colours::BLUE);
}
mark_loc(where, Colours::GREEN, Colours::BLUE);
}
if((overall_mode != MODE_SHOPPING) && (overall_mode != MODE_TALKING)) {
where = (is_town()) ? univ.party.town_loc : global_to_local(univ.party.out_loc);
draw_rect.left = area_to_draw_on.left + 6 * (where.x - view_rect.left);
draw_rect.top = area_to_draw_on.top + 6 * (where.y - view_rect.top);
draw_rect.right = draw_rect.left + 6;
draw_rect.bottom = draw_rect.top + 6;
fill_rect(mini_map(), draw_rect, Colours::RED);
frame_circle(mini_map(), draw_rect, sf::Color::Black);
mark_loc(where, Colours::RED, Colours::BLACK);
}
}
// Draw signs
const std::vector<sign_loc_t>& sign_locs = is_out() ? univ.out->sign_locs : univ.town->sign_locs;
for(sign_loc_t sign : sign_locs){
mark_loc(sign, Colours::TRANSPARENT, Colours::YELLOW);
}
// Draw town entrances
if(is_out()){
const std::vector<spec_loc_t>& city_locs = univ.out->city_locs;
for(spec_loc_t city : city_locs){
mark_loc(city, Colours::TRANSPARENT, Colours::GREEN);
}
}
// Draw vehicles
for(auto& boat : univ.party.boats) {
if(!vehicle_is_here(boat)) continue;
mark_loc(boat.loc, Colours::MAROON, Colours::BLACK);
}
for(auto& horse : univ.party.horses) {
if(!vehicle_is_here(horse)) continue;
mark_loc(horse.loc, Colours::MAROON, Colours::BLACK);
}
}
win_draw_string(mini_map(), map_tooltip_rect,tooltip_text,eTextMode::WRAP,style);

View File

@@ -58,6 +58,7 @@ namespace Colours {
const sf::Color YELLOW { 0xff, 0xff, 0x31};
const sf::Color ORANGE { 0xff, 0x80, 0x00};
const sf::Color LIGHT_BLUE { 0xad, 0xd8, 0xe6 }; // Spell points on dark background
const sf::Color TRANSPARENT { 0x00, 0x00, 0x00, 0x00 };
// Text colours for shopping / talking
// TODO: The Windows version appears to use completely different colours?
const sf::Color SHADOW { 0x00, 0x00, 0x68}; // formerly c[3] QD colour = {0,0,26623} (shop/character name shadow, shop subtitle)