DlangUI project update

Vadim Lopatin via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Jan 22 05:31:20 PST 2015


On Wednesday, 21 January 2015 at 17:16:40 UTC, data man wrote:
> And there is the ability to embed resources into .exe?

Done.

Standard resources are embedded into executable by default.

When your application uses custom resources, you can embed 
resources into executable and/or specify external resource 
directory(s).

To embed resources, put them into views/res directory, and create 
file views/resources.list with list of all files to embed.

Use following code to embed resources:

----
/// entry point for dlangui based application
extern (C) int UIAppMain(string[] args) {

     // embed non-standard resources listed in 
views/resources.list into executable
     
embeddedResourceList.addResources(embedResourcesFromList!("resources.list")());

     ...
----

Resource list resources.list file may look similar to following:

----
res/i18n/en.ini
res/i18n/ru.ini
res/mdpi/cr3_logo.png
res/mdpi/document-open.png
res/mdpi/document-properties.png
res/mdpi/document-save.png
res/mdpi/edit-copy.png
res/mdpi/edit-paste.png
res/mdpi/edit-undo.png
res/mdpi/tx_fabric.jpg
res/theme_custom1.xml
----

As well you can specify list of external directories to get 
resources from.

----

/// entry point for dlangui based application
extern (C) int UIAppMain(string[] args) {
     // resource directory search paths
     string[] resourceDirs = [
         appendPath(exePath, "../../../res/"),   // for Visual D 
and DUB builds
         appendPath(exePath, "../../../res/mdpi/"),   // for 
Visual D and DUB builds
         appendPath(exePath, "../../../../res/"),// for Mono-D 
builds
         appendPath(exePath, "../../../../res/mdpi/"),// for 
Mono-D builds
         appendPath(exePath, "res/"), // when res dir is located 
at the same directory as executable
         appendPath(exePath, "../res/"), // when res dir is 
located at project directory
         appendPath(exePath, "../../res/"), // when res dir is 
located at the same directory as executable
         appendPath(exePath, "res/mdpi/"), // when res dir is 
located at the same directory as executable
         appendPath(exePath, "../res/mdpi/"), // when res dir is 
located at project directory
         appendPath(exePath, "../../res/mdpi/") // when res dir is 
located at the same directory as executable
     ];
     // setup resource directories - will use only existing 
directories
     Platform.instance.resourceDirs = resourceDirs;

----

When same file exists in both embedded and external resources, 
one from external resource directory will be used - it's useful 
for developing
and testing of resources.

As well, it's no more required to set theme and language in 
UIAppMain if you don't want to change default values.



More information about the Digitalmars-d-announce mailing list