Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 13    Views: 76

Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
01/19/15 05:46 PM (9 years ago)

Editing JSON data

Hi all, What i need to do is to have the same plugin with different graphics loading in a different screen. For this, i assume i need to edit the plugin name and then edit the name in the JSON file to pass the correct plugin. I'm not able to edit this in the screen. Can anyone advise please? Thanks.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/19/15 06:13 PM (9 years ago)
I'm not sure what you're going for here... the way it is 'supposed' to work is (depending on the plugin of course) that you would 'add' another screen to your control panel, and configure each with the requirements for those screens. Is this a plugin that doesn't do that? Cheers! -- Smug
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/19/15 08:18 PM (9 years ago)
I am with Smug -- color me dazed and confused.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
01/20/15 12:58 AM (9 years ago)
Hi! The same plugin will need loading five times. I need to change certain elements within the code for each time it loads. This is therefore impossible to do with just the one plugin. Thanks for your help! Greatly appreciated!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/20/15 03:08 AM (9 years ago)
I'm still not completely certain what you're trying to do. That said, if you want to 'clone' a plugin, there might be a couple of ways to do it. 1) Create custom plugin json using Stobes snippet keeper 2) Create new plugins within BT, and put those into your Self Hosted control panel. Either way could probably work. Cheers! -- Smug
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
01/20/15 11:36 AM (9 years ago)
Thanks smug. So, for example, I have a game. It will use a game plugin. 2 buttons will be needed to take you to different versions of the same plugin. As the versions need to be different I'd need 2 versions of the same plugin. Does what you've said above still apply? Thanks
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
01/20/15 12:56 PM (9 years ago)
Smug, I've changed the plugin name and son file and added to my control panel. Once i add the screen to my app, it appears. However, when i click on it it shows as not found. I'm clearly doing something wrong, will really appreciate your help. Cheers!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/21/15 12:55 AM (9 years ago)
Perhaps modify the plugin to accept JSON parameters as a way of adjusting what the Game shows on the screen. Then you can still make multiple screens of the Game plugin, yet make it show different things for each screen via the Control Panel. -- Niraj
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/21/15 04:19 AM (9 years ago)
Don't confuse filenames with class names. They're usually the same, but not always. Case sensitivity is also something to keep track of. the JSON will usually be listing the BT_itemType which will be the 'Class Name'. ( In the class, it'll usually reference the header file (#import <myClass.h>, and that is the physical 'File Name'. https://dl.dropboxusercontent.com/u/115208762/fileclass.png You don't want duplicate filenames, nor do you want duplicate class names. The class name will be the BT_itemType. The filename can be anything you wish, as long as the header/implementation files (h/m) reference each other correctly. Does this help any? Cheers! -- Smug
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
01/21/15 05:00 PM (9 years ago)
Thanks guys. I don't think this is the way to go. What i'm now trying is adding the plugins separately with different names. Then i'm looking to hit each plugin from the xib button plugin via hard coding. It worked for the original plugin, i'm having a few issues with the additional one. https://dl.dropboxusercontent.com/u/63458265/screen.tiff Thanks for your time guys!
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
01/22/15 08:50 AM (9 years ago)
I think I know what you're trying to do, and I've done it a bunch of times myself. My first thought was along the lines of the ideas above. Duplicate the plugin (with different name), and use the JSON Snippet Keeper to serve as a custom plugin, which launches the clone. Once you get your JSON straight for the "real" plugin, just paste that into a Snippet Keeper (changing the unique ID, of course). I thought I made a video tutorial on how to do this. Might be one of these: https://www.youtube.com/watch?v=tycdb94y8Bc https://www.youtube.com/watch?v=Kv5muRTn8qI Good luck!
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
01/22/15 04:49 PM (9 years ago)
Hi, thanks for that. I havent had the chance to look at all of the video content but i'm not sure it will work, i'll try and be clearer.. So i have a plugin. This plugin needs to be customised within Xcode, code changes. I need 5 versions of the same plugin but with different customisation for each. Each needs code changes. If i add the plugin and change the code, this code will be the same for all 5 screens unless i can add additional versions of the same plugin and call those? Don't know if this is clearer, I hope so! Cheers!
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
01/22/15 07:37 PM (9 years ago)
Yes. Very clear. And it's exactly what I thought you were trying to do. My instructions above will work, so I'll try to elaborate. Sad thing is, I could probably do it for you quicker than I could type it out, lol. When I said "Duplicate the plugin" above, I was really referring to making a copy of the class files (which make up the plugin), and calling them something different. I think you can do it inside Xcode, but you could also use finder to do it, and then just drag the new class (classes) into your project. [disclaimer.... make a copy of all your stuff before you attempt to follow my poorly written directions, lol] Example. If you had a plugin named CoolGame, which had CoolGame.h and CoolGame.m, you could duplicate that folder and name it CoolGame2 (with CoolGame2.m and .h). You will have to edit the code in the CoolGame2.m and h to make it understand that it has a new name now (look at the includes, etc. Any reference to the original file names need to be changed to the "2.m" names. Do this as many times as needed (5? I think you said) . At this point, you can make your code changes as you indicated. (maybe you already made these code changes, and you can skip the above steps). Ok. Here's where we make the BT control panel recognize your new "plugins". Since the CP itself only knows the "CoolGame" plugin exists, you have two options to make the CP recognize CG2, CG3, CG4, etc. 1. Create custom plugins for each, and upload them to your control panel. Make them private plugins, so they only exist in your CP (not the store). If you have made a plugin before, you know how to do this. (Package up the source code, edit the CP html file, etc). (not necessarily fun to do an extra 4 times, lol) or... 2. Use the JSON snippet keeper trick I've been alluding to. Here's how... Add your original game to your project in the control panel, and edit all the settings necessary in the CP to make the first plugin work for your app. Now, copy all the JSON from that screen (either from the bottom of the CP page, or from the bt_config.txt file) Now make 4 new JSON snippet keeper screens in your app, called CoolGame2, CoolGame3, etc (name is not important, but something easy for you to pick out of your list of screens). In each JSON snippet keeper plugin, it will have some default JSON. You can delete that out, and paste the copied JSON from the original plugin. IMPORTANT!!!! Now you have to change 2 things in that JSON. First, change the itemId in the JSON you just pasted to the itemId of the JSON Snippet plugin. Luckily, its typed in bold for you right above your JSON box (how convenient!) Second, change the "itemType" (which should be the type of plugin the original game is) to the new "plugin" or class name you created in Xcode. (i.e. CoolGame2) Once you do that, add this new screen to a menu to test it out. If everything goes right, the Snippet plugin will redirect the app to the new (duplicated) plugin. If this doesn't make sense, you can see a similar example in this video at around 17 minutes... (in the video example, i didn't have to change the itemType, because I was using the snippet for a different purpose.) https://www.youtube.com/watch?v=tycdb94y8Bc If you're still reading this, I hope it kinda made more sense, and was easy to follow. I know I recorded a full tutorial for this very reason, but I just can't find it right now. Let me know if you have any more questions. -Stobe
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
01/26/15 01:11 PM (9 years ago)
Thanks Stobe. I shall purchase the snippet keeper. I think i understand, any issues I will give you a shout if thats ok? Thanks again.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.