• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

 Code completion changes/additions proposal

gnysek

Member
I'm using GMS2 for more than 4 months now, so I'm very happy that it have better code completion now, but there are some things I think can be changed, having some experience with other companies IDEs for programming.
  1. All resources are also displayed as "variables" in code completion window, if they were mentioned in code at least once. Which causes duplicates (this is probably a bug):
    code-duplicates.png
  2. All variables defined in objects are visible in all other objects and scripts. This is bad, as the more objects you have with similar variable names, the longer "completion" list will be, even in scripts:
    in-script-variables.png
  3. Variables in completion code should be only ones from "current" object in most case. I know that @rwkay or @Mike already said, that it is hard to achieve, as you can define variables anywhere in GMS, but in fact there are some "good rules" what you can avoid, and I don't see why parsing variable names can skip "bad practices" for variable definitions (it would have even some educational benefit):
    - variables should be created before they are used, or it will cause a fatal error, so the best place to it is always "Create event", as otherwise it's really easy to crash game. Other variable definitions within same object may not be counted to variable definitions by code editor (except temporary "var" of course, which works great now).
    - if not keeping rules above, cause they are too strict, we may keep the rule, that all variables after which equal sign (=) is posted, and aren't in one of: with-block/if-block/instance reference (xxxx.var_name) could be marked as "object local variables".
  4. Having rule about, while in "with" block and object name is directly given, or using instance reference, variables from it could show variables from this object. Additionaly, there could be special JDOC reference
    Code:
    with (my_variable) {
    /// @var my_variable object_0
    }
    which will tell to this block what kind of variable may be hidden under this variable (even if it will be instance_id, not object_id). Also, writing "other." in with scope would again mean main object. Also, having syntax mentioned above, you can mark any variable in current scope to behave like it's directly typed object_name assigned to it
  5. Again, having rule 3) in mind, while in "collision event", an word "other." would point directly to same object that is said to be used in this event.
  6. "var" variables shouldn't be shown in completion code in lines before they definitions.
  7. Having indented code and pressing backspace could remove all spaces between last line and current one, not just move remove character in front of cursor (so it will move code to previous line):
    backspace-proposal.png
  8. There could be "filter" buttons in code completion, so you can hide some results (for example all sounds, or sprites, or build-in functions), when having too much of them.
  9. Shortcut to display function/script arguments OVER current line - helpful especially on workspaces, where sometimes editor footer is outside of view. Prefarably Ctrl+P cause I've saw this shortcut in several IDEs (Ctrl-K then Ctrl+I in Visual Studio if I remember correctly for Quick info, or Ctrl+Shift+Space for Parameter Info):
    code-arguments.png
  10. Ctrl+{ and Ctrl+} could go to next opening/ending bracket in current block code.
  11. And of course code folding, but it was already said by Mike, that there should be something like Visual Studio "regions" at some point, but probably no folding on if/else etc. I'm just mentioning it so people wouldn't propose it again here :)
Thanks.
 

rwkay

GameMaker Staff
GameMaker Dev.
OK I will try to address these

1. Yes this is a bug, please report it as such and I will fix it
2. That is GML for you... not going to change that
3. This is not something I plan on doing, conceptually it is simple but in practice it is much more complicated (I will add it to my consider list, as it requires following script references and extensions to work out what should be available for a particular object, also needs to track parent / child relationships and of course instance_change blows all that out of the water) I am not sure it is worth the effort.
The list getting bigger all the time is a good indication that the complexity of the code is reaching a critical mass and standardising some names may be a good idea.
4. No not getting into that kind of thing in GML, not a big fan of the hinting that JSDoc has started doing for things the compiler should be doing (oh yes... JS has no compiler)
5. OK 3 is not happening so neither will this
6. unlike C++ or C# var variables are still available above the var declaration (they are in scope everywhere in the function i.e.

a = 5;
var a;

still means that the first a is local (not an instance variable), this is true in Javascript as well.

7. Please no... though CTRL+Backspace should do something like that (and may do, I have not checked)
8. Not a bad idea, please file as a suggestion
9. This is my suggestion too (though I also like an XCode style showing it just below like Intellisense)
10. Not a bad idea, please file as a suggestion
11. Already said that it is coming...

Russell
 

Jobo

Member
GMC Elder
If you want to prioritise certain resources in Go To, just type the resource as part of the search query "sprite spr_some" (in most cases your resource naming conventions alone will be enough). A filter requiring mouse interactions will not be added to Go To unless its functionality expands greatly beyond its current scope.
 

gnysek

Member
If you want to prioritise certain resources in Go To, just type the resource as part of the search query "sprite spr_some" (in most cases your resource naming conventions alone will be enough). A filter requiring mouse interactions will not be added to Go To unless its functionality expands greatly beyond its current scope.
Yeah, it will show "spr_some" on first row, but then all other sprites too. And other resources with word sprite. It's more like "sprite OR spr_some", and searches in both name and type.
 

Jobo

Member
GMC Elder
That doesn't matter. Go To put your result at the top, which is its job - to find desired results given an input query. If your desired result is the first item displayed, simply press Enter and this resource will be opened. If it's the second item, press the down arrow and then press Enter. Or type a more accurate input query. etc. etc. etc. It doesn't need to hide anything you don't want (but also match the input query in some way), when it already shows what you want before anything else - it's extra work for no gain.
 

gnysek

Member
Yeeees. May be. I was just thinking that writing this functionality in one place may then be used again in another easily.
 
Top