/!\ EDITED DEC. 26/!\
Changelog:
- Routine to toggle overlay picture on and off: "Z" is used now instead of "A"
- Routine to toggle overlay picture on and off: better initialization of the 'showPict' toggle variable when used first time in session
- Instructions below updated accordingly
__________________________________________________________________
OK, as promised, here are the elements for a release candidate cockpit overlay mod.
The overlay can now be toggled on/of with the "shift z" key combo.
"Z" is apparently not used by anything.
To get there, you will have to make some changes both in "celestiacore.h" and "celestiacore.ccp".
All the changes are fully documented in the files themselves and very easy to figure out.
First, the change in the header file "celestiacore.h". We have to put in there a variable that can be used globally in "celestiacore.ccp" where the main loop of Celestia is sitting.
Look at the very bottom of "celestiacore.h" for the lines:
Code: Select all
Selection lastSelection;
string selectionNames;
#ifdef CELX
friend View* getViewByObserver(CelestiaCore*, Observer*);
friend void getObservers(CelestiaCore*, std::vector<Observer*>&);
#endif
};
#endif // _CELESTIACORE_H_
Add the "Boux" commented line as follows:
Code: Select all
Selection lastSelection;
string selectionNames;
bool showPict;// added by Boux - this variable will be used in celestiacore.ccp to toggle on/off the overlay picture
#ifdef CELX
friend View* getViewByObserver(CelestiaCore*, Observer*);
friend void getObservers(CelestiaCore*, std::vector<Observer*>&);
#endif
};
#endif // _CELESTIACORE_H_
Now in "celestiacore.ccp", there are two changes.
First, look for the "//Show logo at start" block and replace it with the following piece of code:
Code: Select all
// Show logo at start - start replacing with new code from here
if ((logoTexture != NULL) && (showPict==true))// look if there is a logo pict loaded and if we want it to show up or not
{
glEnable(GL_TEXTURE_2D); //initialize OpenGl for texture rendering
float xSize = (logoTexture->getWidth()); // get pict width
float ySize = (logoTexture->getHeight()); // get pict height
float coeffx = xSize/width; // compute pict width/view window width ratio
float coeffy = ySize/height; // compute pict height/view window height ratio
xSize = int (xSize/coeffx); // compute new picture width size to fit viewport
ySize = int (ySize/coeffy); // compute new picture height to fit viewport
float left = (width - xSize)/2; // to be sure pict is perfectly centered in viewport
int bottom = 0; //pict locked at bottom of screen
float topAlpha, botAlpha; //relative top and bottom pict transparencies
botAlpha = 1.0f; // initialization, no transparency needed here!
topAlpha = 1.0f; // initilization, no transparency needed here!
if (messageText != "" && currentTime < messageStart + messageDuration) // check for on-screen message
{
botAlpha = 0.2f; // make the bottom of pict transparent to make message visible
topAlpha = 0.8f; // keep the top of pict semi-transparent
}
else
botAlpha = 1.0f; // make the pict opaque, info is shown through small window in pict
topAlpha = 1.0f; // make the pict opaque as there is nothing to read
{
if (textEnterMode & KbAutoComplete) // check if window at bottom of screen is open by return key
{
bottom = 100; // make some room for it
ySize = ySize-100; // resize pict height accordingly
}
else
bottom = 0; // put the pict at the very bottom of screen as there is nothing to show
ySize = ySize;
logoTexture->bind(); // otherwise binary pict file garbage on screen!
glBegin(GL_QUADS); // start OpenGl rendering stuff and dynamically adjust picture to viewport
glColor4f(1.0f, 1.0f, 1.0f, botAlpha);
glTexCoord2f(0.0f, 1.0f);
glVertex2i(int (left), bottom);
glTexCoord2f(1.0f, 1.0f);
glVertex2i(int (left) + int (xSize), bottom);
glColor4f(1.0f, 1.0f, 1.0f, topAlpha);
glTexCoord2f(1.0f, 0.0f);
glVertex2i(int (left) + int (xSize), bottom + int (ySize));
glTexCoord2f(0.0f, 0.0f);
glVertex2i(int (left), bottom + int (ySize));
glEnd(); // OpenGl rendering stuff is finished
}
} // end of the logo picture overlay routine - end of new code
Now, look for this part in "celestiacore.ccp" where the keyboard is read:
Code: Select all
case '=':
renderer->setLabelMode(renderer->getLabelMode() ^ Renderer::ConstellationLabels);
notifyWatchers(LabelFlagsChanged);
break;
case 'B':
renderer->setLabelMode(renderer->getLabelMode() ^ Renderer::StarLabels);
notifyWatchers(LabelFlagsChanged);
break;
Between case'=' and case 'B' add this piece of code:
Code: Select all
//Routine to toggle overlay picture on and off
case 'Z':// added by Boux
if (showPict==true)// added by Boux
showPict=false;// added by Boux
else// added by Boux
if (showPict==false)// added by Boux
showPict=true;// added by Boux
break;// added by Boux
Build the executable, copy it in the relevant Celestia directory for your os and you are done with the code.
Now, go to your /celestia/textures/ folder and rename "logo.png" to a "logo.png_save" backup in case you want to keep the original in a safe place.
Go grab my Shuttle overlay picture there:
http://jmmi.club.fr/celestia/shut_custom_6.png
Rename it "logo.png" and put it in your /celestia/textures/ folder.
That's it. Run Celestia and enjoy the Shuttle's cockpit view and toggle it on/off with the "shift z" key combo.
Merry Xmas to all of you
![Very Happy :D](./images/smilies/icon_biggrin.gif)