Using GeLoadString to load description string



  • On 17/02/2014 at 07:12, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R15 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    I have a RegisterObjectPlugin and I would like to use some strings defined in the string resource file.
    However it returns "strNotFound". The plugin is working and the description is shown

    	Bool ret = RegisterObjectPlugin(ID_SOLAROBJECT, PluginName, OBJECT_GENERATOR, SolarObject::Alloc, "Osolar", AutoBitmap("solar.tif"), 0);
    	if (ret) 
    	{
    		GePrint ("About: " + GeLoadString(ABOUT));
    	}
    

    Part of the resource file

    STRINGTABLE Osolar
    {
    	    ABOUT   "About";
    

    Resource init is done in main.cpp

    Bool PluginMessage(Int32 id, void* data)
    {
    	switch (id)
    	{
    		case C4DPL_INIT_SYS:
    			if (!resource.Init())
    				return false;		// don't start plugin without resource
    


  • On 17/02/2014 at 08:09, xxxxxxxx wrote:

    When using GeLoadString(), you must put the string in the c4d_strings.str file, not your custom plugin file, at least it is so in accordance with my experience.



  • On 17/02/2014 at 08:20, xxxxxxxx wrote:

    I put it in c4d_strings.str, but still strNotFound is returned.
    The file is allocated here:
    D:\Program Files\MAXON\CINEMA 4D R15\plugins\solar system kit v10\res\strings_us
    Is that correct?
    Should ABOUT have an ID, different than the resource id?

    // C4D-StringResource
    // Identifier	Text
      
    STRINGTABLE
    {
      ABOUT " Build 01024";
      }
    


  • On 17/02/2014 at 08:33, xxxxxxxx wrote:

    Have you assigned an enumeration to ABOUT in the c4d_symbols.h file?



  • On 17/02/2014 at 08:54, xxxxxxxx wrote:

    I did now, what nothing yet.
    It is recognized by vs, because when I hoover over it tells me:
    enum <unnamed> :: IDS_ABOUT = 10002

    enum
    {
    	// string table definitions
    	IDS_GRADIENTTITLE	= 10000,
    	IDS_TYPE,
        IDS_ABOUT,
        
    // End of symbol definition
    	_DUMMY_ELEMENT_
    };
    


  • On 17/02/2014 at 09:03, xxxxxxxx wrote:

    And you will need to use IDS_ABOUT in your references.  Realize that IDS_ABOUT may already be defined by C4D.  Use something unique like IDS_ABOUT_MYPLUGIN to avoid confusion during compilation and execution.



  • On 17/02/2014 at 10:23, xxxxxxxx wrote:

    Thanks, it is working now.
    So if you have different languages, you must get the LanguageID and set you string accordingly.
    So for example, IDS_ABOUT_US, IDS_ABOUT_DE, etc.?



  • On 17/02/2014 at 15:18, xxxxxxxx wrote:

    No, just use a different file for the strings, the ID is the same.



  • On 18/02/2014 at 02:09, xxxxxxxx wrote:

    sorry, I do not think so.

    The res files are language dependent, but c4d_strings.str is not language dependent?



  • On 18/02/2014 at 02:50, xxxxxxxx wrote:

    The whole purpose (at least some of it) if using IDs, is that the IDs remain, you just use different language (strings) files.



  • On 18/02/2014 at 03:37, xxxxxxxx wrote:

    IMO that is correct for .str as part of the resource files.
    I am now using c4d_symbols.h and c4d_symbols.str, not part of the resource files.
    I guess that is the only way to use GeLoadString(id)?

    I also wonder about c4d_symbols.h and c4d_symbols.str. What is the use of them when you have resource files?



  • On 18/02/2014 at 03:59, xxxxxxxx wrote:

    Hi, others here are certainly better to answer this, but I know this much:
    Look at the folder yourplugin/res/strings_us
    In this folder you put US English strings.
    You will have other folders for other languages, of course.
    The c4d_symbols.str is for strings independent of your classes, "global strings" if you like.
    The other, class specific strings, have their own *.h, *.cpp, *.res, *.str files.



  • On 18/02/2014 at 04:35, xxxxxxxx wrote:

    Ok, but I thought based on the replies in this post, that GeLoadString(id) only works with c4d_symbols.h and c4d_symbols.str?



  • On 18/02/2014 at 04:43, xxxxxxxx wrote:

    Class-specific strings are automatically loaded with Register...() for your plugin and are associated with its descriptions directly.  Global strings need to use GeLoadString() wherever needed because there is no direct association (in a dialog or the console or statusbar etc.).



  • On 18/02/2014 at 04:47, xxxxxxxx wrote:

    Ok, thanks.

    Conclusion: Global strings need to use GeLoadString() and are defined in c4d_symbols.h and c4d_symbols.str and are in only one language (not langugae dependent).



  • On 18/02/2014 at 06:10, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Conclusion: Global strings need to use GeLoadString() and are defined in c4d_symbols.h

    Yes

    Originally posted by xxxxxxxx

    and c4d_symbols.str and are in only one language (not langugae dependent).

    No



  • On 18/02/2014 at 08:56, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Ok, thanks. Conclusion: Global strings need to use GeLoadString() and are defined in c4d_symbols.h and c4d_symbols.str and are in only one language (not langugae dependent).

    Incorrect, c4d_strings.str is _inside_ the folder strings_us so all you do is create another c4d_strings.str in a different language and make sure it is in the correct folder for that language. AIUI Cinema will use the correct one when you call GeLoadString().



  • On 18/02/2014 at 09:24, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Originally posted by xxxxxxxx

    Ok, thanks. Conclusion: Global strings need to use GeLoadString() and are defined in c4d_symbols.h and c4d_symbols.str and are in only one language (not langugae dependent).

    Incorrect, c4d_strings.str is _inside_ the folder strings_us so all you do is create another c4d_strings.str in a different language and make sure it is in the correct folder for that language. AIUI Cinema will use the correct one when you call GeLoadString().

    As noted, you can support any of the languages which Cinema 4D supports by creating the proper folder for the c4d_symbols.str files (strings_us for English, strings_de for German, strings_fr for French, strings_es for Spanish, etc.).  You use the same IDs but the strings are in another language.

    You need to use four-character escape UNICODE to add foreign characters - for instance, \u00a9 is the Copyright symbol.  You can find UNICODE PDFs online.

    Finally, to support other languages for direct-string plugins, you use the same folder but put the .str file in a 'description' subfolder, i.e.:

    strings_us
    --- c4d_symbols.str
    --- description
    ------ OmyObjPlugin.str



  • On 18/02/2014 at 11:57, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Incorrect, c4d_strings.str is _inside_ the folder strings_us so all you do is create another c4d_strings.str in a different language and make sure it is in the correct folder for that language. AIUI Cinema will use the correct one when you call GeLoadString().

    Thanks, that makes sense.



  • On 18/02/2014 at 12:05, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    You need to use four-character escape UNICODE to add foreign characters - for instance, \u00a9 is the Copyright symbol.  You can find UNICODE PDFs online.

    Thanks, valuable information.


Log in to reply