It is currently 16 Apr 2024, 23:47
   
Text Size

New Filters

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

New Filters

Postby Seravy » 27 Jun 2017, 10:14

Completed my second goal, a quest mode filter for rating cards and filtering them based on user rating.
filter1.png

filter2.png

filter3.png


-Allows the player to rate their cards from 1 to 5 stars, effectively dividing them into 6 total categories (Unrated being the default) - the player can then use this for whatever purpose they want from marking unwanted cards to sell, or marking cards they want to use in every deck, etc.
-Each card+set combination can be rated individually, so players can assign different ratings to an Alpha Black Lotus than a Beta if they want to - useful if you want to keep a specific edition of the card and sell (or not use) the rest.
-Combined with the foil filter you can even perform complex operations like selling all 1, 2 and 3 star non-foil cards but sell only 1 star foils and keep the rest or not sell foils at all.
-The ratings are part of the quest save, so you can have new ratings for each quest game.
-The previously posted "foil filter" is also included in the patch file

RatingandFoilFilters.txt
The patch file
(18.72 KiB) Downloaded 210 times


Please include this in the next release if possible, we definitely need these filters for an enjoyable game experience. (and let me know when you did or if there is any problem)

Note : The patch uses existing icons for the filters - feel free to replace that with new icons if you think it looks bad.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: New Filters

Postby Seravy » 27 Jun 2017, 12:21

btw I have a question about making patch files.

How to I make it so that next time I use "create patch" it doesn't include all the previous changes?

(or is it acceptable if all the stuff I make is in one big patch file?)

...I guess reverting all the changes before starting to work on a new patch works albeit then I have to reapply the patches every time I want to compile a copy that has the changes for personal use.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: New Filters

Postby Agetian » 29 Jun 2017, 14:35

This is a very cool patch, and I'm keen on integrating it, but I have a couple issues with it that I'd really like to see resolved:

- As far as code goes, you're adding a part of Quest-specific code into ACEditorBase, which is very bad coding practice because ACEditorBase is meant to be mode-agnostic and should only contain code that applies equally to all game modes and thus to all the editors.
- Even though your modification appears to be local to Quest mode, the relevant filter (Personal Rating) confusingly appears in all the deck editors, including Constructed and Sealed, where it does nothing. It should ideally only appear in Quest mode. This might be at least in part related to the first point above.

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: New Filters

Postby Seravy » 29 Jun 2017, 17:42

Well, 5 hours of trying and no success.
While I understand what needs to be done :
move this block
Code: Select all
+       
+        public void AddRatingItem(final CEditorQuest qe, final int n) {
+        if (n==1) {menu.addSeparator();}
+        String s;
+        if (n==0) { s="Remove custom rating"; }
+        else {s="Rate this card as"+Integer.toString(n)+" stars"; }
+        GuiUtils.addMenuItem(menu, s,
+                KeyStroke.getKeyStroke(48+n, 0),
+                new Runnable() {
+            @Override
+            public void run() {
+                qe.SetRatingStars(n);
+            }
+        });
+          
+       
+        }
+         
into CEditorQuest, I can't figure out how to do it.
The problem is, this is not a method of ACEditorBase itself, but of a class declared inside of it. To move it, I would need to override the whole class and ultimately even if I try to find solutions on the net, the closest answer I found was "You can't override classes".
Sorry, but I have to leave this to someone more experienced.

(albeit...a very crude solution, but making "Menu" a public field and accessing it directly from the outside might work? In that case there is no need to try to insert a method by overriding the class.)
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: New Filters

Postby Seravy » 01 Jul 2017, 10:46

...all I needed was to make a getter for menu. I really need to get used to OOP faster lol, that's like, the first thing they teach in school.

Here, this should be what you wanted.

RatingFilters2.txt
(15.37 KiB) Downloaded 220 times
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: New Filters

Postby Agetian » 01 Jul 2017, 10:48

Nice! :) I'll take a look as soon as I can! Thanks for your effort!

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: New Filters

Postby Seravy » 01 Jul 2017, 12:13

Meanwhile, I'm wondering, is there a setting or option somewhere to change the default filters? I noticed some come always enabled, others start by being off. Would be nice if I could have the rating and foil filters always on as I use them quite often...but if it's hardcoded, I rather not change it.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: New Filters

Postby Agetian » 01 Jul 2017, 13:34

Ok, I started testing this patch and generally it seems to work fine, but it won't allow you to set the card rating when the card is in the deck, only when it's in your inventory, which is not very convenient. Would be nice if you could expand this functionality such that while in the quest deck editor, ratings could be set and cleared both in the inventory tab and the deck tab.

Also, I had a lot of reformatting to do... A couple points you definitely want to introduce into your coding practice:
1. You're still using tabs instead of spaces, this breaks visualization of code for others. There should be an option in your IDE to expand a tab into 4 spaces automatically.
2. Since manual formatting is hard for you at this point, make it a practice to select your new code (using the LMB drag, for example), and use the source auto-format command in your IDE (there should be one, e.g. in NetBeans it's Source -> Format) as an assisting tool.

Here's an updated (reformatted) patch that I'm preparing for submission.
Please expand it as mentioned in the first part of the post, if possible. Thanks in advance! :)

- Agetian
Attachments
CardRatings_reformatted.txt
(16.27 KiB) Downloaded 208 times
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: New Filters

Postby KrazyTheFox » 01 Jul 2017, 18:10

I think for this we really need something other than the generic mana symbol for the filters. It will cause a lot of confusion in its current state.
User avatar
KrazyTheFox
Programmer
 
Posts: 725
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 226 times

Re: New Filters

Postby Agetian » 01 Jul 2017, 18:23

KrazyTheFox wrote:I think for this we really need something other than the generic mana symbol for the filters. It will cause a lot of confusion in its current state.
Yeah, I agree with that! I think it might be good to add the actual "rating stars" pictures for this, or something along those lines.

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: New Filters

Postby Seravy » 01 Jul 2017, 20:19

1. You're still using tabs instead of spaces, this breaks visualization of code for others. There should be an option in your IDE to expand a tab into 4 spaces automatically.
I already enabled that once. Maybe Eclipse forgot?
...no it's still on. "Insert spaces for tabs" you mean this, right? In General/Editors/Text Editor?
It might not apply retroactively to patches already saved and loaded back, idk.

I tried looking for a "format" menu item a few days ago, but didn't see any. It would help if you specified where it is in Eclipse - if one even exists at all.

To add the feature to the other menu, I believe you only need to copy these 5 lines :
+ AddRatingItem(cmb,1);
+ AddRatingItem(cmb,2);
+ AddRatingItem(cmb,3);
+ AddRatingItem(cmb,4);
+ AddRatingItem(cmb,5);
+ AddRatingItem(cmb,0);

from the AddContextMenu that handles the "add" (left) side of deck editors, to the RemoveContextMenu which is the "remove" (right) side.
If it's not a problem I rather not load up Eclipse, revert, patch, change and save for that, if it doesn't work, let me know and I'll look at it.

btw I also suggest making some actual star pictures for this. The mana symbols are pretty much a placeholder as I didn't have anything better for it in the existing resources.

PS : Any info about how "default" filters are decided/are they optional? If not, it might be a good idea to make it so (personal rating for most players, foil for some others would be useful to default to on)
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 39 guests


Who is online

In total there are 39 users online :: 0 registered, 0 hidden and 39 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 39 guests

Login Form