diff --git a/rsrc/graphics.exd/mac/cursors/E.gif b/rsrc/graphics.exd/mac/cursors/E.gif index fa105e7a..fbea2972 100644 Binary files a/rsrc/graphics.exd/mac/cursors/E.gif and b/rsrc/graphics.exd/mac/cursors/E.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/N.gif b/rsrc/graphics.exd/mac/cursors/N.gif index ecb291c3..fb4d5f87 100644 Binary files a/rsrc/graphics.exd/mac/cursors/N.gif and b/rsrc/graphics.exd/mac/cursors/N.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/NE.gif b/rsrc/graphics.exd/mac/cursors/NE.gif index 777cb8af..7a18e2c2 100644 Binary files a/rsrc/graphics.exd/mac/cursors/NE.gif and b/rsrc/graphics.exd/mac/cursors/NE.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/NW.gif b/rsrc/graphics.exd/mac/cursors/NW.gif index 68df212c..3ff0c072 100644 Binary files a/rsrc/graphics.exd/mac/cursors/NW.gif and b/rsrc/graphics.exd/mac/cursors/NW.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/READ_BEFORE_EDITING.txt b/rsrc/graphics.exd/mac/cursors/READ_BEFORE_EDITING.txt new file mode 100644 index 00000000..ebba114f --- /dev/null +++ b/rsrc/graphics.exd/mac/cursors/READ_BEFORE_EDITING.txt @@ -0,0 +1,10 @@ +When editing the GIF files in this folder, you need to be aware how the hotspot is stored. +Each of these GIF files encodes the cursor's hotspot into a GIF comment with the following +syntax (case-sensitive): + + Hotspot(x,y) + +where x and y are substituted with the actual integer coordinates. There should be no extra +spaces anywhere in that. (However, anything after the closing parenthesis will be ignored.) + +If you edit any of these images, be sure to update the hotspot if necessary! diff --git a/rsrc/graphics.exd/mac/cursors/S.gif b/rsrc/graphics.exd/mac/cursors/S.gif index 4b539496..40d51956 100644 Binary files a/rsrc/graphics.exd/mac/cursors/S.gif and b/rsrc/graphics.exd/mac/cursors/S.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/SE.gif b/rsrc/graphics.exd/mac/cursors/SE.gif index 1555061c..e9b89a2c 100644 Binary files a/rsrc/graphics.exd/mac/cursors/SE.gif and b/rsrc/graphics.exd/mac/cursors/SE.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/SW.gif b/rsrc/graphics.exd/mac/cursors/SW.gif index 4647059c..2bc05444 100644 Binary files a/rsrc/graphics.exd/mac/cursors/SW.gif and b/rsrc/graphics.exd/mac/cursors/SW.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/W.gif b/rsrc/graphics.exd/mac/cursors/W.gif index 68b8b0c5..456d6a44 100644 Binary files a/rsrc/graphics.exd/mac/cursors/W.gif and b/rsrc/graphics.exd/mac/cursors/W.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/boot.gif b/rsrc/graphics.exd/mac/cursors/boot.gif index 71fd1322..81bc8dc3 100644 Binary files a/rsrc/graphics.exd/mac/cursors/boot.gif and b/rsrc/graphics.exd/mac/cursors/boot.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/bottomright.gif b/rsrc/graphics.exd/mac/cursors/bottomright.gif index 6fc74f28..1dc0c848 100644 Binary files a/rsrc/graphics.exd/mac/cursors/bottomright.gif and b/rsrc/graphics.exd/mac/cursors/bottomright.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/brush.gif b/rsrc/graphics.exd/mac/cursors/brush.gif index 51461c31..f54b218d 100644 Binary files a/rsrc/graphics.exd/mac/cursors/brush.gif and b/rsrc/graphics.exd/mac/cursors/brush.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/drop.gif b/rsrc/graphics.exd/mac/cursors/drop.gif index da032da1..9fe48830 100644 Binary files a/rsrc/graphics.exd/mac/cursors/drop.gif and b/rsrc/graphics.exd/mac/cursors/drop.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/eraser.gif b/rsrc/graphics.exd/mac/cursors/eraser.gif index d6a515b7..605bc2fa 100644 Binary files a/rsrc/graphics.exd/mac/cursors/eraser.gif and b/rsrc/graphics.exd/mac/cursors/eraser.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/eyedropper.gif b/rsrc/graphics.exd/mac/cursors/eyedropper.gif index 1427b7fd..2b20df61 100644 Binary files a/rsrc/graphics.exd/mac/cursors/eyedropper.gif and b/rsrc/graphics.exd/mac/cursors/eyedropper.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/hand.gif b/rsrc/graphics.exd/mac/cursors/hand.gif index da032da1..9fe48830 100644 Binary files a/rsrc/graphics.exd/mac/cursors/hand.gif and b/rsrc/graphics.exd/mac/cursors/hand.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/key.gif b/rsrc/graphics.exd/mac/cursors/key.gif index bc565c0f..1d9cff10 100644 Binary files a/rsrc/graphics.exd/mac/cursors/key.gif and b/rsrc/graphics.exd/mac/cursors/key.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/look.gif b/rsrc/graphics.exd/mac/cursors/look.gif index 8aacc4ea..9e77b9f5 100644 Binary files a/rsrc/graphics.exd/mac/cursors/look.gif and b/rsrc/graphics.exd/mac/cursors/look.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/spraycan.gif b/rsrc/graphics.exd/mac/cursors/spraycan.gif index 27ac2cde..5bf1bbc5 100644 Binary files a/rsrc/graphics.exd/mac/cursors/spraycan.gif and b/rsrc/graphics.exd/mac/cursors/spraycan.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/sword.gif b/rsrc/graphics.exd/mac/cursors/sword.gif index 046de790..f2586836 100644 Binary files a/rsrc/graphics.exd/mac/cursors/sword.gif and b/rsrc/graphics.exd/mac/cursors/sword.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/talk.gif b/rsrc/graphics.exd/mac/cursors/talk.gif index f0d27572..36378bd1 100644 Binary files a/rsrc/graphics.exd/mac/cursors/talk.gif and b/rsrc/graphics.exd/mac/cursors/talk.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/target.gif b/rsrc/graphics.exd/mac/cursors/target.gif index cfbb23ab..bf6f891d 100644 Binary files a/rsrc/graphics.exd/mac/cursors/target.gif and b/rsrc/graphics.exd/mac/cursors/target.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/topleft.gif b/rsrc/graphics.exd/mac/cursors/topleft.gif index b1078f12..ee556cd2 100644 Binary files a/rsrc/graphics.exd/mac/cursors/topleft.gif and b/rsrc/graphics.exd/mac/cursors/topleft.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/wait.gif b/rsrc/graphics.exd/mac/cursors/wait.gif index 92ca31e1..56febfaa 100644 Binary files a/rsrc/graphics.exd/mac/cursors/wait.gif and b/rsrc/graphics.exd/mac/cursors/wait.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/wand.gif b/rsrc/graphics.exd/mac/cursors/wand.gif index 725acd72..a8b9d67e 100644 Binary files a/rsrc/graphics.exd/mac/cursors/wand.gif and b/rsrc/graphics.exd/mac/cursors/wand.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/watch.gif b/rsrc/graphics.exd/mac/cursors/watch.gif index 0fe98eae..d01786ad 100644 Binary files a/rsrc/graphics.exd/mac/cursors/watch.gif and b/rsrc/graphics.exd/mac/cursors/watch.gif differ diff --git a/src/tools/resmgr/restypes.hpp b/src/tools/resmgr/restypes.hpp index 6940cc2c..8ad44349 100644 --- a/src/tools/resmgr/restypes.hpp +++ b/src/tools/resmgr/restypes.hpp @@ -42,43 +42,54 @@ namespace ResMgr { } /// Load a cursor from a GIF file. - /// The cursor's hotspot location is stored in a .hot file, as plaintext: - /// simply the X value followed by the Y value, separated by whitespace. + /// The cursor's hotspot location is stored in a GIF comment, with the following syntax (case-sensitive): + /// "Hotspot(x,y)" template<> inline CursorRsrc* resLoader::operator() (std::string fname) { - // TODO: Store the hotspots on disk instead of hardcoded here - static const std::map cursor_hs = { - {"wand", {4, 1}}, {"eyedropper", {1, 14}}, {"brush", {5, 13}}, {"spraycan", {8, 8}}, - {"eraser", {8, 8}}, {"topleft", {8, 8}}, {"bottomright", {8, 8}}, {"hand", {14, 0}}, - {"NW", {3, 3}}, {"N", {9, 3}}, {"NE", {12, 3}}, - {"W", {2, 7}}, {"wait", {8, 8}}, {"E", {14, 7}}, - {"SW", {3, 12}}, {"S", {9, 12}}, {"SE", {12, 12}}, - {"sword", {1, 1}}, {"boot", {2, 6}}, {"drop", {14, 0}}, {"target", {8, 8}}, - {"talk", {2, 13}}, {"key", {3, 2}}, {"look", {7, 6}}, {"watch", {8,8}}, - }; fs::path fpath = resPool::rel2abs(fname + ".gif"); - fs::path hotpath = resPool::rel2abs(fname + ".hot"); - int x = 0, y = 0; - if(fs::exists(hotpath)) { - std::ifstream fin(hotpath.c_str()); - fin >> x >> y; - fin.close(); - } else { - auto entry = cursor_hs.find(fname); - if(entry == cursor_hs.end()) - std::cerr << "Cursor hotspot missing: " << fname << std::endl; - else { - std::cerr << "Cursor hotspot missing (using fallback value): " << fname << std::endl; - location hs = entry->second; - x = hs.x; y = hs.y; + if(!fs::exists(fpath)) + throw xResMgrErr("Failed to load GIF cursor: " + fname); + int x = 0, y = 0, f_sz; + std::ifstream fin(fpath.c_str(), std::ios::binary); + fin.seekg(0, std::ios::end); + f_sz = fin.tellg(); + fin.clear(); + fin.seekg(0, std::ios::beg); + bool found_hotspot = false; + while(fin && !found_hotspot) { + unsigned char c = fin.get(); + if(c != 0x21) continue; + c = fin.get(); + if(c != 0xfe) continue; + // If we get here, we've probably found a GIF comment + std::string str; + int count; + found_hotspot = true; + do { + count = fin.get(); + if(count + fin.tellg() >= f_sz) { + found_hotspot = false; + break; + } + std::copy_n(std::istream_iterator(fin), count, std::back_inserter(str)); + } while(count > 0); + if(found_hotspot) { + if(str.substr(0,7) == "Hotspot") { + size_t open_paren = str.find_first_of('('), comma = str.find_first_of(','), close_paren = str.find_first_of(')'); + std::string x_str = str.substr(open_paren + 1, comma - open_paren - 1); + std::string y_str = str.substr(comma + 1, close_paren - comma - 1); + x = std::stoi(x_str); + y = std::stoi(y_str); + } else found_hotspot = false; } } + if(!found_hotspot) + std::cerr << "Cursor hotspot missing: " << fname << std::endl; // TODO: Handle errors? CursorRsrc* cur = new Cursor(fpath.string(),x,y); return cur; - throw xResMgrErr("Failed to load GIF cursor: " + fname); } - /// Load a font form a TTF file. + /// Load a font from a TTF file. template<> inline FontRsrc* resLoader::operator() (std::string fname) { fs::path fpath = resPool::rel2abs(fname + ".ttf"); FontRsrc* theFont = new FontRsrc;