Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
op2_sdk:textdialogbox [2016/03/28 13:35] – vagabond | op2_sdk:textdialogbox [2016/12/28 19:03] (current) – vagabond | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== In Game Text Dialog Box ====== | ====== In Game Text Dialog Box ====== | ||
- | A text dialog | + | The Outpost 2 SDK supports adding custom |
- | Creating | + | Creating |
* Write up the briefing/ | * Write up the briefing/ | ||
* Add a resource script (.rc) to the project detailing the design of the dialog box. | * Add a resource script (.rc) to the project detailing the design of the dialog box. | ||
* Add a resource header file (typically resource.h) to the project providing a link between the resource script file and the rest of the source code. | * Add a resource header file (typically resource.h) to the project providing a link between the resource script file and the rest of the source code. | ||
+ | * Include odasl in your project. | ||
* Add code to the scenario that formats and opens the dialog screen through the windows API. | * Add code to the scenario that formats and opens the dialog screen through the windows API. | ||
Line 18: | Line 19: | ||
Typically, the RTF file is saved as briefing.rtf and added to the root directory of the scenario' | Typically, the RTF file is saved as briefing.rtf and added to the root directory of the scenario' | ||
- | **Note: | + | **Note:** Although Microsoft Word can create and save RTF documents, it is not recommended. Microsoft Word adds large amounts of metadata to the document that is not necessary for Outpost 2, typically increasing a small amount of text from about 3 kb to about 50 kb. This file size increase will carry into the compiled DLL. |
**Example RTF file** | **Example RTF file** | ||
Line 49: | Line 50: | ||
To add a resource script file and associated resource header: | To add a resource script file and associated resource header: | ||
- | right click on your project in the solution explorer. -> Add -> New Item... -> Visual C++ -> Resource -> Resource File (.rc) -> Add. | + | - Right click on your project in the solution explorer. -> Add -> New Item... -> Visual C++ -> Resource -> Resource File (.rc) -> Add. (Using the default filename is fine.) |
- | Resource Scripts by default | + | By default |
Below is a sample resource script file that provides a dialog box before a scenario is initialized. The dialog box will include the contents of briefing.rtf in a rich text box. | Below is a sample resource script file that provides a dialog box before a scenario is initialized. The dialog box will include the contents of briefing.rtf in a rich text box. | ||
Line 57: | Line 58: | ||
For more information on TEXTINCLUDE, | For more information on TEXTINCLUDE, | ||
- | #ifdef // | + | **Common Pre-processor Directives: |
- | #ifndef // | + | * #ifdef // |
- | + | * #ifndef // | |
- | #undef // | + | |
+ | **Resource Script Sample** | ||
<code cpp> | <code cpp> | ||
// Microsoft Visual C++ generated resource script. | // Microsoft Visual C++ generated resource script. | ||
Line 221: | Line 223: | ||
===== Resource.h | ===== Resource.h | ||
+ | |||
+ | Once the Resource Script is added, the project will not successfully compile until all required items are defined in the resource header. Visual Studio will automatically create a resource header when the resource script is created. Typically, 5 items are defined in resource script as shown in the sample below, IDR_MISSIONTEXT, | ||
Microsoft Resource Naming and Numbering Conventions can be reviewed here: https:// | Microsoft Resource Naming and Numbering Conventions can be reviewed here: https:// | ||
Line 235: | Line 239: | ||
**Note:** //0x prefix on a number indicates it is in hexadecimal form.// | **Note:** //0x prefix on a number indicates it is in hexadecimal form.// | ||
+ | **Resource Header Example** | ||
<code cpp> | <code cpp> | ||
// | // | ||
// Microsoft Visual C++ generated include file. | // Microsoft Visual C++ generated include file. | ||
- | // Used by RisingFromTheAshes.rc | + | // Used by Resource.rc |
// | // | ||
#define IDR_MISSIONTEXT | #define IDR_MISSIONTEXT | ||
Line 261: | Line 266: | ||
===== Creating the Dialog Box in Code ===== | ===== Creating the Dialog Box in Code ===== | ||
- | Once the resource script and resource header have been well formed, the briefing screen | + | Once the resource script and resource header have been included, the briefing screen |
- | First, you will require | + | - Add a reference to the Outpost2Dialog project, which can be found with the rest of the APIs. odasl.h and odasl.lib are contained in this project and are required to skin the Dialog Window in the Outpost 2 theme. |
+ | - Create | ||
+ | - Add code to initialize and open the window. Typically this code is placed in it's own cpp file named briefing.cpp. | ||
+ | - Call code to initialize the window from '' | ||
+ | |||
+ | **Defining a handle to the DLL instance from DllMain:** | ||
**DllMain.cpp** | **DllMain.cpp** | ||
Line 285: | Line 295: | ||
</ | </ | ||
- | **briefigin.h** | + | **Code used to initialize window. This also may be written without a header file.** |
+ | |||
+ | **briefing.h** | ||
<code cpp> | <code cpp> | ||
#pragma once | #pragma once | ||
Line 365: | Line 377: | ||
- //Go Back to [[op2_sdk: | - //Go Back to [[op2_sdk: | ||
- //Go Back to [[outpost_2: | - //Go Back to [[outpost_2: | ||
- | - //Go Back to [[http:// | + | - //Go Back to [[http:// |