For all my code it compiled this garbage... "Param/Value/SomeHexValue". This happened for things such as, TextTagCreate and so forth. Why does it do this? How can I convert a C string to text, so I can pass "" as an argument?
You should not be using hard coded strings for anything but constants (used by game engine). Instead use the localization lookup native to pull the text down from the localized text files. Obviously you need to declare the entries in that file for your appropriate localization.
This is so your map supports localization correctly. It is just like your usual C/C++ program where you use a function call to get the localized version of a string from some constant string.
I suppose that is an option. However, for things that are only used ONCE, creating a text tag, displaying a welcome message and so on, I honestly feel is best to use "Magic Values". I do not and have not declared variables for a simple ONE use value that is self explanatory. It confuses the heck out of me reading Param/Value/SomeHexValue in my code. BTW, where and what is the name of this/these files for the standard map? I just saw, StringToText, guess I will use that.
It confuses the heck out of me reading Param/Value/SomeHexValue in my code.
Which is why for your code you should give them meaningful paths like Triggers/UI/PressOkButton.
Quote:
where and what is the name of this/these files for the standard map?
I think they are spread across numerous files for each type of data. However you can export them in the editor as a single file which goes in path/text mappings, very useful for localization.
Quote:
StringToText, guess I will use that.
There are these...
// StringExternal looks up the given string identifer in the externalized string tablenativetextStringExternal(strings);nativetextStringExternalHotkey(strings);nativetextStringExternalAsset(strings);// StringToText converts the given string to text directly (not externalized)nativetextStringToText(strings);// Text expressions// - An expression consists of externalized text with one or more tokens to be replaced dynamically// - TextExpressionSetToken sets the token values// - TextExpressionAssemble returns the final text with token replacements//nativevoidTextExpressionSetToken(stringid,stringcode,textvalue);nativetextTextExpressionAssemble(stringid);
Use eternalized strings for anything non-technical that is displayed to the user. For example button tooltips or game messages. Only convert strings for technical information such as in use when debugging or major errors displayed to users (when the map breaks).
I am not really seeing how text-string maps stored in text files are better than global/temp strings. StringExternal requires a table lookup and therefore, is less accessible and is more performance heavy(not that it really matters in this case). Another reason, why I am not doing it that way is, I am doing a lot of string concatenation( this would require serveral lookups to concatenate several "text" types); this reduces the amount of code needed to accomplish my task, to makes it more readable and more dynamic.
Is there a way to convert text to string? Or even looking at the text class would be nice...
I am not really seeing how text-string maps stored in text files are better than global/temp strings. StringExternal requires a table lookup and therefore, is less accessible and is more performance heavy(not that it really matters in this case). Another reason, why I am not doing it that way is, I am doing a lot of string concatenation( this would require serveral lookups to concatenate several "text" types); this reduces the amount of code needed to accomplish my task, to makes it more readable and more dynamic.
As you probably already know from your experience programming professionally, you need to keep all strings in an external table to allow for localization. This way you can give the people doing localization only the table of text which they can then translate. If you embed the text as strings in the program it becomes a complete mess to localize since each string will need multiple selection to choose the correct one and text can be easily missed as you might remember where it all is etc.
Quote:
Is there a way to convert text to string?
No as Blizzard is not that silly to even let you try seeing how it would require synchronization. The value of text is non-deterministic because it can be localized. This means that between clients text might have different values. For example one client might get the German version of the text while another client the English(UK) version.
Strings are deterministic, this means that they are identical across all clients in a session. This allows them to be used for all internal mechanics such as data references, file paths etc. Since strings are deterministic it is easy to convert them to non-deterministic text since you do not care if the text is different between client. On the other hand to convert a non-deterministic text value into a string you need to synchronize the result so that game determinism is kept, something which is pretty silly to do.
You can see this reflected in the way string and text are use. Strings can be read and can be used for major game mechanics (data reference to unit type for example). On the other hand text can only be written to or manipulated with other text and are only used for sending messages to a client through the user interface.
If you are planning to use strings as a core part of your map mechanics (such as for dynamic storage space or whatever) then text clearly is not what you are after. If you plan to show a quest dialog to a player or send some tips then text is what you are after.
Quote:
Or even looking at the text class would be nice...
Galaxy has no idea of the concept of "class". It is based on C and not C++.
That said text probably does have a class as part of its implementation as a type into the galaxy virtual machine. However only Blizzard has access to the source code for that.
I more have built frameworks and such. I would probably take a different approach to this, but I guess if that's how they do it. So how do I create an external string table in this setup? How do I declare entries? What file do I create to store them in( extension? )? How do I include the file?
"That said text probably does have a class as part of its implementation as a type into the galaxy virtual machine. However only Blizzard has access to the source code for that."
Yes that is why I used the term class. I'm sure they didn't write their data types in galaxy... Anyways, a class and struct are very similar anyways, the only difference is access rights outside the class.
I more have built frameworks and such. I would probably take a different approach to this, but I guess if that's how they do it. So how do I create an external string table in this setup? How do I declare entries? What file do I create to store them in( extension? )? How do I include the file?
I am surprised it so so hard to find... Go to the Terrain editor window then click the "Modules" menu and then "Text". Alternatively you can hit "F8" as the shortcut. In there you can add text, remove text, etc.
If you want to import/export a mapping file then use the localization feature of the editor. Go to the Terrain editor window then click the "Map" menu and then "Locale sub menu". From there either choose the "Export Locales..." option to export a mapping file or the "Import Locales..." file to import a mapping file. The file is a plain text file with paths and their appropriate text. As a guess it is probably in Unicode however wordpad has no issues opening it.
Quote:
Anyways, a class and struct are very similar anyways, the only difference is access rights outside the class.
Actually the main difference is structs are a plain old data structure available in C while Classes are not defined in C. In C++ is a different story where they are still plain old data if no methods are defined but become a class with default public modifier if methods are defined. I am not sure if classes can be plain old data but in theory I would imagine so however again they are only in c++.
Thanks a ton, I was able to import a new locale file. I prefer doing everything the no-dialog way. It is much more dynamic and easier for me to do, due to what I am used to.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
For all my code it compiled this garbage... "Param/Value/SomeHexValue". This happened for things such as, TextTagCreate and so forth. Why does it do this? How can I convert a C string to text, so I can pass "" as an argument?
You should not be using hard coded strings for anything but constants (used by game engine). Instead use the localization lookup native to pull the text down from the localized text files. Obviously you need to declare the entries in that file for your appropriate localization.
This is so your map supports localization correctly. It is just like your usual C/C
++
program where you use a function call to get the localized version of a string from some constant string.@ImperialGood: Go
I suppose that is an option. However, for things that are only used ONCE, creating a text tag, displaying a welcome message and so on, I honestly feel is best to use "Magic Values". I do not and have not declared variables for a simple ONE use value that is self explanatory. It confuses the heck out of me reading Param/Value/SomeHexValue in my code. BTW, where and what is the name of this/these files for the standard map? I just saw, StringToText, guess I will use that.
Which is why for your code you should give them meaningful paths like Triggers/UI/PressOkButton.
I think they are spread across numerous files for each type of data. However you can export them in the editor as a single file which goes in path/text mappings, very useful for localization.
There are these...
Use eternalized strings for anything non-technical that is displayed to the user. For example button tooltips or game messages. Only convert strings for technical information such as in use when debugging or major errors displayed to users (when the map breaks).
I am not really seeing how text-string maps stored in text files are better than global/temp strings. StringExternal requires a table lookup and therefore, is less accessible and is more performance heavy(not that it really matters in this case). Another reason, why I am not doing it that way is, I am doing a lot of string concatenation( this would require serveral lookups to concatenate several "text" types); this reduces the amount of code needed to accomplish my task, to makes it more readable and more dynamic.
Is there a way to convert text to string? Or even looking at the text class would be nice...
As you probably already know from your experience programming professionally, you need to keep all strings in an external table to allow for localization. This way you can give the people doing localization only the table of text which they can then translate. If you embed the text as strings in the program it becomes a complete mess to localize since each string will need multiple selection to choose the correct one and text can be easily missed as you might remember where it all is etc.
No as Blizzard is not that silly to even let you try seeing how it would require synchronization. The value of text is non-deterministic because it can be localized. This means that between clients text might have different values. For example one client might get the German version of the text while another client the English(UK) version.
Strings are deterministic, this means that they are identical across all clients in a session. This allows them to be used for all internal mechanics such as data references, file paths etc. Since strings are deterministic it is easy to convert them to non-deterministic text since you do not care if the text is different between client. On the other hand to convert a non-deterministic text value into a string you need to synchronize the result so that game determinism is kept, something which is pretty silly to do.
You can see this reflected in the way string and text are use. Strings can be read and can be used for major game mechanics (data reference to unit type for example). On the other hand text can only be written to or manipulated with other text and are only used for sending messages to a client through the user interface.
If you are planning to use strings as a core part of your map mechanics (such as for dynamic storage space or whatever) then text clearly is not what you are after. If you plan to show a quest dialog to a player or send some tips then text is what you are after.
Galaxy has no idea of the concept of "class". It is based on C and not C
++
.That said text probably does have a class as part of its implementation as a type into the galaxy virtual machine. However only Blizzard has access to the source code for that.
@ImperialGood: Go
Thanks.
I more have built frameworks and such. I would probably take a different approach to this, but I guess if that's how they do it. So how do I create an external string table in this setup? How do I declare entries? What file do I create to store them in( extension? )? How do I include the file?
"That said text probably does have a class as part of its implementation as a type into the galaxy virtual machine. However only Blizzard has access to the source code for that." Yes that is why I used the term class. I'm sure they didn't write their data types in galaxy... Anyways, a class and struct are very similar anyways, the only difference is access rights outside the class.
I am surprised it so so hard to find... Go to the Terrain editor window then click the "Modules" menu and then "Text". Alternatively you can hit "F8" as the shortcut. In there you can add text, remove text, etc.
If you want to import/export a mapping file then use the localization feature of the editor. Go to the Terrain editor window then click the "Map" menu and then "Locale sub menu". From there either choose the "Export Locales..." option to export a mapping file or the "Import Locales..." file to import a mapping file. The file is a plain text file with paths and their appropriate text. As a guess it is probably in Unicode however wordpad has no issues opening it.
Actually the main difference is structs are a plain old data structure available in C while Classes are not defined in C. In C
++
is a different story where they are still plain old data if no methods are defined but become a class with default public modifier if methods are defined. I am not sure if classes can be plain old data but in theory I would imagine so however again they are only in c++
.Thanks a ton, I was able to import a new locale file. I prefer doing everything the no-dialog way. It is much more dynamic and easier for me to do, due to what I am used to.