Anahkiasen / cookie-monster

A rehosted, cleaned up and updated version of the CookieMonster plugin.
31 stars 24 forks source link

Multiple fixes: Fix CM freeze, and issues with dynamic tooltips #45

Closed Qhorin closed 10 years ago

Qhorin commented 10 years ago

Please review. I familiarized myself with the code and made changes I thought appropriate, though I do not know if the changes have unintended consequences. FYI: I was unable to run grunt test. See #43

https://github.com/Qhorin/cookie-monster/commit/bf6a5f1c97afcfef085bd1a42adb3d22b5b33681 fixes the error "Uncaught TypeError: Cannot read property 'apply' of undefined". Cause: RebuildStore function was renamed RefreshStore.

https://github.com/Qhorin/cookie-monster/commit/bc273dd4b73cc6a46fb702a1fa5c8eee38c35282 fixes issue #41 and possibly #38. I just changed a "null" to "this". Debugging showed that when the Game.tooltip.draw function was called, the "this" was not what was expected. It was expecting it to be Game.tooltip, but it was something else. Maybe the Window itself? Adding "this" passed the Game.tooltip object to the draw function. This seems to have resolved the issue.

https://github.com/Qhorin/cookie-monster/commit/5c825d4e68933c819f9318a0d9f030063a914476 fixes an issue where Clicker HTML overwites CM tooltip HTML during each game loop. This issue caused CM tooltip to flash on and off repeatedly.

https://github.com/Qhorin/cookie-monster/commit/dc8e665d45d79a3d1cffa890067e7e10b757404d is a LARGER change. This is my proposed solution for dynamic tooltips for buildings. The Clicker code regenerates the tooltips every loop which overwrites some CM tooltip divs. The committed code intercepts the dynamic tooltip string, adds CM tooltip HTML, and returns the modified string to the Clicker code.

Also, it appears that my edits added a newline to the end of some files. Is that a problem?

Unaddressed issue: After applying all these fixes, and resetting my Clicker game, I noticed a new issue. Every time I buy a building, the Game.seasonPopup.reset() is called which resets the Reindeer timer. I don't think this was caused by the commits in this pull request because none of that code as modified. I also tried just applying the first 2 commits in the pull request just to get CM working. With these minimal changes, this issue still exists. I believe something else must have changed in the recent Cookie Clicker release. I don't yet have the understanding to fix this issue. I will open this up as on Issue on Github if this pull request is merged.

Anahkiasen commented 10 years ago

Looks good! Thanks for the hard work, the season issue if I recall was already there indeed. Newlines are not a problem.