• ORBITER-FORUM will be temporarily closed at 2026-07-23 18:00 UTC while we complete some OF maintenance tasks. The amount of downtime is expected to take up to one hour, but probably less.

Developer Poll: Uptake of Orbiter "Help" feature

Developers: Have you used the ingame vessel or scenario Help feature?


  • Total voters
    41
Otherwise you could install PDFCreator, which adds a "virtual printer" on your system.

You normally "print" your doc (or any other file) on the PDFCreator printer, and your pdf file is created.
 
Last edited:
Maybe this workaround (and even the 50ms delay) is completely unnecessary with the new code, there is a "WaitOnReadyState" which was not here in the "simple" project.

Anyway great job ! :thumbup: A minimal window size would help also to not completely mess most of the html presentation (580px for example)

I would use the "WaitOnReadyState" For this aswell. Give the page to load and as soon as it is done, run that statement to display the text. Less buggy if you want to load images that will take a long time to load (Especially on slow computers).
 
Maybe this workaround (and even the 50ms delay) is completely unnecessary with the new code, there is a "WaitOnReadyState" which was not here in the "simple" project.

Anyway great job ! :thumbup: A minimal window size would help also to not completely mess most of the html presentation (580px for example)

I would use the "WaitOnReadyState" For this aswell. Give the page to load and as soon as it is done, run that statement to display the text. Less buggy if you want to load images that will take a long time to load (Especially on slow computers).

Just to clarify: I am already calling WaitOnReadyState, and it is precisely this function that introduced the delay. It is running through a timeout loop, each time checking if a ready condition is satisfied, but for me the condition is never satisfied, and the loop is always running to the end - so the function isn't really working as it's supposed to. However, once the function exits, the page is loading ok anyway. All I did was to reduce the timeout for the delay loop from 1000 to 50. Whether this is a robust solution - no idea.
 
but for me the condition is never satisfied, and the loop is always running to the end - so the function isn't really working as it's supposed to.

Ah okay, maybe it's missing the rest of the code (some messages?) if you used the same method than me.

Anyway if it work, it work...

Dan
 
The latest orbiter beta on orbithangar (121129) now features the embedded html viewer. Give it a try and check if it works as expected.

Note that as an "experimental feature", the simulation writes out a screenshot on exit which is then displayed in the (Current state) description. The image format is currently BMP, which is a bit wasteful and slow. I'm trying to bind in a jpeg library, which could also be useful for doing screenshots in general. In the meantime, you can suppress the screenshot from Orbiter.cfg (SaveExitScreen = FALSE).
 
Hello martins, this is a copy of my post in another (wrong?!) thread, so don't mind my arguments, you've already made the same:tiphat:
--------------------------------

Hello martins,

I really like the "CurrentState_img.htm" approach :thumbup:, ...having an image of my last burn-up is kind of cool!

But wouldn't it be better to save the image as PNG?
1st BMP is not a "standard HTML" image type,
2nd PNG would result in much smaller images
3rd it doesn't seem to be much of a problem if you are using GDI+ (see below)

With this example code you should be able to save the screenshot ass PNG:
PHP:
HBITMAP hbm = (HBITMAP)LoadImage(NULL, L"C:\\Test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); // just an exmaple to get an "BMP" image into memory

Bitmap bmp(hbm, NULL);

CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid);

Status s = bmp.Save(L"C:\\Test.png", &pngClsid, NULL);
I think the image is in memory, so the first step does not apply, but in general this should do it.
If you don't handle the screenshot anyway like this, don't mind. I just thought "BMP is soooo proprietary & non-html" ;)

...and of course you have to change the image-links to
Code:
<img src="../../Images/CurrentState.png" width="100%" />
in the CurrentState_img.htm as well ;)

/Kuddel
 
PRE formatted text display

Hi martins,

I've found a little issue in the display on non-HTML scenario description display (see attachment).
In the example a scenario of OrbiterSound40 is displayed, but somehow it's not displayed as it should be.
I have attached the scenario as well just in case you do not have it handy.

/Kuddel
 

Attachments

Hi martins,

I've found a little issue in the display on non-HTML scenario description display (see attachment).

/Kuddel

But if you ad <br> at the end of each line or paragraph, that works.
 
Last edited:
Thanks!
Regarding the missing text: I'll fix this for the next beta.
Regarding the missing line breaks: html ignores line feeds, so these disappear from the display. I could convert newlines into <br /> tags, but that's a bit of a hack. I think it's better if scenario writers eventually convert their descriptions to proper html formatting, e.g. wrapping paragraphs in <p></p> tags. With proper tags, it might look something like this:
 

Attachments

  • launchpad4.png
    launchpad4.png
    100.1 KB · Views: 21
I think it's better if scenario writers eventually convert their descriptions to proper html formatting, e.g. wrapping paragraphs in <p></p> tags.
Or just use the <pre>...</pre> tag (for pre-formatted text) around the complete text, this keeps the 'layout' of the text.
The "<br />" approach is more of a hack; with <pre> you even keep multiple white-spaces and tabs!
 
Last edited:
Or just use the <pre>...</pre> tag (for pre-formatted text) around the complete text, this keeps the 'layout' of the text.
The "<br />" approach is more of a hack; with <pre> you even keep multiple white-spaces and tabs!

I was just thinking about the <pre> tag but, after verification, it does not work
 
I was just thinking about the <pre> tag but, after verification, it does not work
I am pretty sure it does! You just have to make sure you only put one <pre>
at the beginning and a </pre> at the end of the pre-formatted text (in our case: around the complete DESCR part).

See the attachment for POC ;)
 

Attachments

Sorry it's me again ;)

On the topic of replacing newline by <br/> tags:
When you do such things you have to also replace all HTML-Entities like:
< to <
> to >
" to "
& to &

Then you are kind of 'save' :thumbup:

And you are right when you argue that the <pre> approach does not add "automatic line breaks" when you make the view-port smaller. If you/we like to have the old descriptions displayed as before (but now via HTML) you/we have to replace all those things!
 
Last edited:
I think it's better if scenario writers eventually convert their descriptions to proper html formatting, e.g. wrapping paragraphs in <p></p> tags. With proper tags, it might look something like this:

Yep but that make almost 8 years of scenarios to convert and all 2010 addons to update (Something nobody would do of course)...
It would be better to simply replace line feed with br. (I have a search_replace routine similar to php if you want,
you can also replace all the non-safe characters as "<>" into %lt etc. etc.)

This helper function can load whatewer format, bmp, jpg, png into a HBITMAP, it's used in all my orbiter
addons since years:

Code:
#include "olectl.h"

////////////////////////////////////////////////////////////////
// LOAD JPG IMAGE HELPER
////////////////////////////////////////////////////////////////
HBITMAP LoadJpgImage(char* FileName)
{
	char LoadPath[MAX_PATH*2]={0};
[COLOR="DarkRed"]       // TODO: insert full Orbiter path in loadpath so you only need to provide local relative path[/COLOR]
	strcat(LoadPath,FileName);

	WCHAR wpath[MAX_PATH*2];
	MultiByteToWideChar(CP_ACP, 0, LoadPath, -1, wpath, MAX_PATH);

	IPicture* pPic;
	if(OleLoadPicturePath(wpath, NULL, NULL, NULL, IID_IPicture,(LPVOID*)&pPic)!=S_OK)
	{
		//WriteMessageToLog("Loading Jpg failed: ",FileName);
		return NULL;
	}

	HBITMAP hPic = NULL;
	if(pPic->get_Handle((UINT*)&hPic)!=S_OK)
	{
		//WriteMessageToLog("Loading Jpg get_handle failed: ",FileName);
		pPic->Release();
		return NULL;
	}

	HBITMAP hPicRet = (HBITMAP)CopyImage(hPic, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG);
	if(!hPicRet)
	{
		//WriteMessageToLog("Loading Jpg copy image failed",FileName);
		pPic->Release();
		return NULL;
	}

	pPic->Release();
	return hPicRet;
}
 
Last edited:
This helper function can load whatewer format, bmp, jpg, png into a HBITMAP:

Hi dansteph,

I think loading (png/jpg) is not the problem here, that is done by the HTML-Renderer (IE in our case). The problem is saving the screenshot to any other format than BMP.
But I might take your code if I am in a situation where I have to load some :thumbup:
/Kuddel
 
Ooops sorry, too fast reading. Here it is so you have both:

Code:
#include "olectl.h"
#include <ocidl.h>
#include <atlbase.h>

////////////////////////////////////////////////////////////////
// SAVE HBITMAP TO JPG IMAGE HELPER 
////////////////////////////////////////////////////////////////
void SaveJpg(HBITMAP hbm, char *pszSaveFile)
{
	PICTDESC pd = { sizeof(pd), PICTYPE_BITMAP };
	pd.bmp.hbitmap = hbm;

	CComPtr<IPicture> pPicSave;
	HRESULT hr = OleCreatePictureIndirect(&pd, IID_IPicture, TRUE, (void**)&pPicSave);
	_ASSERT(SUCCEEDED(hr));

	CComPtr<IStream> pStr;
	hr = CreateStreamOnHGlobal(NULL, TRUE, &pStr);
	_ASSERT(SUCCEEDED(hr));
	LONG size = 0;
	hr = pPicSave->SaveAsFile(pStr, TRUE, &size);
	_ASSERT(SUCCEEDED(hr));
	_ASSERT(size);
	
	// rewind stream
	LARGE_INTEGER start = {0};
	hr = pStr->Seek(start, STREAM_SEEK_SET, NULL);
	_ASSERT(SUCCEEDED(hr));

	FILE* fsave = fopen(pszSaveFile, "wb");
	if(fsave)
	{
		DWORD read, total = 0;
		BYTE buf[256];
		do
		{
			read = 0;
			hr = pStr->Read(buf, sizeof(buf), &read);
			if(SUCCEEDED(hr))
			{
				total += read;
				fwrite(buf, 1, read, fsave);
			}
		}
		while(read);
		_ASSERT(size == total);
	       fclose(fsave);
	}

}
 
Last edited:
Hello Docteur Schweiger,

The attached file (notes.zip at the end of this message), contains a lite version of an interface - work in slow progress ;) - for the online help, of which I sometimes spoke on the forum, describing it's principle.

A chm (notes.chm, here) containing - and containing only - a function, that you know (parser / link to an external file), ...
http://msdn.microsoft.com/en-us/library/ms644690.aspx
... giving the possibility to display, with Internet Explorer, an html page ( once again: external to the chm ) - notes.htm, here - being able to serve, itself:

- of relay for others pages through a menu, modifiable, supplied - in doc write - by a file text (liens.txt, here);
- and/or of toolbox for other functionalities offered by javascript (in the complete full file : timer, video flv).

This device was not, is not, in my mind, destined to be displayed in the launchpad (I have besides discover this possibility only very recently), but in Orbiter, in full screen (F4/Help/scenarios).

But, by the fact, if i discover, now, that it works in the launchpad, with the 2010 P1 version, this is not the case with the last beta 121129-100830diff.

Is this the fact of the supported code (or not supported) by the new viewer ? Something related to the parser function ?

Other interrogation:

- In quicksave or in current state, the original's Help lines in scenarios files becomes "Help CurrentState_img".

At last, being the question of the pdf editor, it was a confusion on my part: I wanted to say pdf viewer.


NB: This file - "notes.zip" - is to be unziped in Orbiter as any addon.

A scenario file for essay: "notes.scn", is available at the root of the Scenarios folder. Once inside Orbiter: F4/Help/scenarios, as usual.

Work with IE6 and XPSP1. With IE 7 AND XPSP2 or 3 in the CHM file (if my memory is good), and in any case with necessary authorizations in IE for javascript. Vista ? Seven ? IE8 ?

The display of a standard pdf necessitates an IE compatible viewer (Acrobat Reader, ver 5.0 here, Foxit first or second versions, and. ..) and the abscence of a welcome screen in the viewer (to see: options Acrobat Reader).
 

Attachments

Last edited:
While we are talking about help features:

Would it be possible to have a function in the API, that permits highlighting a position in a VC or Panel2D, by drawing a circle-like shape (maybe animated, depending on Client) over the position?

For example: You have a tutorial scenario. In this tutorial is a Lua script, that highlights a switch in the VC. Until you flip this switch (Vessel module sends event to Orbiter), the switch remains highlighted. After you flipped the switch, the highlight is switched to an indicator, that now changes because of the switch action with the tutorial explaining the resulting behavior.
 
For 2D panels, something like this is already possible with the Lua oapi.set_panelblink function. For a demo on how this works see the Tutorials|ADI training scenario. Is this what you had in mind? It should be possible to extend this to virtual cockpits as well.
 
Ooops sorry, too fast reading. Here it is so you have both:
<snip>
Hi Dan, thanks for the code. I'll try that!

Two questions though:
1. Where is the JPEG output format set? Nothing in this code seems to indicate in which format the bitmap should be written. Or is .jpg the default file format for IPicture objects? Is it possible to store it in other formats as well? Is there a way to modify the jpeg parameters, e.g. compression ratio, etc?
2. Why are the image data first written to a memory stream and then copied to a file? Wouldn't it be easier to just open a file stream and write the image directly to that?

Edit: I just tried that SaveJpg function, but for me this writes out a bmp file! Is there anything I am missing here?
 
Back
Top