-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Linux - GTK3/GTK2] Action Replay code menu (+ other cheat menu improvements) #847
[Linux - GTK3/GTK2] Action Replay code menu (+ other cheat menu improvements) #847
Conversation
The decision to change the value column to store G_TYPE_UINT is purely pragmatic--having all data be treated and displayed as unsized is simpler than writing a custom display to handle signedness and cleaner than 1-3 byte ints appearing unsigned and 4 byte int appearing signed.
My implementation plan is to use a GtkTreeModelFilter to create separate section for internal and ActionReplay cheats, but I was not convinced the indices in the tree path would correspond to the indices in , hence the additional column.
…date/delete Filters were a little more cumbersome than I was expecting, but managed to get raw cheats operational again. From now on, I'm focusing purely on GTK3 and will backport the changes to GTK2 right before the PR
Goodness, was messing around with GTK to get it to all work out such a pain. Not completely happy with the scroll not expanding to fit text as is it added, but at least everything is functional.
+ some additional clean-up comments and small bug patches
@@ -120,6 +120,9 @@ class CHEATS | |||
|
|||
bool remove(const size_t pos); | |||
|
|||
void toggle(bool enabled, const size_t pos); | |||
void toggle(u8 enablbed, const size_t pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo. do we really need an overloaded func for this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then it's probably fine.
this is marked as a draft. does this mean that the GTK2 version isn't completed yet ? please also provide some examples of cheat code/game name so this can be tested. |
Yes, I realized part way through that repeatedly backporting everything before every commit would be a waste when I commit changes on top of one another, so I decided I could save backporting for the end and make a draft PR with most of the progress.
I like my test suites big, so I will claim anything on DeSmuMe's wiki page on cheats will work. |
At reviewer request
cool. give me a heads-up when it's ready so i can test the gtk2 version. |
Upset with the amount of procrastinating I did, though I am going to tinker with the custom CellRenderer because I think I am close to a more aesthetic solution.
Hopefully passes CI now. Make systems are hard.
Alright, GTK2 should be on par with GTK3 functionality. I am still disappointed with the UI with the cheat cell, though it is usable for cheats of reasonable length. There should be a way to bound |
finally got around to test the PR, it's a huge improvement - thanks. action replay codes finally work and the input is hex as expected. however i had to make the following changes: --- a/desmume/src/frontend/posix/gtk/utilsGTK.cpp
+++ b/desmume/src/frontend/posix/gtk/utilsGTK.cpp
@@ -19,6 +19,7 @@
*/
#include "utilsGTK.h"
+#include <string.h>
/*
A C++ implementation of a GtkCellRendererText subclass which handles
diff --git a/desmume/src/frontend/posix/gtk2/utilsGTK.cpp b/desmume/src/frontend/posix/gtk2/utilsGTK.cpp
index 831340e1..f7f893c5 100644
--- a/desmume/src/frontend/posix/gtk2/utilsGTK.cpp
+++ b/desmume/src/frontend/posix/gtk2/utilsGTK.cpp
@@ -20,7 +20,7 @@
#include "utilsGTK.h"
#include <gdk/gdkkeysyms.h>
-
+#include <string.h>
/*
A C++ implementation of a GtkCellRendererText subclass which handles
newline-delimited text and allows for editing that text with the ability
@@ -56,11 +56,13 @@ static void desmume_entry_nd_cell_editable_init(GtkCellEditableIface *iface);
// As defined in GObject 2.38, which is past the last release of GTK2.
// https://gitlab.gnome.org/GNOME/glib/-/blob/main/gobject/gtype.h#L2188
+#ifndef G_ADD_PRIVATE
#define G_ADD_PRIVATE(TypeName) \
{ \
TypeName##_private_offset = g_type_add_instance_private( \
g_define_type_id, sizeof(TypeName##Private)); \
}
+#endif
G_DEFINE_TYPE_WITH_CODE(DesmumeEntryNd, desmume_entry_nd, GTK_TYPE_EVENT_BOX,
G_ADD_PRIVATE(DesmumeEntryNd) G_IMPLEMENT_INTERFACE( this is because you used strlen but didn't include string.h. also the G_blah macro is already defined - glib and gtk2 are independent and it's possible to use a newer glib with gtk2. |
Thanks for getting around to the review. I know how long things can take in open source. Can't believe I missed the |
Summary:
The Linux GTK frontend's cheat menu now reads Action Replay codes from a game's
dct
file and adds them to a seperate section where users can add, remove, toggle, and modify them correctly and conveniently.A couple changes were also made to the internal cheats' section of the menu to make it harder to misuse:
Notes:
Action Replay code entry still leaves something to be desired. The scroll window sometimes doesn't scroll all of the way down and there is no size cut-offs, so long codes can consume far too much space. Coding two new GTK objects to get multiline editable text was easily the hardest part of this coding adventure though.
I still need to backport much to the GTK2 frontend, but with a working GTK2 build, I expect that part to be merely tedious, not actually hard.
The formatting was fairly scattered throughout the sections I worked on, (noticable really early on, when Neovim picked up the
.editorconfig
and inserted tabs, which I usually set to 2 spaces). I wrote an opinionated.clang-format
that kept at least some of the formatting decisions I gleaned (but not tabs, screw tabs). I'll share it if you want it.I wanted to cheat something for a fun project, which led me to realizing the shortcomings of the internal cheat menu. After converting to decimal and discovering they were not capable of doing what I wanted, I found the file cheats were stored, added Action Replay codes to another file on a Windows version, then copied them back to the
dct
file on Linux. Seeing they worked flawlessly meant everything in the backend was there, so it was just interface programming. Found the culpritatoi
messing with internal cheat offset in like 2 minutes, and though the rest was not as easy, its still really nice at the end to tangibly improve a project because it's open source. <3