qmake & data files

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

qmake & data files

Post by Nokurn »

Hi,

Wanting a mature, object-oriented, cross-platform solution for creating OpenGL applications and complex--yet native--user interfaces, I recently turned to Qt. Its near-total cross-platform nature was appealing to me, as I regularly work in Mac OS X, Windows, and Linux, and maintaining separate project files for each platform is always a pain in the ass. I'm not very familiar with Qt or its toolkit, so I am working on a simple project to introduce me to the workflow with Qt Creator before jumping into the project I want to eventually create using Qt.

In the past, Qt Creator's internal use of qmake has been the obstacle preventing me from making the switch to using Qt Creator as my IDE of choice; a fact I've mentioned before on these forums. Coming from the near-infinite configurability of IDEs like Visual Studio and Xcode, I feel like, in its quest to be cross-platform, it takes the "lowest common denominator" approach too far and as a result is not very flexible and can be rather weak for certain things. However, I am trying to overcome this relatively minor issue to gain access to the vast power that the Qt system as a whole can offer.

I've come to accept the concept of shadow builds, but now I am faced with a troubling problem: a clean and consistent means of accessing common data files between projects at runtime (i.e., not built into the binary with a .qrc script). My project directory is set up as follows,
  • Project
    • Data
      • ... images, fonts, scripts, sounds, zones, etc ...
    • Editor
      • ... source code for the data editor, which operates directly on the contents of the Data folder ...
    • Engine
      • ... source code for the static engine library, which contains location-neutral classes for reading and writing formats used in the Data folder ...
    • Game
      • ... source code for the game itself, which uses the contents of the Data folder ...
Typically, in Visual Studio (2010), I would set $(SolutionDir) as the debugger working directory, add the .vcxproj.user file to version control, and use "Data/whatever" to access data files. This prevents duplication of the Data folder. However, with Qt Creator, the debugger working directory is an absolute path in the .pro.user file--which also contains an abundance of absolute paths and shadow build settings, which means I can't add it to version control. So, how the hell do I get the path to the Data folder without hardcoding anything?

Additionally, once deployed, I want things to look like this on Windows:
  • %ProgramFiles%\Project
    • Data
    • Editor.exe
    • Game.exe
    And this on Mac:
    • /Applications/Game.app
      • Contents
        • Resources
          • Data
        • ... other bundle stuff ...
      • /Applications/Editor.app
        • ... bundle stuff ...
(The Editor application has a folder selection dialog box, which chooses the Data folder it will operate on, so it can be installed separately from the Game application and still function)

I figured doing something like this would be fairly common, but several months of sporadic Googling have revealed next to nothing. Maybe I'm approaching this completely wrong. If so, please share the right way to do it.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: qmake & data files

Post by Falco Girgis »

That is a good question. I'm sure there must be a debugger setting for the working directory...

We actually have the exact same setup for our Engine and Toolkit. We've been able to avoid this problem, because you still have to go to File->Open Project and specify the working directory yourself...
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: qmake & data files

Post by Nokurn »

GyroVorbis wrote:That is a good question. I'm sure there must be a debugger setting for the working directory...

We actually have the exact same setup for our Engine and Toolkit. We've been able to avoid this problem, because you still have to go to File->Open Project and specify the working directory yourself...
That makes sense for the Toolkit, and is very similar to what I am planning on doing. I suppose you haven't faced this problem with the Engine though, right? Since you're using Visual Studio and Xcode for that. I guess that if I can't come up with a decent solution to this problem I could just use a setup similar to what you have. Was hoping to avoid the multi-IDE bullshit though. :/
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: qmake & data files

Post by Nokurn »

I am looking around in the Qt Creator source code for a way to do this. If I can't find anything I might just make a plugin for it, or modify Qt Creator itself.
Post Reply