Skip to content
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

Unix newline on input text box #5

Closed
ghost opened this issue May 9, 2019 · 11 comments
Closed

Unix newline on input text box #5

ghost opened this issue May 9, 2019 · 11 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented May 9, 2019

When you paste code into the text box that comes from unix environment it will paste as a single line, since Environment.NewLine is obviously "\r\n".
Solutions include a custom textbox that catches the paste event and changes text, handling the text change event if it exists and change text, or simply make the textbox work with newline as "\n".

Given the fact that most cheat codes are made with tools from consoles etc and predominantly, "\n" as newline, wouldn't it make sense to just use that and skip windows newlines (aka this issue would become "when you paste code into the text box that comes from windows environment...".

e.g CWCheat POPs database files have unix newlines.

@ghost ghost changed the title Unix newline Unix newline on input text box May 9, 2019
@Yohoki Yohoki added the bug Something isn't working label May 9, 2019
@Yohoki
Copy link
Owner

Yohoki commented May 9, 2019

I have not looked at the original codes for the converter parts at all, so it's entirely unfamiliar to me. It's probably possible to parse the text first and replace any "\n" with "\r\n". That's already done on the pointer searcher side and in my VitaCheat Code Maker that isn't in the program yet.

I'm not the original creator, though, so I don't know the code without studying it, and I'm also not a programmer. If you have a fix already for it, I'd be glad to implement it. If not, it will have to wait until I can study that side of it.

I'm sure it's probably as simple as using something like:

string line = ...
line = line.Replace( "\n", "\r\n");

I'll see what I can do when I finish the codemaker function.

Edit: On second thought, this will add an \r\n every time this is done, causing it to start showing \r\r\n and \r\r\r\n, etc. I'll have to make it a 2part replace:

string line = ...
line = line.Replace( "\n", "BALOOGA").Replace( "\r", "").Replace( "BALOOGA", "\r\n");

Something like that should work.

@ghost
Copy link
Author

ghost commented May 10, 2019

So basically you're ok with the application using unix style newlines globally.

I'm about to finish the implementation of a drop list for code types on both tabs, maybe I'll include a fix for the newlines as well if I can get something to work with as least code as possible.

EDIT: Nevermind, I misread what you replied. You want to keep using \r\n.

@Yohoki
Copy link
Owner

Yohoki commented May 10, 2019

What changes do you have in mind? I'd very much like to see this program get new features, which is why I'm doing what I am doing. Let me know when you have it ready and I'll check it out and maybe merge it. I could actually use the help because I know literally 0 c#. XD

My main focus is adding features for use with the Vita, as this is our main tool for hunting pointers. I'm working right now on a new tab that's entirely focused on the console and making it's codes easier to understand. most of what I've done is already pushed to the code, but I haven't finished it so it's not in the releases section.

I do not know which would be better, to use unix style or \r\n. The original program used \r\n and my changes have also used it. So it will require some tinkering to change it now, some of which I haven't released yet. If it is NEEDED for the Convert tab, feel free to use whichever style you need. I will have to test to see if it works for the vitacheat and Pointer Search tabs or if changing to \n breaks the functions. I believe VitaCheat's .PSV files are particular about which character is used for newlines, though...

Edit: I just saw your pull request. It's been approved and merged. Thank you for your interest and contribution!

@Yohoki
Copy link
Owner

Yohoki commented May 10, 2019

Would something like this work? All I've done is found where it looks like it exports the CWCheat Pops file and tried to make it do a .Replace on the output file. This should retain the Unix style newline when saving it. I'll still have to check for the input file line as well, to replace the \n with \r\n for use in the converter.

else if (this.rdbConvertFile.Checked && ((Control)sender).Name == "btnConvert" && (this.txtInputPath.Text.Length > 0 && this.txtOutputPath.Text.Length > 0))
    {
        switch (this.cbCnvCodeTypes.Text)
        {
            case CT_CNV_CWCHEATPOPS:
        if (File.Exists(this.txtInputPath.Text) && Directory.Exists(Path.GetDirectoryName(this.txtOutputPath.Text)))
        Converter.file_cwcpops_pspar(this.txtInputPath.Text, this.txtOutputPath.Text.Replace("\r\n", "\n"));
        break;
            case CT_CNV_NITEPR:
       ..............

@ghost
Copy link
Author

ghost commented May 10, 2019

Sorry I forgot to reply. The "issue" is more on the copy & paste. Take any .db and try to paste values (assuming db has unix newlines), it will paste as a single line.

But I'm pretty ignorant in the topic, I barely started checking out cheats and debuggers a month ago for the switch and now I wanna do the same with the Vita, but I don't really know much about pointer searches and file formats to name 2.

@Yohoki
Copy link
Owner

Yohoki commented May 10, 2019

Same. I know 0 c#. This is more of a "I'm tired of helping explain this same thing to everyone" kind of thing. XD

I think I get the issue. The CWCheatPops .DB file NEEDS the \n unix-style linebreak, correct?

In that case, I'll need to .Replace on loading the .DB to remove Unix type linebreaks and insert Windows style. Then, on saving the code, I'll need to also replace them again for Unix Style. Does this sound right so far?

@Yohoki
Copy link
Owner

Yohoki commented May 10, 2019

I see what you mean.... I can prob fix that. Will the .DB work if I make any NEW CWCPops .DBs use \r\n, or do they have to use \n? I can do either way probably.

@Yohoki
Copy link
Owner

Yohoki commented May 11, 2019

I've pushed a fix. It looks like the output text is already formatted with Windows style line breaks, so it shouldn't be an issue to have it stay that way. I've added 2 .Replace functions at the line where text in the input box is checked for changes and sent to the converter to send to the output box.

The code now replaces all Windows Linebreaks (\r\n) to unix style (\n), It then replaces all unix style line breaks with Windows style.

The reason for converting to unix first is to avoid causing any windows linebreaks from turning into \r\r\n.

try building it when you can and give it a debug for me to see if that works for you.

@Yohoki
Copy link
Owner

Yohoki commented May 11, 2019

It says I edited 3 lines, but 2 were me testing that I forgot to remove before pushing... I only edited line 172

@ghost
Copy link
Author

ghost commented May 11, 2019

Awesome, I gave it a go and works just fine thanks.

Issue can be closed now then.

Btw what I meant by my previous comment wasn't clear; I am an experienced developer and have no issues modifying most things out there, but I'm a n00b in cheats and static/dynamic debugging (in the end, cracking). I used to know things but that was more than a decade ago, so I'm slowly getting back into it.
So as you can see I'm your opposite (expert at cheats, new at programming).

@Yohoki
Copy link
Owner

Yohoki commented May 11, 2019

Great to hear! Glad that fixed it. I was still a little confused until I downloaded a .DB and tried it out. It was instantly clear how it would look in the program when I loaded it first in notepad.

You're not so different, actually at the debugging part. I was decent at it a decade ago with CheatEngine on PC, but I hadn't released anything public and hadn't done any programming and barely even knew how to get lvl 1 pointers... Vitacheat kinda let me get back into it and I've been really enjoying it, so I really wanted to add a few things to TempAR to get it easy for people to pickup and start making new codes.

The offer's still out there. If you'd like to help add some things, I could also use an experienced programmer. If not, Google's a great tool to learn new things for me. XD

@Yohoki Yohoki closed this as completed May 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant