summary refs log tree commit diff stats
path: root/wizard.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 11:46:24 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-11-04 11:46:24 -0500
commit8375f92802d3aa7667bfc6f22f6d2a72361c9808 (patch)
treebb706d3493d1ed7043387a3cb9e6a4d1897acba4 /wizard.cpp
parent460b99583bcf6da4462f13ad75856283849904e7 (diff)
downloadwizard-8375f92802d3aa7667bfc6f22f6d2a72361c9808.tar.gz
wizard-8375f92802d3aa7667bfc6f22f6d2a72361c9808.tar.bz2
wizard-8375f92802d3aa7667bfc6f22f6d2a72361c9808.zip
Websockets server!
Diffstat (limited to 'wizard.cpp')
-rw-r--r--wizard.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/wizard.cpp b/wizard.cpp index 1541fed..a1d7df4 100644 --- a/wizard.cpp +++ b/wizard.cpp
@@ -50,6 +50,10 @@ wizard::wizard(const cardset& cards, const imagestore& images, std::string text,
50 std::cout << std::endl; 50 std::cout << std::endl;
51} 51}
52 52
53void wizard::set_status_callback(status_callback_type callback) {
54 status_callback_ = callback;
55}
56
53Magick::Image wizard::run() { 57Magick::Image wizard::run() {
54 std::string text = text_; //"what the heck, it's just some gay guy"; 58 std::string text = text_; //"what the heck, it's just some gay guy";
55 // getline(std::cin, text); 59 // getline(std::cin, text);
@@ -58,6 +62,9 @@ Magick::Image wizard::run() {
58 } 62 }
59 63
60 std::cout << "Calculating card list..." << std::endl; 64 std::cout << "Calculating card list..." << std::endl;
65 if (status_callback_) {
66 status_callback_("Calculating card list...");
67 }
61 68
62 std::string canonText = hatkirby::lowercase(text); 69 std::string canonText = hatkirby::lowercase(text);
63 designer des(canonText, cards_.getTitles()); 70 designer des(canonText, cards_.getTitles());
@@ -76,10 +83,16 @@ Magick::Image wizard::run() {
76 << cardName.substr(u.strIndex + u.strLen) << std::endl; 83 << cardName.substr(u.strIndex + u.strLen) << std::endl;
77 84
78 std::cout << "Downloading image..." << std::endl; 85 std::cout << "Downloading image..." << std::endl;
86 if (status_callback_) {
87 status_callback_("Downloading image...");
88 }
79 89
80 Magick::Image cardImg = images_.get(theCard.uuid, theCard.imageUri); 90 Magick::Image cardImg = images_.get(theCard.uuid, theCard.imageUri);
81 91
82 std::cout << "Reading text..." << std::endl; 92 std::cout << "Reading text..." << std::endl;
93 if (status_callback_) {
94 status_callback_("Reading text...");
95 }
83 96
84 Magick::Image titleImg = cardImg; 97 Magick::Image titleImg = cardImg;
85 titleImg.magick("TIFF"); 98 titleImg.magick("TIFF");
@@ -139,9 +152,10 @@ Magick::Image wizard::run() {
139 152
140 size_t leadin = hatkirby::lowercase(lineStr).find( 153 size_t leadin = hatkirby::lowercase(lineStr).find(
141 hatkirby::lowercase((cardName))); 154 hatkirby::lowercase((cardName)));
142 if (leadin != std::string::npos) { 155 // if (leadin != std::string::npos)
156 {
143 foundName = true; 157 foundName = true;
144 extraChars = leadin; 158 // extraChars = leadin;
145 159
146 break; 160 break;
147 } /* else { 161 } /* else {