I didn't know the plotline was conceived of as a trilogy before I played the game, but I did know there would need to be another game to finish the story.
I've seen movies and read books where the badguy wins in the end, without that having a mojor influence on the overall quality (in fact for one particular movie I recall, the badguy winning raised it above what could have been a well done but somewhat cliché hero tracks down the demon / serial killer type plotline, and made it a better story).

The fact that you were emotionally involved enough in the plot for the ending to have that much of an effect is arguably a sign of a good ending. If you need a happy ending where everything works out perfectly and you are guaranteed never to fail, even temporarily, then you should do some research for making random RPG purchases.

My opinion is based on my opinion.