Commit graph

111 commits

Author SHA1 Message Date
bi
13727c1adc VMF Mod Data: got rid of 'is_togglable' and 'is_mutator' methods 2018-06-21 09:40:02 +03:00
bi
a172f72c0a VMF Mod Data: updated external change protection 2018-06-20 00:26:33 +03:00
bi
b5a9699bd8 VMF Mod Data: changed several comments 2018-06-19 17:38:17 +03:00
bi
391c1ca65f VMF Mod Data: refactoring, adding modification protection 2018-06-19 17:05:38 +03:00
bi
cb0e0b5585 Chat Actions: little style change 2018-06-19 17:02:30 +03:00
bi
15f7194629 Fixed error fest in mutators test file 2018-06-19 16:28:22 +03:00
bi
e0e519fbad Updated hooks definitions 2018-06-18 19:50:58 +03:00
bi
5b153657e7 VMF Options: fixed duplicated option's name in tooltip 2018-06-18 18:41:29 +03:00
bi
d825003301 Logging: fixed duplicating mod output in log 2018-06-18 18:36:01 +03:00
bi
1b5111d067 Safe Calls: moved to a separate file 2018-06-11 19:52:40 +03:00
bi
4824e6a5c8 Misc: little style changes 2018-06-11 19:51:49 +03:00
bi
4a6fb28b86 Renamed 'core_functions' to 'misc' 2018-06-11 19:36:30 +03:00
bi
315e45165d Logging: moved to a separate file 2018-06-11 18:58:40 +03:00
bi
e1f515e4ef Mutators: updated testing script 2018-06-11 15:20:18 +03:00
bi
a271e08f16 Mutators GUI: fixed dissapearing mutators while trying to scroll 2018-06-11 15:14:37 +03:00
Azumgi
4b890a616a
Merge pull request #14 from FireSiku/new_hooks
Delay disabling delayed hooks and fix a crash
2018-06-11 10:30:55 +03:00
FireSiku
8a13ec1bf9 Hooks's active status is based on mod's enabled status now.
Also, allow hook_enable and hook_disable to be delayed as well.
2018-06-11 03:15:44 -04:00
FireSiku
bee94c1665 Throw error if mod is trying to hook something that isnt a function 2018-06-10 20:35:49 -04:00
FireSiku
6b06745986 Only disable delaying when the state is set to Ingame. 2018-06-10 18:27:57 -04:00
Azumgi
32ce5e6fc9
Merge pull request #13 from FireSiku/events
Move event-checking logic inside run_event
2018-06-10 01:45:32 +03:00
Azumgi
4e9fc3a9c2
Merge pull request #9 from FireSiku/new_hooks
New Hook System
2018-06-10 01:45:12 +03:00
FireSiku
5f5ef1d317 Move event-checking logic inside run_event 2018-06-09 14:32:48 -04:00
bi
c4d5890f7e Events: reverted back 'update' behaviour for disabled mods 2018-06-09 20:56:38 +03:00
FireSiku
2f5bfd989a Spelling checks and logging updates 2018-06-09 13:53:34 -04:00
FireSiku
dd31894cd2 Safe hooks are now truly safe: Handler functions are xpcall'd 2018-06-08 19:13:00 -04:00
bi
7b4bba89c0 Commands: refactoring 2018-06-08 14:37:20 +03:00
bi
fcb0b570d8 Commands: fixed crash if description wasn't specified 2018-06-08 14:28:05 +03:00
bi
977ec7558f Commands: restricted command name to have only [a-z, A-Z, 0-9, _] chars 2018-06-08 13:29:49 +03:00
bi
f6c62a949a Mutators: little style changes 2018-06-08 12:03:23 +03:00
bi
a79d879de0 VMF Loader: little style changes 2018-06-08 11:20:47 +03:00
bi
b34a00d57f VMF Mod Manager: disabled compatibility with the old 'new_mod' structure 2018-06-08 11:17:12 +03:00
bi
1ee5beaa76 VMF Mod Manager: little style changes 2018-06-08 11:15:49 +03:00
FireSiku
0380e9f4a8 Adding small hook creation info log. 2018-06-08 03:01:28 -04:00
FireSiku
4af4cd5f75 Fix a few edge cases and correctly error if the function doesn't exist. 2018-06-08 01:56:26 -04:00
FireSiku
722bc35f60 Rename newhooks. 2018-06-07 23:12:33 -04:00
FireSiku
55ebff741b Removed old hooks.lua 2018-06-07 23:10:42 -04:00
FireSiku
007fabfae4 Some final changes that were discussed on discord.:rawhook has been renamed :hook_origin, making it a much better name.:after has been renamed :hook_safe.:before has been removed. 2018-06-07 23:02:39 -04:00
FireSiku
5287ce2569 Throw an error if it cannot find an object after everything is loaded.
The delayed hooking implementation didn't have a flag to say when to stop trying to delay hooks that do not exist.
2018-06-07 23:00:36 -04:00
FireSiku
fa393c4f78 Prevent creating multiple hooks on the same function using different API 2018-06-07 22:58:18 -04:00
FireSiku
099b9db187 Fix issue where hooks arent delayed properly.
Under certain conditions, get_object_from_string could return that a hook needs to be delayed, but also return nil instead of the string.
2018-06-07 22:37:47 -04:00
FireSiku
f195b10e7d Make sure to restore original functions when reloading vmf. 2018-06-07 22:37:47 -04:00
FireSiku
f6baeb4ccd Send function name instead of hook_type to generic functions.
This makes it much easier to give the function name in the error/warning messages and we can easily get the hook type based on function name.
Also, swap around enable_hook and similar function to hook_enable format to keep backward-compatibility with existing mods.
2018-06-07 19:33:17 -04:00
FireSiku
9d554418f4 Added generic_hook_toggle
Instead of having a single enable/disable_hook call that requires modders to know hook type IDs, make separate APIs for all types.
This also makes it much easier in the future to improve the system or handle new use case scenarios easily.
2018-06-07 19:32:05 -04:00
FireSiku
7a08f1c32b Refactor API to use generic function for argument checking/handling
A lot of the code ended up being duplicated between the four api calls,
on top of that some type handling checks had to be made in both create_hook and get_orig_function.
This lead to a very messy state of things, so combine all of the handling into a single function,
then we can proceed with the rest of the code expecting one thing.

Having a single entry point made it very easy to add support for delaying hook cleanly.

Also add support for "Obj.Method" notation for backward-compatibility with old hooks.
I initially tried to use string.split provided by fatshark's code, but it creates a table, and requires a lot of supporting code that is all avoided by using a simple string.sub call.
2018-06-07 18:10:59 -04:00
FireSiku
78a1f5cbc0 Replace old vmf hook system.
- Comment out the old hooks.lua
- Remove the HookMixin table in favor of using VMFMod.
- Update UIRenderer hook to adjust for changes in the new system.
2018-06-07 18:09:09 -04:00
FireSiku
be0e9075ef Add mod:enable/disable_all_hooks() 2018-06-07 18:08:29 -04:00
FireSiku
06b23556a3 Implementing new hook system.
Changes includes:
- No longer relies on any globals.
- No longer uses loadstrings, or recreate the hook chain frivolously.
- Adding :before() and :after() which will call the func before and after the function call.
- Added :rawhook() that imitate the old 'back' functionality, by replacing the original function at the "end" of the chain.

- Refactoring to only fetch original function once.
- Refactor to use a single internal _registry table.

- registry.hooks[hook_type] are now using metatable to automatically generate tables.
- Rawhooks now have their own specialized hooks, that will call the original if disabled.
- Make sure rawhooks are limited to one per function.

- No longer has the ability to overwrite hooks. We remove a table lookup from every hook call and make the code more straightforward.
- The functionality of overwriting a hook is not used in any mods. Any code that would require this can simply be written in a better way without bogging down the whole system for everyone.
2018-06-07 18:07:24 -04:00
bi
0439a66c45 Possible fix for not unloaded resources inside Guis on reloading 2018-06-07 13:51:59 +03:00
bi
14a6bdfa0f Persistent Tables: refactoring, added ability to set default table 2018-06-07 13:18:24 +03:00
FireSiku
d35060d57a Ignore the hook file since it will be changed soon. 2018-06-07 00:56:00 -04:00