Update an old plugin for 2.1 version

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jospic
:warning: Old Version Published before Godot 3 was released.

Hi,
I need to use good Resolution Switcher plugin in the new 2.1 Godot version, but it was developed for previous 2.0.x versions.
Is there anyway to easy convert it for current version?
Thanks in advance
-j

Please give a link to the plugin. I wrote a “crutch” to change the screen Resolution, I would like to see how others do it.

DimitriyPS | 2016-07-27 07:32

:bust_in_silhouette: Reply From: vinod

Hi,
I am the author of that plugin. I didn’t check the 2.1 as I am busy these days. I’ll certainly look into it when I can make up some time for that.
Meanwhile you can look into the code and fix it. I think it will be only some minor changes.

Thank you,
I 'll take a look and I’ll try to update it.
Regards
-j

jospic | 2016-07-25 16:08

:bust_in_silhouette: Reply From: necdel

I took a little time out today and fixed this myself since I was wanting to use it as well.

So the first thing you want to do is create an “addons” folder inside of your project folder.

  1. So for example if your project is at “c:\shmup” create “c:\shmup\addons”
  2. Copy the “Resolution Switcher” folder from plugins into the new addon folder.
  3. Change the following few lines of code inside “res_switcher.gd”

Replace line #26

add_custom_control(CONTAINER_CANVAS_EDITOR_MENU,toolbar_button)

with

add_control_to_container(CONTAINER_CANVAS_EDITOR_MENU,toolbar_button)

Next replace line #28

custom_window = preload("custom_res_popup.xml").instance()

with

custom_window = preload("res://addons/Resolution Switcher/custom_res_popup.xml").instance()

Replace lines 32-36

path = OS.get_data_dir()
var lpos = path.find_last("/")
path = path.substr(0,lpos)
lpos = path.find_last("/")
path = path.substr(0,lpos) + "/plugins/Resolution Switcher/list.txt"

with

path = "res://addons/Resolution Switcher/list.txt"

Now under your settings → plugins you can activate Resolution Switcher as usual, have fun!

@vinod, if you like I can create a pull request for you, I have no idea if what i did here is best practice or not, but it worked for now!

Sure.
But I am not much familiar with git. How can I make it so that the plugin is available for older and newer versions of Godot. I know there are branches but that’s all I know about them.

vinod | 2016-08-05 04:16

Sure vinod, If you go into your directory of the repository you can do a:

 git checkout -b testing

This would automatically create the branch if it doesn’t exist. Your working set is now the “Testing” branch. So you would make your changes and then

git commit -m"Test branch for 2.1RC plugin changes"
git push

That should publish your new branch for you. So at any time you could do a

git checkout master
git checkout testing

Will let you switch back and forth between the two locally. Once its published you should see it under your branch list on Github.

Another option is to use the GitHub application, it has a little plus icon in it next to your branch name that will let you create new branches. So you would just create it in there and click publish where the sync button usually is.

necdel | 2016-08-05 21:33