Monday, January 31, 2011

Qt is just awesome

I just have to say it over and over again.
Qt is just awesome.

Everytime I think of, for example, toolbars...How I could realize them in Qt, I just
open google and search for the tool I'd like to use and add an "Q" at the begining.

"QToolbar"
"QThread"
"QWizard"

It's always a hit.

Thursday, January 27, 2011

Finally got QT static linkage working! (How-to inside)

Yesterday I gave the current build of the leveleditor to a friend to test if the application runs correctly. He got an "Side-by-side configuration is incorrect" error when he wanted to start the editor.

After some investigation I found out that since VS2005 and Windows Vista you have to ship the Visual C++ Runtime library (Downloadlink see below) with your application to make them run properly.
(You'll notice the installation of the runtime files after you start nearly every game the first time in Valves Steam).

So you now have two choices...Either you ship your application with the runtime install files or you link the runtime library staticly to your application.Easy choice yeah...?

Well no. I was FORCED to find out that's it not that easy.

The tricky part is that every library you use in your application also has to be staticly linked with the runtime files.

So if you use foo.dll (DLL = Dynamic link library) and want to use it with your bar.exe but don't want the user to install the visual c++ runtime you'll have to compile foo.dll as foo.lib. To do that you have to open your DLL-project in Visual Studio and go to Project->Settings->Configurationsettings->Common. Set "Configurationtype" from "*.dll" to "*.lib" and choose "use MFC in a static library" at "Usage of MFC" after that go to "C\C++ -> Code generation" and change "Multithreaded Debug DLL" to "Multithreaded Debug" (Or "Multirthreaded DLL" to "Multithreaded" if you want to build a release).

If you've done that you do the same in your application project and then you are ready to go.

For QT-Developer:
If you want to staticly link Qt library you have to do the following:
  1. Download the OpenSource from the QT libraries.
  2. After you unpacked everything start the command prompt from Visual Studio.
  3. Go to the root directory of the unpacked sourcecode (the same directory where bin\ is in)
  4. Enter "configure -static" (during this process an project.sln will get created)
  5. Open Visual Studio and open the just created "project.sln"
  6. Choose the parts of QT you want to build and xo everything mentioned above to staticly link the runtime files.
If you've done that you should be able to staticly link the QT libraries.

If you don't want to link staticly, here you'll get the runtime installfiles:

Friday, January 21, 2011

Gesundheit!

I won't release a new video until end of the next week.

I didn't really program much new in the past days
because I'm down with influenza.

I hope I'll get better soon.

Thursday, January 13, 2011

QRect.setX() and QRect.setY() are evil!

I tried to tile an image using this algorythm:

 bool copyTileContainerFromImageFile( QString &fileString, QVector<Tile*> *sourceVector )  
{
if(fileString.isEmpty())
return false;
QRect rect(0,0,32,32);
QPixmap originalImage(fileString);
//goal = amount of possible tiles in this image.
int goal = (originalImage.width() * originalImage.height()) / 1024; //1024 Pixels fits in one Tile
sourceVector->reserve(goal); //reserves the amount of images in the vector.
for(int i = 0;i != goal;i++) {
sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
if(rect.x() + 32 >= originalImage.width()) {
rect.setY(32 + rect.y());
rect.setX(0);
}else
rect.setX(32 + rect.x());
}
return true;
}


the result using this algorythm was this:



If you're now like "WTF?" then I can tell you that "WTF?" was my first reaction,too.
I really had no freakin' idea why the image got tiled like THAT.

After I posted in some forums and read through the documentantion I changed
the algorythm to this:
 bool copyTileContainerFromImageFile( QString &fileString, QVector<Tile*> *sourceVector )  
{
if(fileString.isEmpty())
return false;
QRect rect(0,0,32,32);
QPixmap originalImage(fileString);
//goal = amount of possible tiles in this image.
int goal = (originalImage.width() * originalImage.height()) / 1024; //1024 Pixels fits in one Tile
sourceVector->reserve(goal); //reserves the amount of images in the vector.
for(int i = 0;i != goal;i++) {
sourceVector->append(new Tile(rect,i,originalImage.copy(rect)));
if(rect.x() + 32 >= originalImage.width()) {
rect.moveTop(32 + rect.y()); <--was setY(32 + rect.y()) before
rect.moveLeft(0); <--was setX(0) before
}else
rect.moveLeft(32 + rect.x()); <--was setX(32 + rect.x()) before
}
return true;
}

Now everything works fine.

EDIT:
Nice tool for everyone who's posting sourcecode in blogspot posts:
Code formatter

Tuesday, January 11, 2011

The problem about extreme programming

When I started with the tilesetmanager of my tileeditor I was like "How big could it be?I just do a little bit coding here and some geek stuff there and then everything should work fine".

Today is payback time.
I faced an error in the tilesetmanager and had no idea where to look for the error on the first look. No commentation and barely readable code.

I figured out the error but now I'll go and redesign the datamodel of the tilesetmanager because I can't live with the shame that I programmed something that ugly.

Long story short: I shouldn't do that anymore. (Although that's really not my style usually)

Monday, January 10, 2011

Happy new year (yeah..A little bit late...I know)

Woosa I'm back.
My holidays ended yesterday and now the cold,cruel world got me back.

Bad things first:
I really REALLY wanted to code during the holidays but I made a big mistake...I bought Oblivion G.O.T.Y Edition (Shivering Isles and Knights of Nine included) on Steam during the holiday specials and spent nearly the whole holidays playing it... But what's even worse is that I didn't even finished it. :-/ Such a big game with millions of opportunities ...agh!
Time swallowing beast!

I also realized that I apparently have something like a "programming-Karma"... Everytime I plan to do some programming but then end up gaming, my karma does something bad with my car.The last time I had to pay EUR1.400 at the car workshop (thanks to Red Dead Redemption). This time the windshield from my car got smashed during New Year's Eve (Thanks to god it costs me "only" EUR150).

Well yeah... Never mind.

What I originaly wanted to say is that I'll release a new video of the current state of the leveleditor at the end of the week.