about summary refs log tree commit diff stats
path: root/lunatic.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-03-02 19:47:19 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-03-02 19:47:19 -0500
commit5b7bf82edb672d5d5dbd8b1de64532aeec695661 (patch)
tree7de8d174a75f06f0f11ed5f3de4e17e8e7912c2c /lunatic.cpp
parent13aab8498a0a2d4494a088f1235a0e80c078bdcf (diff)
downloadlunatic-5b7bf82edb672d5d5dbd8b1de64532aeec695661.tar.gz
lunatic-5b7bf82edb672d5d5dbd8b1de64532aeec695661.tar.bz2
lunatic-5b7bf82edb672d5d5dbd8b1de64532aeec695661.zip
Handled games with no images
For games where no images could be downloaded from Steam, which happens if a game has been removed from the store, the bot will now use a default background. This image is copyright Nintendo.
Diffstat (limited to 'lunatic.cpp')
-rw-r--r--lunatic.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/lunatic.cpp b/lunatic.cpp index 291bd09..58a0854 100644 --- a/lunatic.cpp +++ b/lunatic.cpp
@@ -65,9 +65,6 @@ int main(int argc, char** argv)
65 std::cout << "Generating tweet" << std::endl; 65 std::cout << "Generating tweet" << std::endl;
66 66
67 achievement ach = db.getRandomAchievement(); 67 achievement ach = db.getRandomAchievement();
68 std::string imageName = db.getRandomImageForGame(ach.gameId);
69 std::string imagePath = config["images"].as<std::string>()
70 + "/" + imageName;
71 68
72 Magick::Image moonColor; 69 Magick::Image moonColor;
73 moonColor.read("res/" + ach.color + ".png"); 70 moonColor.read("res/" + ach.color + ".png");
@@ -150,14 +147,25 @@ int main(int argc, char** argv)
150 shadow.negate(); 147 shadow.negate();
151 shadow.blur(0, 12); 148 shadow.blur(0, 12);
152 149
153 // Read the game image 150 // Read the game image, using a default if the game has no images
154 Magick::Image image; 151 Magick::Image image;
155 image.read(imagePath);
156 152
157 // Stretch and pixelate it 153 if (db.doesGameHaveImages(ach.gameId))
158 image.transform("1600x900!"); 154 {
159 image.scale("80x45"); 155 std::string imageName = db.getRandomImageForGame(ach.gameId);
160 image.scale("1600x900"); 156 std::string imagePath = config["images"].as<std::string>()
157 + "/" + imageName;
158
159 image.read(imagePath);
160
161 // Stretch and pixelate it
162 image.transform("1600x900!");
163 image.scale("80x45");
164 image.scale("1600x900");
165 } else {
166 image.read("res/default.png");
167 image.transform("1600x900!");
168 }
161 169
162 // Add the generated overlay to it 170 // Add the generated overlay to it
163 image.composite(shadow, 0, 0, Magick::OverCompositeOp); 171 image.composite(shadow, 0, 0, Magick::OverCompositeOp);