-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanEditor_Events.cpp
148 lines (148 loc) · 3.64 KB
/
cleanEditor_Events.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "G.h"
#include <wx/dcclient.h>
void G::editByte_BOnClick( wxCommandEvent& event )
{
FillEditor();
}
void G::editShow_BOnClick( wxCommandEvent& event )
{
if ( !editOptions_P->IsShown() )
{
editOptions_P->Show();
editShow_B->SetLabel( wxT( "-" ) );
}
else
{
editOptions_P->Hide();
editShow_B->SetLabel( wxT( "+" ) );
}
edit_P->Layout();
}
void G::editUpdate_DOnChoice( wxCommandEvent& event )
{
listAdd = 0u;
ListApps_D->Select( 0 );
s32 mode = editUpdate_D->GetSelection();
SetTime( editAdd, mode );
if ( mode > 0 )
{
FillEditor();
}
}
void G::editGet_BOnClick( wxCommandEvent& event )
{
listAdd = 0u;
ListApps_D->Select( 0 );
FillEditor();
}
void G::editSetRam( u64 address, u64 value, u8 size )
{
NewHook();
if ( isHooked < 1 ) return;
u8 ramNo = editRam_D->GetSelection();
address += mGetRamByte( ramNo );
if ( hookApp ) SetRamX( appHandle, address, &value, size );
else
{
bin_BF.Seek( address, wxFromStart );
bin_BF.Write( &value, size );
}
DelHook();
}
void G::editSet_BOnClick( wxCommandEvent& event )
{
u8 size = gGetUSize( editSize_D->GetSelection() );
u64 address = GetHex( editSet_TXT->GetValue() );
u64 value = GetHex( editValue_TXT->GetValue(), size );
editSetRam( address, value, size );
FillEditor();
}
void G::edit_GOnEditBegin( wxGridEvent& event )
{
if ( event.GetCol() >= 16 ) event.Veto();
else isEdit = true;
event.Skip();
}
void G::edit_GOnEditEnd( wxGridEvent& event ) { isEdit = false; }
void G::edit_GOnChange( wxGridEvent& event )
{
u8 col = event.GetCol();
if ( col >= 16u || editIsRecursing > 0 ) return;
++editIsRecursing;
u8 row = event.GetRow();
xStr text = edit_G->GetCellValue( row, col );
u64 address = GetHex( edit_G->GetRowLabelValue( row ) );
address += col;
u8 size;
u8 len = text.length();
if ( len < 2u ) size = 1u;
else if ( len < 4u ) size = 2u;
else if ( len < 8u ) size = 4u;
else size = 8u;
editSetRam( address, GetHex( text, size ), size );
FillEditor();
--editIsRecursing;
}
bool lFromUser = false;
void G::edit_TXTOnMouseWheel( wxMouseEvent& event )
{
u64 address = GetHex( editGet_TXT->GetValue() );
while ( ( address % 0x10 ) > 0u ) --address;
while ( ( address % 0x100 ) > 0u ) address -= 0x10;
if ( event.GetWheelRotation() >= 0 )
{
if ( address > 0u ) address -= 0x100;
}
else
{
if ( address < UINT64_MAX ) address += 0x100;
}
xStr txt;
txt.Printf( hexVLL, address );
editGet_TXT->ChangeValue( txt );
FillEditor();
}
void G::edit_GOnMouseWheel( wxMouseEvent& event )
{
event.Skip();
s32 r = event.GetWheelRotation();
editScroll( r, true );
}
void G::editScroll( s32 direction, bool fromUser, s32 orient )
{
if ( orient != wxVERTICAL || !fromUser ) return;
s32 xS = 0, yS = 0;
s32 w = 0, h = 0;
s32 xL = 0, yL = 0;
edit_G->GetViewStart( &xS, &yS );
edit_G->GetScrollPixelsPerUnit( &xL, &yL );
s32 x = xS * xL;
s32 y = yS * yL;
edit_G->GetClientSize( &w, &h );
lFromUser = false;
++editIsRecursing;
if ( ( y <= 0 || y >= h ) && ( x <= 0 || x >= w ) )
{
u64 address = GetHex( editGet_TXT->GetValue() );
while ( ( address % 0x10 ) > 0u ) --address;
while ( ( address % 0x100 ) > 0u ) address -= 0x10;
if ( direction >= 0 )
{
if ( address > 0u && y <= 0 ) address -= 0x100;
}
else
{
if ( address < UINT64_MAX && y >= h ) address += 0x100;
}
xStr txt;
txt.Printf( hexVLL, address );
editGet_TXT->ChangeValue( txt );
FillEditor();
}
--editIsRecursing;
}
void G::edit_GOnKeyDown( wxKeyEvent& event )
{
lFromUser = true;
event.Skip();
}