Author Topic: Ufopaedia development  (Read 31133 times)

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Ufopaedia development
« on: December 19, 2010, 12:20:08 am »
Hi,

I'm going to implement Ufopaedia in the next weeks. This thread is to keep you updated on the progress.
Here is the plan:

Milestone 1 - learning:
* try to put together a simple article to learn about State behaviour and resource management.

Milestone 2 - present all kinds of articles:
* identify all types of articles: Mission, Alien description, Weapons, Crafts, Base tiles, ...
* present various types of articles with navigation

Milestone 3 - complete material:
* put together all material from Access List to Cydonia
* some article data might be configurable (Weapon stats, base item properties, etc.)

Milestone 4 - final version:
* articles must be activated by game mechanics
* current viewable articles must be stored in/loaded from saved games

Please let me know if I missed something. But Ufopaedia doesn't have any bugs that could be reproduced as far as I know ;)

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Ufopaedia development
« Reply #1 on: December 19, 2010, 12:41:06 pm »
Have you talked to SupSuper yet, preferably over IRC?
As a contributor to openXcom, I can only give you the advice to start with a few babysteps.
Milestone 2 is very general.
I would have done something like this: "Milestone 2 - create a UfopaediaState class: a screen with a background image and an OK button. This state is launched when you press the ufopaedia button. When you press the OK button, you go back to the geoscape."
Done.
But I'm afraid you will bump into a lot of voids still in this very early stage of the game... new interface objects will need to be made, a structure to hold together all ufopaedia data.... RuleItems that read out of OBDATA.DAT, Rules for soldiers armour, Rules for HWPs, the whole Research structure... you'll need all that to build the ufopaedia on top.
I'm afraid SupSuper had a reason to put Ufopaedia on release 0.6 in the roadmap....

But I'm not the guy to discuss this with, just warning you upfront of possible obstacles :)
« Last Edit: December 19, 2010, 12:44:07 pm by Daiky »

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: Ufopaedia development
« Reply #2 on: December 19, 2010, 04:00:40 pm »
I think that for now you just could create some basic prototype of ufopaedia. Concentrate on layout, showing images, description, without stats.

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #3 on: December 19, 2010, 10:13:25 pm »
Thanks for the warning Daiky! I'm currently finding my way into the code and build a general structure for Ufopaedia articles.
I'm aware, that I cannot finish it before the whole structure is done. The milestones don't have a date tag yet ;)

As michal said, I will concentrate on layout and navigation. Getting real values from game stats is in MS 3.

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #4 on: December 20, 2010, 12:39:51 am »
Well, I was warned. :)
I put together a simple Article state and it works...nearly... ;)

I'm sure you saw such images before. Can someone please give me a hint on how the Palettes have to be set correctly?

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: Ufopaedia development
« Reply #5 on: December 20, 2010, 08:43:34 am »
I guess you should do it same way as in battlescapestate (line 101):

https://openxcom.svn.sourceforge.net/viewvc/openxcom/trunk/src/Battlescape/BattlescapeState.cpp?revision=225&view=markup

But in your case i think PALETTES.DAT_3 should be used, according to:
https://www.ufopaedia.org/index.php?title=PALETTES.DAT#UFO

(4. Research Displays.)

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #6 on: December 20, 2010, 06:39:00 pm »
Thanks, I guess I understand now. The new screen looks much better now :)

I made some screenshots from the original Ufopaedia to match colors etc. accurately.
It's not there yet, but Milestone 1 is within reach...

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #7 on: December 20, 2010, 11:04:57 pm »
Milestone 1 reached!

A small step for sure, but I'm happy it worked out so fast. :)
The first simple Ufopaedia article is here.
As you can see, the border is correct now (I was using Window instead of a Surface),
the colors of the buttons and texts changed and the positions are like in the original game.

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: Ufopaedia development
« Reply #8 on: December 21, 2010, 08:34:29 am »
Good start :)

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #9 on: December 27, 2010, 02:55:23 am »
Just a small update:
1.) the Alien lifeform screen works now. (see screenshot)
2.) Navigation (left, right) already works.

I have already implemented some management code like a factory to get article screens, article class structures, etc.
There is a feature I miss with the text handling. It should be possible to calculate, if a given text fits into the text box, or otherwise, to calculate how large the text will be, when rendered.
The reason is, that some Titles are two liners (like f.i. "Cyberdisk autopsy") where the screen layout must change...

What I missed completely is the main Ufopaedia dialog and the list screens, so these are also on my todo list now. :)

Offline sir_nacnud

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Ufopaedia development
« Reply #10 on: December 27, 2010, 03:22:32 am »
I was looking at your screen shot for Sectoid and was wondering how the description text is handled.  Is that just one big string that you are relying on text wrapping to put it in to paragraph form?  If that is the case, looks like there is a bug with text wrapping, as the seventh line includes the space(s) between the period and "They".  I think we would want to remove the staring spaces if the line is wrapped.  This will correctly align the text, as of right now it doesn't look very good with the seventh line indented.

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #11 on: December 29, 2010, 09:37:19 pm »
The text is saved in one chunk. Right now, there is no possibility to check for text wrappings or positioning AFAIK.
But I see this is an annoying issue, so I will definitely try to work on this next. The same problem arises with the two-liner headlines mentioned before...

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: Ufopaedia development
« Reply #12 on: January 02, 2011, 01:19:50 pm »
Word wrapping is pretty easy, here's a pseudo code implementation of how I usually do it:

Code: [Select]
Function DrawWrappedText( String TextToDisplay, Int StartX, Int StartY, Int WrapAtWidth )
{
  Int lineStartIndex, lineEndIndex, lineWidth
  Int drawY
  String TextLine

  lineStartIndex = 0
  drawY = StartY
  While( lineStartIndex < TextToDisplay.Length )
  {
    lineEndIndex = lineStartIndex
    lineWidth = 0

    https:// Find the first character that takes us beyond our limit (or to the end of the text)
    While( lineWidth < WrapAtWidth || lineEndIndex == TextToDisplay.Length - 1 )
    {
      lineWidth += GetCharacterWidth( TextToDisplay[lineEndIndex] )
      lineEndIndex++
    }

    https:// start tracking backwards looking for the first word break character (but only if it causes a wrap)
    While( TextToDisplay[lineEndIndex] Not In ( ' ', '.', ',', '!', '?', ')', '-' ) && lineWidth >= WrapAtWidth )
    {
      lineEndIndex--
    }

    https:// Get and draw the substring
    TextLine = SubString( TextToDisplay[lineStartIndex], lineEndIndex - lineStartIndex )
    DrawText( TextLine, StartX, drawY )

    https:// Move down a line (assuming all characters are same render height)
    drawY += GetCharacterHeight( TextToDisplay[lineStartIndex] )

    https:// Start from the next character after the break
    lineStartIndex = lineEndIndex + 1
  }
}

Hope that helps

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #13 on: January 02, 2011, 10:51:23 pm »
Thanks,
word wrapping is already implemented in the Text class. I extended it now to trim spaces in line beginnings.
I want to finish the Start dialog and the Select-Item screen next, this would be my Milestone 2.

Maybe I can merge my code into trunk then? I will try to make a patch file for the changes.
I have made only two rather minor changes in existing code to make it work.

The next big step for Ufopaedia will be implementing the articles, that depend on game rules like crafts, weapons, HWPs, base elements, ...
But this will depend more on other people's code. So maybe we can discuss about this some time or other via chat or PN?

Offline panther

  • Sergeant
  • **
  • Posts: 42
    • View Profile
Re: Ufopaedia development
« Reply #14 on: January 27, 2011, 12:30:50 am »
Just as an update, I'm still working on Ufopaedia.
After a good e-mail discussion with SupSuper, I will scratch what I've coded so far and rebuild the thing in a completely new structure. :)
There are also a lot of changes going on in classes I need to interface, so I'm planning to attach Ufopaedia after to 0.2 release.