Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Point and Vector string conversion operators #1552

Merged
merged 3 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions appOPHD/States/MapViewState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,19 @@ namespace

void pushAgingRobotMessage(const Robot* robot, const MapCoordinate& position, NotificationArea& notificationArea)
{
const auto robotLocationText = "(" + std::to_string(position.xy.x) + ", " + std::to_string(position.xy.y) + ")";

if (robot->fuelCellAge() == 190) // FIXME: magic number
{
notificationArea.push({
"Aging Robot",
"Robot '" + robot->name() + "' at location " + robotLocationText + " is approaching its maximum age.",
"Robot '" + robot->name() + "' at location " + std::string{position.xy} + " is approaching its maximum age.",
position,
NotificationArea::NotificationType::Warning});
}
else if (robot->fuelCellAge() == 195) // FIXME: magic number
{
notificationArea.push({
"Aging Robot",
"Robot '" + robot->name() + "' at location " + robotLocationText + " will fail in a few turns. Replace immediately.",
"Robot '" + robot->name() + "' at location " + std::string{position.xy} + " will fail in a few turns. Replace immediately.",
position,
NotificationArea::NotificationType::Critical});
}
Expand Down Expand Up @@ -1115,7 +1113,7 @@ void MapViewState::placeRobodigger(Tile& tile)
const auto position = tile.xy();
mNotificationArea.push({
"Mine destroyed",
"Digger destroyed a Mine at (" + std::to_string(position.x) + ", " + std::to_string(position.y) + ").",
"Digger destroyed a Mine at " + std::string{position} + ".",
tile.xyz(),
NotificationArea::NotificationType::Information});
mTileMap->removeMineLocation(position);
Expand Down Expand Up @@ -1293,20 +1291,18 @@ void MapViewState::updateRobots()

if (robot->isDead())
{
const auto robotLocationText = "(" + std::to_string(position.xy.x) + ", " + std::to_string(position.xy.y) + ")";

if (robot->selfDestruct())
{
mNotificationArea.push({
"Robot Self-Destructed",
robot->name() + " at location " + robotLocationText + " self destructed.",
robot->name() + " at location " + std::string{position.xy} + " self destructed.",
position,
NotificationArea::NotificationType::Critical
});
}
else if (robot->type() != Robot::Type::Miner)
{
const auto text = "Your " + robot->name() + " at location " + robotLocationText + " has broken down. It will not be able to complete its task and will be removed from your inventory.";
const auto text = "Your " + robot->name() + " at location " + std::string{position.xy} + " has broken down. It will not be able to complete its task and will be removed from your inventory.";
mNotificationArea.push({"Robot Broke Down", text, position, NotificationArea::NotificationType::Critical});
robot->abortTask(*tile);
}
Expand All @@ -1329,7 +1325,7 @@ void MapViewState::updateRobots()

mNotificationArea.push({
"Robot Task Completed",
robot->name() + " completed its task at (" + std::to_string(tile->xy().x) + ", " + std::to_string(tile->xy().y) + ").",
robot->name() + " completed its task at " + std::string{tile->xy()} + ".",
tile->xyz(),
NotificationArea::NotificationType::Success
});
Expand All @@ -1344,7 +1340,7 @@ void MapViewState::updateRobots()

mNotificationArea.push({
"Robot Task Canceled",
robot->name() + " canceled its task at (" + std::to_string(tile->xy().x) + ", " + std::to_string(tile->xy().y) + ").",
robot->name() + " canceled its task at " + std::string{tile->xy()} + ".",
tile->xyz(),
NotificationArea::NotificationType::Information
});
Expand Down
2 changes: 1 addition & 1 deletion appOPHD/UI/TileInspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void TileInspector::update()

position = mRect.position + NAS2D::Vector{5, 62};
const auto tilePosition = mTile->xy();
drawLabelAndValue(position, "Location: ", std::to_string(tilePosition.x) + ", " + std::to_string(tilePosition.y));
drawLabelAndValue(position, "Location: ", std::string{tilePosition});

position.y += 10;
drawLabelAndValue(position, "Terrain: ", terrainTypeStringTable.at(mTile->index()));
Expand Down