@@ -43,19 +43,21 @@ public NewAddress(Main mainForm, Section addrSection, Section baseSection, ulong
43
43
OnBox = new TextBox ( ) ;
44
44
OffBox = new TextBox ( ) ;
45
45
46
- OnLabel . Anchor = AnchorStyles . Top | AnchorStyles . Right ;
47
46
OnLabel . AutoSize = true ;
47
+ OnLabel . Dock = DockStyle . Fill ;
48
48
OnLabel . Margin = AddressLabel . Margin ;
49
49
OnLabel . Name = "OnLabel" ;
50
50
OnLabel . TabIndex = 1 ;
51
51
OnLabel . Text = "On" ;
52
+ OnLabel . TextAlign = System . Drawing . ContentAlignment . MiddleRight ;
52
53
53
54
OffLabel . AutoSize = true ;
54
- OffLabel . Dock = DockStyle . Right ;
55
+ OffLabel . Dock = DockStyle . Fill ;
55
56
OffLabel . ForeColor = ForeColor ;
56
57
OffLabel . Margin = ValueLabel . Margin ;
57
58
OffLabel . Name = "OffLabel" ;
58
59
OffLabel . Text = "Off" ;
60
+ OffLabel . TextAlign = System . Drawing . ContentAlignment . MiddleRight ;
59
61
60
62
OnBox . BackColor = BackColor ;
61
63
OnBox . ForeColor = ForeColor ;
@@ -160,6 +162,7 @@ public void ApplyUI(LanguageJson langJson)
160
162
DescriptionLabel . ForeColor = ForeColor ;
161
163
LockBox . ForeColor = ForeColor ;
162
164
PointerBox . ForeColor = ForeColor ;
165
+ OnOffBox . ForeColor = ForeColor ;
163
166
164
167
AddressBox . ForeColor = ForeColor ;
165
168
AddressBox . BackColor = BackColor ;
@@ -209,12 +212,12 @@ private void SaveBtn_Click(object sender, EventArgs e)
209
212
CheatType = ( ScanType ) ( ( ComboItem ) ( ScanTypeBox . SelectedItem ) ) . Value ;
210
213
ScanTool . ValueStringToULong ( CheatType , ValueBox . Text ) ;
211
214
Value = ValueBox . Text ;
212
- OnValue = OnBox . Text ;
213
- OffValue = OffBox . Text ;
215
+ OnValue = string . IsNullOrWhiteSpace ( OnBox . Text ) ? null : OnBox . Text ;
216
+ OffValue = string . IsNullOrWhiteSpace ( OffBox . Text ) ? null : OffBox . Text ;
214
217
IsLock = LockBox . Checked ;
215
218
Descriptioin = DescriptionBox . Text ;
216
219
217
- if ( ! AddressBox . ReadOnly ) mainForm . AddToCheatGrid ( AddrSection , ( uint ) ( Address - AddrSection . Start ) , CheatType , Value , IsLock , Descriptioin , PointerOffsets ) ;
220
+ if ( ! AddressBox . ReadOnly ) mainForm . AddToCheatGrid ( AddrSection , ( uint ) ( Address - AddrSection . Start ) , CheatType , Value , IsLock , Descriptioin , PointerOffsets , null , - 1 , true , OnValue , OffValue ) ;
218
221
219
222
DialogResult = DialogResult . OK ;
220
223
Close ( ) ;
@@ -320,24 +323,26 @@ private void SetOffsetBoxs(bool isAdd)
320
323
{
321
324
TextBox textBox = new TextBox
322
325
{
323
- Text = "0" ,
324
- Location = AddOffsetBtn . Location ,
326
+ Text = "0" ,
327
+ Location = AddOffsetBtn . Location ,
325
328
ForeColor = ForeColor ,
326
329
BackColor = BackColor ,
327
- Dock = DockStyle . Fill ,
328
- Margin = new Padding ( 3 )
330
+ Dock = DockStyle . Fill ,
331
+ Margin = new Padding ( 3 )
329
332
} ;
330
333
331
- Label label = new Label
334
+ TextBox label = new TextBox
332
335
{
333
- Text = "" ,
334
- Location = DelOffsetBtn . Location ,
335
- ForeColor = ForeColor ,
336
- BackColor = BackColor ,
337
- Dock = DockStyle . Fill ,
338
- Margin = new Padding ( 3 )
339
- } ;
340
-
336
+ Text = "" ,
337
+ Location = DelOffsetBtn . Location ,
338
+ ForeColor = ForeColor ,
339
+ BackColor = BackColor ,
340
+ Dock = DockStyle . Fill ,
341
+ Margin = new Padding ( 3 , 6 , 3 , 3 ) ,
342
+ ReadOnly = true ,
343
+ BorderStyle = BorderStyle . None ,
344
+ } ;
345
+ PointerOffsets . Add ( 0 ) ;
341
346
TableLayoutBottomBox . RowCount += 1 ;
342
347
TableLayoutBottomBox . RowStyles . Add ( new RowStyle ( SizeType . Percent , 100F ) ) ;
343
348
TableLayoutBottomBox . Controls . Add ( textBox , 0 , TableLayoutBottomBox . Controls . Count ) ;
@@ -351,6 +356,7 @@ private void SetOffsetBoxs(bool isAdd)
351
356
{
352
357
if ( TableLayoutBottomBox . Controls . Count == 0 ) return ;
353
358
359
+ PointerOffsets . RemoveAt ( PointerOffsets . Count - 1 ) ;
354
360
Height -= TableLayoutBottomBox . Controls [ TableLayoutBottomBox . Controls . Count - 1 ] . Height ;
355
361
TableLayoutBottomBox . Controls . RemoveAt ( TableLayoutBottomBox . Controls . Count - 1 ) ;
356
362
TableLayoutBottomBox . RowCount -= 1 ;
@@ -366,27 +372,42 @@ private void ScanTypeBox_SelectedIndexChanged(object sender, EventArgs e)
366
372
if ( IsPointer || PointerOffsets != null ) return ;
367
373
368
374
var newCheatType = ( ScanType ) ( ( ComboItem ) ( ScanTypeBox . SelectedItem ) ) . Value ;
369
- if ( newCheatType == ScanType . String_ ) return ;
370
- else if ( CheatType == ScanType . Hex && ValueBox . Text . Length > 32 )
375
+ if ( CheatType == ScanType . Hex && ValueBox . Text . Length > 16 )
371
376
{
372
377
ScanTypeBox . SelectedIndex = ScanTypeBox . FindStringExact ( CheatType . GetDescription ( ) ) ;
373
378
return ;
374
379
}
380
+ else if ( newCheatType == ScanType . String_ ) return ;
375
381
376
382
try
377
383
{
378
384
var newValue = ScanTool . ValueStringToULong ( CheatType , ValueBox . Text ) ;
379
385
if ( newValue == 0 ) return ;
380
386
381
- if ( newCheatType == ScanType . Byte_ && newValue > byte . MaxValue ) return ;
382
- else if ( newCheatType == ScanType . Bytes_2 && newValue > UInt16 . MaxValue ) return ;
383
- else if ( newCheatType == ScanType . Bytes_4 && newValue > UInt32 . MaxValue ) return ;
387
+ if ( newCheatType == ScanType . Byte_ && newValue > byte . MaxValue ||
388
+ newCheatType == ScanType . Bytes_2 && newValue > UInt16 . MaxValue ||
389
+ newCheatType == ScanType . Bytes_4 && newValue > UInt32 . MaxValue ||
390
+ newCheatType == ScanType . Float_ && newValue > float . MaxValue )
391
+ {
392
+ ScanTypeBox . SelectedIndex = ScanTypeBox . FindStringExact ( CheatType . GetDescription ( ) ) ;
393
+ return ;
394
+ }
384
395
385
396
var newText = ScanTool . ULongToString ( newCheatType , newValue ) ;
386
397
if ( newText == "0" ) return ;
387
398
388
399
Value = newValue . ToString ( ) ;
389
400
ValueBox . Text = newText ;
401
+
402
+ //var newOnValue = ScanTool.ValueStringToULong(CheatType, OnBox.Text);
403
+ //var newOnText = ScanTool.ULongToString(newCheatType, newOnValue);
404
+ //OnValue = newOnValue.ToString();
405
+ //OnBox.Text = newOnText;
406
+
407
+ //var newOffValue = ScanTool.ValueStringToULong(CheatType, OffBox.Text);
408
+ //var newOffText = ScanTool.ULongToString(newCheatType, newOffValue);
409
+ //OffValue = newOffValue.ToString();
410
+ //OffBox.Text = newOffText;
390
411
}
391
412
catch ( Exception ex )
392
413
{
@@ -417,26 +438,30 @@ private void RefreshPointerChecker_Tick(object sender, EventArgs e)
417
438
418
439
if ( BaseSection == null ) break ;
419
440
420
- if ( TableLayoutBottomBox . Controls . Count > PointerOffsets . Count ) PointerOffsets . Add ( address ) ;
421
- else PointerOffsets [ idx ] = address ;
441
+ PointerOffsets [ idx ] = address ;
422
442
423
443
if ( idx != TableLayoutBottomBox . Controls . Count - 1 )
424
444
{
425
445
if ( AddrSection == null || AddrSection . SID == 0 ) AddrSection = mainForm . sectionTool . GetSection ( mainForm . sectionTool . GetSectionID ( ( ulong ) ( address + baseAddress ) ) ) ;
426
446
byte [ ] nextAddress = PS4Tool . ReadMemory ( AddrSection . PID , ( ulong ) ( address + baseAddress ) , 8 ) ;
427
447
baseAddress = BitConverter . ToInt64 ( nextAddress , 0 ) ;
428
- TableLayoutBottomLabel . Controls [ idx ] . Text = baseAddress . ToString ( "X" ) ;
448
+ TableLayoutBottomLabel . Controls [ idx ] . Text = string . Format ( "=> {0:X2} +" , baseAddress ) ;
429
449
}
430
450
else
431
451
{
432
452
if ( address == 0 && baseAddress == 0 ) continue ;
433
- byte [ ] data = PS4Tool . ReadMemory ( BaseSection . PID , ( ulong ) ( address + baseAddress ) , ScanTool . ScanTypeLengthDict [ CheatType ] ) ;
434
- TableLayoutBottomLabel . Controls [ idx ] . Text = ScanTool . BytesToString ( CheatType , data ) ;
453
+ int length = 0 ;
454
+ if ( CheatType != ScanType . Hex ) length = ScanTool . ScanTypeLengthDict [ CheatType ] ;
455
+ else if ( ValueBox . Text . Length > 1 ) length = ValueBox . Text . Length / 2 ;
456
+ else length = 8 ;
457
+ byte [ ] data = PS4Tool . ReadMemory ( BaseSection . PID , ( ulong ) ( address + baseAddress ) , length ) ;
458
+ string value = ScanTool . BytesToString ( CheatType , data ) ;
459
+ TableLayoutBottomLabel . Controls [ idx ] . Text = string . Format ( "=> {0}" , value ) ;
435
460
AddressBox . Text = ( address + baseAddress ) . ToString ( "X" ) ;
436
461
if ( ! ValueBox . Enabled || changedCheatType )
437
462
{
438
463
ValueBox . Enabled = true ;
439
- ValueBox . Text = TableLayoutBottomLabel . Controls [ idx ] . Text ;
464
+ ValueBox . Text = value ;
440
465
}
441
466
}
442
467
}
0 commit comments