Resources: a couple of questions and a suggestion about them

This forum is currently in read-only mode.
  • Ok, so I'm fairly certain there's no Resource Bar anymore. (It's still in the wiki, and the Object Bar isn't, but that's a different issue) I could probably go back and pore through the changelogs and see when that happened, but I'm guessing it was with the release of 0.99 (do I win a cookie?)

    So there's that neat little tree hierarchy in the Project Bar instead, and sections for "Sounds" and "Music" and "Fonts" and whatnot. That's what I want to discuss.

    "Sounds" can be .WAV or .OGG, which is awesome, and probably typical of what most people need.

    On the other hand, "Music" could probably use a tiny bit of fine-tuning. Presently, you can choose from:

    • .WAV files. Alright. No sense restricting your options, I guess, but heaven help you if you're including music of any length, because you're talking tens of megs per file.
    • . MP3 files. Cool. Standard enough that they should be here, and it's what everyone associates with music anyway.
    • .WMA files. Neat, whatever. Although I don't care for the format personally, I'm sure people use it for music, especially music they got from other places.

    Notably, though, you can't include .OGG files in "Music." Which seems strange, given that it's a format made for, you know, music. Not that it's not a perfectly good format for sound effects as well, but it would be nice to say "Hey, Construct, I want to stop whatever music is playing" instead of "Hey, let's figure out what channel I arbitrarily set the music to, which will of course be listed as a sound effect and not music anyway, and stop it."

    So, I suggest that little change be made. It's a pretty minor thing, really.

    Of course, that's all completely moot right now, because resources simply don't seem to show up at all in the dropdown for the XAudio2 object, regardless of whether they're in "Music" or "Sounds." I can only assume that's all something that's being worked on right now (I'm on 0.99.9, if that makes any difference). If this is a bug, rather than just the expected state of things, could someone let me know?

    While you're presumably working on that, mind making the "Fonts" resource section actually work? It would be tremendously helpful, as presently the install packager doesn't seem to have the functionality to include fonts either, which means it's necessary to use a third-party installer if any non-standard fonts are being used in the game. That, in turn, means that the person installing the game needs to run the installer in Admin mode, and that just opens up a whole bucket of worms.

    Ok, that's all I've got for now.

  • All resources need to go into the "files" folder on the project bar, the sounds, music, and fonts folders are not fully implemented yet. The XAudio plugin retrieves resources from the "files" folder. If you want to access resource files outside of XAudio use the Resource Plugin.


    It's possible to make your game install your own fonts.

    Add the font to the "files" folder of the project bar.

    Use the "File" and "Path" plugins to see if the font is in the windows font directory.

    If it isn't, use the "Resource" plugin to extract the font and then copy it to the windows font directory.

    Then display a message to the effect that a font was installed and you need to restart the program.

    Then close the program.

    I'll make a cap if that helps.

  • That actually makes better sense, as I didn't see anyone complaining that resources weren't working, per se. It's just the first time I've tried to mess with them, and there's literally nothing in the usual places to suggest a better way to do it.

    As for the fonts, sure, I'd very much appreciate a .cap that does what you explained. Outside of playing sounds directly from files, and using the Array object's save-to and load-from file features, I've done basically nothing at all with files in Construct.

    Of course, there may still be the issue of having to run the program as Administrator in order to install fonts, since that directory is typically writable only with admin permissions. I found a C# routine to temporarily load fonts until the next time Windows is restarted, and I may have to resort to that if your solution doesn't solve it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • My method on installing a font from a game is flawed, while I got it to work in XP it doesn't work in vista.

    I found another way. Sounds like it's the same way you spoke about where the font will only be loaded until a restart. I plan on adding this to my resource plugin, but until then here's an example using python.

    Note: you will probably need to install python for this to work as it requires the "ctypes" module.

    made with 0.99.84

  • That worked great for me, until it crashed (on exit). But it's awesome that you made it happen!

    Not that this necessarily is the place for it, but on the off chance it helps you with writing your plugin, here's basically what I'm doing in C#:

    namespace LaunchWithFonts
        class Program
            static extern bool RemoveFontResource(string lpFileName);
            static extern int AddFontResource(string lpFilename);
            static void Main(string[] args)
                Console.WriteLine("Loading dependent font files...\r\n");
                //Set these to actual font names being used in main executable.
                String[] fonts = { "font1.ttf", "font2.ttf", "font3.ttf", "font4.ttf" };
                //Load game .exe (edit to the correct file name first)
            public static void LoadSomeFonts(string[] strFilesToProcess)
                if (strFilesToProcess.Length < 1)
                for (int i = 0; i <= strFilesToProcess.GetUpperBound(0); i++)
                    FileInfo objFileInfo = new FileInfo(strFilesToProcess[i]);
                    if (!objFileInfo.Exists)
                        Console.WriteLine("Couldn't find font: {0}", objFileInfo.Name.ToString());
                    objFileInfo = null;
    It's cobbled together from a couple of sources, and some work of my own, so my apologies if it looks a little sloppy.
    edit: Apparently I had that routine set up with a 1-index and not a 0-index, oops! Too much Construct for me these days, and not enough C++/C# I guess.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)