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

RunRenpyViaplugin #291

Merged
merged 11 commits into from
May 7, 2023
Merged

RunRenpyViaplugin #291

merged 11 commits into from
May 7, 2023

Conversation

seanj29
Copy link
Contributor

@seanj29 seanj29 commented Apr 12, 2023

I don't have any expereince with typescript, so it may be a bit of a botched job, and I can't seem to get node.js to run on my machine, but this should be able to deal with https://github.com/LuqueDaniel/vscode-language-renpy/issues/115#issue-1239736338. I used a child process to run terminal command similar to what is done to watch for renpy compile data, but it should spawn a new renpy process in a new window.

@duckdoom4
Copy link
Collaborator

duckdoom4 commented Apr 12, 2023

Hi there, thank your interest in the project and taking the time to build this PR! :) This is definitely a good start and the code looks good. (I will need to take some time later to test it before I approve the code).

That said, it would be nice if you can link this command to the 'play/run' button. That way we use the default behavior, instead of requiring users to run a command.

@duckdoom4
Copy link
Collaborator

duckdoom4 commented Apr 12, 2023

I just looked through the documentation for this. I think the only way to do this, is through the debugger API.

https://code.visualstudio.com/api/extension-guides/debugger-extension

In our case, the full debugger is a bit of a stretch. But I think we should be able to use the mock debugger example they provided, then strip out all the debugger options and only provide the launch/run functionality.

Let me know if that's something you'd be willing to help with, or if you'd rather leave it as a command for now. Given that this is a bit more work, I totally understand if you do.

@duckdoom4
Copy link
Collaborator

duckdoom4 commented Apr 12, 2023

Actually, looking at this: Screenshot_20230412-222052.jpg

I think we might be able to add a launch configuration without the debugger. That would be best. In our case the 'type' should then be cmd instead of mock and adding the "command" property. Eg. "command": "run renpy cmd"

Also see this:
https://github.com/microsoft/vscode-mock-debug/blob/63e33ea07d9769ae9605212a13e96796333a61fd/src/activateMockDebug.ts#L30

@seanj29
Copy link
Contributor Author

seanj29 commented Apr 12, 2023

I'm happy to try out doing this. Ill read through the vscode extension docs you sent and send an update

@LuqueDaniel
Copy link
Member

Thank you very much for your contribution. I look forward to testing and reviewing it soon.

@duckdoom4
Copy link
Collaborator

I noticed that your formatting is configured to 2 spaces instead of four. Did you use prettier? The .editorconfig does use 4 spaces for ts files. Let me know if that setting doesn't work anymore

@seanj29
Copy link
Contributor Author

seanj29 commented Apr 15, 2023

Ill try rerunning it, I should have prettier installed on the machine tho gimme a sec

@seanj29
Copy link
Contributor Author

seanj29 commented Apr 15, 2023

Done now. Think my prettier for some reason didn't format the workspace on save like I set it to

@duckdoom4
Copy link
Collaborator

duckdoom4 commented Apr 17, 2023

Screenshot_20230418-010424.jpg

That's much better, tho it's still applying two spaces instead of 4 :(

(That makes it really hard to review the changes you've made, git doesn't display those diffs very well)

@seanj29
Copy link
Contributor Author

seanj29 commented Apr 18, 2023

I'll try to reformat again, should be able to whitespace diff instead of full diff instead, but hopefully this works.

@duckdoom4
Copy link
Collaborator

Yes perfect, that worked. I'll review it in a bit

Copy link
Collaborator

@duckdoom4 duckdoom4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Looking really good, some minor things and then we can get this merged! 😄

src/extension.ts Outdated
if (!config) {
window.showErrorMessage("Ren'Py executable location not configured or is invalid.");
} else {
if (isValidExecutable(config.renpyExecutableLocation)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move this check to the line above with an || or comparison. (So 'if not config or renpy executable location not set'.) That way you don't need the copy the message log code :)

(Also in case you didn't know, that works because if statements do early out. Meaning the config is checked first, and only if true will it check the remaining parts)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

God it, fixed this now

src/extension.ts Outdated
window.showErrorMessage("Ren'Py executable location not configured or is invalid.");
} else {
if (isValidExecutable(config.renpyExecutableLocation)) {
//this is kinda a hob botched together attempt that I'm like 30% certain has a chance of working
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test if it works? If it does you should remove the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not manage to test if it works yet, will try after this commit

src/extension.ts Outdated
window.showInformationMessage("Ren'Py is running successfully");
}
} else {
window.showErrorMessage("Ren'Py executable location not configured or is invalid.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to remove this one if you addressed my first comment :)

src/extension.ts Outdated
function RunWorkspaceFolder(): boolean {
const config = workspace.getConfiguration("renpy");
const renpy = config.renpyExecutableLocation;
if (isValidExecutable(renpy)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that the config can be null, you should use the same check as above.

(Even if you know you checked, if someone in the future wants to use this function, it should be safe to use on it's own)

src/extension.ts Outdated
if (isValidExecutable(renpy)) {
const renpyPath = cleanUpPath(Uri.file(renpy).path);
const cwd = renpyPath.substring(0, renpyPath.lastIndexOf("/"));
let wf = getWorkspaceFolder();
Copy link
Collaborator

@duckdoom4 duckdoom4 Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now you copied it from the function below, so no worries. But my feedback should still be applied.

I think this can be const. Also please use full (short) descriptive names for variables. If I want to know what wf means, I now have to look at the definition.

@seanj29
Copy link
Contributor Author

seanj29 commented Apr 18, 2023

I can't seem to run the extension tests on my machine? Or at least the secondary checker one you have on there

src/extension.ts Outdated Show resolved Hide resolved
@duckdoom4
Copy link
Collaborator

One last thing :p

Sorry, what extension tests are you talking about?
If you mean you want to run the extension, you'll need node.js installed to execute webpack.
To be fair, I've been developing on the dev branch for the longest time. It could very well be that it's broken on main.
(don't have much time to check rn, sorry)

@seanj29
Copy link
Contributor Author

seanj29 commented Apr 22, 2023

Also yeah, I did mean running the extension, I'm installing node.js now lmao, didn't even realize it was needed.

@duckdoom4
Copy link
Collaborator

Your last commit converted everything to two spaces again 😁

@duckdoom4
Copy link
Collaborator

Yes looking good. LGTM! 🎉🎉

@duckdoom4 duckdoom4 merged commit c2bea06 into renpy:master May 7, 2023
@LuqueDaniel LuqueDaniel added this to the 2.0.17 milestone May 7, 2023
duckdoom4 pushed a commit that referenced this pull request May 12, 2023
* Edited extensions method to add way to run renpy

* Added the command to the pallete via json

* Adding debug config to allow renpy to be played from play button

* changed type to cmd

* reformatted with prettier

* This format might work?

* Refactored if statement to make it more readable

* Refactoring of folder names and chaning if statements

* This commit fixed the issues in comment https://github.com/LuqueDaniel/vscode-language-renpy/pull/291#discussion_r1170180867, , refactoring if statement

* reformated through magical means... God I hate switching computers

* Reformated with the correct file, please ignore previous one
duckdoom4 pushed a commit that referenced this pull request Jun 1, 2023
* Edited extensions method to add way to run renpy

* Added the command to the pallete via json

* Adding debug config to allow renpy to be played from play button

* changed type to cmd

* reformatted with prettier

* This format might work?

* Refactored if statement to make it more readable

* Refactoring of folder names and chaning if statements

* This commit fixed the issues in comment https://github.com/LuqueDaniel/vscode-language-renpy/pull/291#discussion_r1170180867, , refactoring if statement

* reformated through magical means... God I hate switching computers

* Reformated with the correct file, please ignore previous one
duckdoom4 pushed a commit that referenced this pull request Jun 2, 2023
* Edited extensions method to add way to run renpy

* Added the command to the pallete via json

* Adding debug config to allow renpy to be played from play button

* changed type to cmd

* reformatted with prettier

* This format might work?

* Refactored if statement to make it more readable

* Refactoring of folder names and chaning if statements

* This commit fixed the issues in comment https://github.com/LuqueDaniel/vscode-language-renpy/pull/291#discussion_r1170180867, , refactoring if statement

* reformated through magical means... God I hate switching computers

* Reformated with the correct file, please ignore previous one
duckdoom4 pushed a commit that referenced this pull request Jun 2, 2023
* Edited extensions method to add way to run renpy

* Added the command to the pallete via json

* Adding debug config to allow renpy to be played from play button

* changed type to cmd

* reformatted with prettier

* This format might work?

* Refactored if statement to make it more readable

* Refactoring of folder names and chaning if statements

* This commit fixed the issues in comment https://github.com/LuqueDaniel/vscode-language-renpy/pull/291#discussion_r1170180867, , refactoring if statement

* reformated through magical means... God I hate switching computers

* Reformated with the correct file, please ignore previous one
duckdoom4 added a commit that referenced this pull request Jun 2, 2023
* Chore: Allow 000*.rpy files in renpy/common (#300)

* RunRenpyViaplugin (#291)

* Edited extensions method to add way to run renpy

* Added the command to the pallete via json

* Adding debug config to allow renpy to be played from play button

* changed type to cmd

* reformatted with prettier

* This format might work?

* Refactored if statement to make it more readable

* Refactoring of folder names and chaning if statements

* This commit fixed the issues in comment https://github.com/LuqueDaniel/vscode-language-renpy/pull/291#discussion_r1170180867, , refactoring if statement

* reformated through magical means... God I hate switching computers

* Reformated with the correct file, please ignore previous one

* Ignore dist folder (#303)

* Ignore dist folder (#301)

* Chore(Enhancement) - Add a command that cleans up compiled files.

* Update the command title to match the convention.

* Use await/async syntax

* Merge pull request #304 from a2937/old-file-command

Chore(Enhancement) - Add a command that cleans up compiled files.

---------

Co-authored-by: a2937 <[email protected]>
Co-authored-by: seanj29 <[email protected]>
Co-authored-by: Daniel Luque <[email protected]>
duckdoom4 added a commit that referenced this pull request Jun 2, 2023
* Chore: Allow 000*.rpy files in renpy/common (#300)

* RunRenpyViaplugin (#291)

* Edited extensions method to add way to run renpy

* Added the command to the pallete via json

* Adding debug config to allow renpy to be played from play button

* changed type to cmd

* reformatted with prettier

* This format might work?

* Refactored if statement to make it more readable

* Refactoring of folder names and chaning if statements

* This commit fixed the issues in comment https://github.com/LuqueDaniel/vscode-language-renpy/pull/291#discussion_r1170180867, , refactoring if statement

* reformated through magical means... God I hate switching computers

* Reformated with the correct file, please ignore previous one

* Ignore dist folder (#303)

* Ignore dist folder (#301)

* Chore(Enhancement) - Add a command that cleans up compiled files.

* Update the command title to match the convention.

* Use await/async syntax

* Adds PR ci to master

Fixes #306

* Fixes codeql-analysis.yml format

* Adds setup action

* Fix package lock after merge

---------

Co-authored-by: a2937 <[email protected]>
Co-authored-by: seanj29 <[email protected]>
Co-authored-by: Daniel Luque <[email protected]>
@LuqueDaniel LuqueDaniel modified the milestones: 2.0.17, 2.2.0 Jun 3, 2023
@hsandt
Copy link

hsandt commented Oct 31, 2023

Hey, I'm trying to use the command Run: Renpy: Run Project but it shows me an error:

Ren'Py executable location not configured or is invalid.

I can see that it should be set in config.renpyExecutableLocation in the commit diff, but I see no such setting in Settings > Extensions > Ren'Py (there are only 10 settings, from editor.defaultFoldingRangeProvider to renpy.watchFoldersForChanges).

How am I supposed to set it?

@duckdoom4
Copy link
Collaborator

Hi there, I think there might be no UI entry for this (going off your comment). In that case you can only set it manually by adding this entry in the setting json config

@hsandt
Copy link

hsandt commented Nov 15, 2023

Hi there, I think there might be no UI entry for this (going off your comment). In that case you can only set it manually by adding this entry in the setting json config

So, the parameter is not autocompleted and not recognised (it appears half transparent and hovering it shows tooltip "Unknown Configuration Setting") but surprisingly setting it to the full path of renpy.sh (on Linux) actually replaces the "Ren'Py executable location not configured or is invalid." error bottom-right popup with a centered popup window:

image

Clicking on "Install cmd Extension" will suggest a few bash/command-related extension to install, but it doesn't seem quite right, so I'm not sure what to do now.

For now I just run Renpy via a custom command using F5Anything...

EDIT: since this PR is merged I'll copy this post to #115 to continue discussion.

@seanj29
Copy link
Contributor Author

seanj29 commented Dec 4, 2023

I've got some time, so I'm gonna try and remake this in better way, and try to get running working from GUI too.

@seanj29
Copy link
Contributor Author

seanj29 commented Dec 4, 2023

realised that its alredy been fixed in #115 oops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants