Change the icon in code on a Mac
BlitzMax Forums/BlitzMax Programming/Change the icon in code on a Mac
| ||
Hi, I have some neat code to change the icon for my PC games, but has anyone managed to do this in code for the Mac? I've found this thread which tells you how to do it manually: http://www.blitzbasic.com/Community/posts.php?topic=41986 and this one: http://www.blitzbasic.com/Community/posts.php?topic=41222 But neither do it in code. Is that even possible? Thanks in advance for any help you can offer. |
| ||
Since the icon isn't actually part of the executable, but is part of the application package, it's probably a little more difficult than on Windows. Maybe you could edit the info.plist file inside the package in code to point to a different icon name. I don't know if that would be picked up on the fly, though. |
| ||
Hmm, OK so when you compile an app on a Mac, it makes the package folder and gives it the BMax icon, but I was wanting to find some way to automatically make that icon a GAME icon. Perhaps it's an IDE issue? As if you could specify it in the IDE, it could make the package with the correct icon right? |
| ||
Yes, I think it would have to be done from the IDE, or with a program that was executed after the package has been created. |
| ||
As jhanson says, the IDE would likely be a good place to have this functionality. You kind of want a cross-platformable "Customize your project Icon" window - where you can specify a set of icons (different sizes) to be deployed with your application, included in the package on Mac, stored as application resources on Windows... :o) |
| ||
sounds fantasic. Yes the IDE should have it built in... |
| ||
If we could add scripts to the build process this would be easy to do. I bash: cp myGame.icns myGame.app/Contents/Resources/myGame.icns after building but it would be nice if I could run that as part of the build |
| ||
Agreed. How do you turn that into a script or batch file equivalent on a Mac (I'm a Mac noob) as I'm still copying it in manually each time. Thanks. |
| ||
Can bash scripts be invoked via system_ command? If yes, it should be easy changing the IDE to manage this script, modifing the BuildSource Method (standard IDE). |
| ||
yeah.. I have that in a file called blabla.bash then in the console you'd do bash blabla.bash There's ways to use variables in a bash script so it would be something like cp $var.icns $var.app/Contents/Resources/$var.icns but I'm not exactly sure how you do it. |
| ||
I'm testing this piece of codeLocal fileicon$=RequestFile("Icon name") local fileapp$=RequestFile("Application name") local newfileicon$="/"+StripDir(fileIcon) local com$=chr(24)+"cp "+fileicon+" "+fileapp+"/Contents/Resources"+newfileicon+chr(34) system_ com print "ICON: "+fileicon print "APP : "+fileapp print "COM : "+com but I have an error when running the 'com' instruction: No such file or directory Any clue? In any case I've tested via Terminal to change the icon like suggested, but I dont' understand if ICON_NAME and APP_NAME *must* be identical or not... Tested on Mac OS X 10.3.9 - Bmax 1.26 |
| ||
Have you put .app on the end of fileapp? You need it. |
| ||
I run the program and I choose this 2 files: Font.icns Font.app In the output window of MaxIDE I can see the name of the choosen files (and they are correct). The error raises in the call to the system_ command sh: line 1: cp /Users/degac/Desktop/Font.icns /Users/degac/Desktop/Font.app/Contents/Resources/Font.icns: No such file or directory For test I copied&pasted the cp... to the Terminal - no error |
| ||
The error message is telling you that there is no command called "cp /Users/degac/Desktop/Font.icns /Users/degac/Desktop/Font.app/Contents/Resources/Font.icns". It appears that system_ is taking your string literally - which isn't what you want it to do. You may find there's less hassle to use Stream Read/Write to do a "copy". |
| ||
Doh! Thanks to clear out the problem. |