Strangepete/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
(MP example - simple and clear enough? next destination is /Stringtable.xml (capital S in form of Description.ext- all in favor?))
(geSHi and syntaxhighlight play - i'd like to work on a lightweight SQF highlighter for use on the wiki)
Line 1: Line 1:
==Stringtable.xml==
just learned about <syntaxhighlight> and geSHi Extension: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi
{{note|Work-in-Progress : please contribute here if you see anything or want to add anything...
*implementation in arma 2: eg, compatibility with arma3 xml? etc.
*use of @STR_ in mission.sqm and via Mission Editor - still valid? working example?
*proof read}}
String tables are used to make internationalization easier for the game. They are used in addons, missions, and scripts, and are located in the root of the mission or addon folders.


Any strings that are used in the game can be kept separate from the code, and can therefore easily be edited and expanded into different languages. Instead of using strings directly in the code, you are using a variable. This variable will then contain the actual string, read from stringtable.xml, with the language that's being read depending on the game settings.
i'd like to start working on a SQF highlight for use in the wiki, something lightweight and simple, personally i think the notepad++ syntax highlight for a3 is very clean, with minimal color use - comments, command names, strings...i'm not familiar with geshi, but it doesnt seem too hard to get a basic style formed....


=====Example Format:=====
one issue i'd read about, and noticed so far, is that [[ bracketed ]] wiki links don't work, so this would remove any links to commands within code...not something im thrilled about - perhaps theres a way to preprocess the url before the highligher handles it, or maybe geshi allows for inserting or ignoring the appropriate code tags
<code><?xml version="1.0" encoding="utf-8" ?>
 
geshi xml lang
<syntaxhighlight lang="xml" enclose="div" line="GESHI_NORMAL_LINE_NUMBERS"><?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
<Project name="Any Name">
<Package name="Mission One">
<Package name="Mission One">
Line 15: Line 12:
<Key ID="str_myTag_Yes">
<Key ID="str_myTag_Yes">
<Original>yes</Original>
<Original>yes</Original>
<English>yes</English>
<Czech>ano</Czech>
<French>oui</French>
<German>ja</German>
<Italian>sì</Italian>
<Polish>tak</Polish>
<Portuguese>sim</Portuguese>
<Russian>да</Russian>
<Spanish>sí</Spanish>
</Key>
<Key ID="str_myTag_No">
<Original>no</Original>
</Key>
</Key>
</Container>
</Container>
<Container name="Another Container">
<Container name="Another Container">
<Key ID="str_myTag_another_key">
<Original></Original>
</Key>
<Key ID="str_myTag_formatted">
<Original>Hello, %1.</Original>
</Key>
<Key ID="str_myTag_structured">
<Key ID="str_myTag_structured">
<Original>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</Original>
<Original>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</Original>
Line 43: Line 21:
</Package>
</Package>
</Project>
</Project>
</code>
</syntaxhighlight>


*Replace ''myTag'' in str_myTag_someKey with your OFPEC tag or other means of personal identification so other addon and mission string names won't collide, potentially breaking your mission - this is just good practice
<!--
*Package and container names appear to only be for organizational use; use them for your own sanity
<style>
{{Important|Stringtable.xml must be saved with UTF-8 Encoding for international characters to display and save correctly}}
div.code-good {
background: #efffef url(/mediawiki-1.19/skins/common/tmhp/silk-icons/tick.png) no-repeat top right !important;
border-color: #6c6 !important;
}
div.code-bad {
background: #ffefef url(/mediawiki-1.19/skins/common/tmhp/silk-icons/cancel.png) no-repeat top right !important;
border: 1px dashed #c66 !important;
}</style>
-->
<!--


==Usage==
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr" style="border: 1px dashed #6c6; background: #ddf8cb;">[[image:Ico_ok.png|left|22px|Best Practice]] Good Practice:
====Scripts====
<syntaxhighlight lang="c">blah</syntaxhighlight>
A string from stringtable.xml can be retrieved and used in a script by using the [[localize]] command:
</div>
-->


<code>[[hint]] ( [[localize]] "str_myTag_Yes" );</code>
based off submission on mediaWiki: http://www.mediawiki.org/wiki/Extension_talk:SyntaxHighlight_GeSHi


<code>"Marker1" [[setMarkerTextLocal]] [[localize]] "str_myTag_SiezeTheTown";</code>
some Template ideas (using language 'c'):


<code>[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; // "Hello, Dave."
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr" style="border: 1px dashed #6c6; background: #ddf8cb;">[[image:Ico_ok.png|left|22px|Best Practice]] Good Practice:
&nbsp;
<syntaxhighlight lang="c" highlight="5" enclose="div">//str_myTag_teamKillers: <English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>
// str_myTag_formatted: <Original>Hello, %1.</Original></code>


// Server
if ( [[isServer]] ) then {
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};</syntaxhighlight>
</div>


The stringtable can also hold [[Structured Text]] xml tags, if the tag characters < > are encoded as {{Inline_code| &amp;lt; < }} and {{Inline_code| &amp;gt; > }}  [http://www.w3schools.com/html/html_entities.asp see: HTML Entities]
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr" style="border: 1px dashed #c66; background: #ffdada;">[[image:Ico_none.png|left|22px|Bad Practice]] Bad Practice:
<syntaxhighlight lang="c" enclose="div" line="GESHI_NORMAL_LINE_NUMBERS">//str_myTag_teamKillers: <English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>


<code>[[hint]] [[parseText]] [[format]] [ [[localize]] "str_myTag_structured", "#FF0000", "with Color!" ]; //show 'with Color!' in Red
// Server
&nbsp;
if ( [[isServer]] ) then {
// str_myTag_structured: <English>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</English>
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
// after format & parseText: Some text <t color='#FF0000'>with Color!</t></code>
};
</syntaxhighlight></div>




====Description.ext====
I think i prefer this:
Stringtable values can be used in the [[Description.ext]] config by typing the key as such, {{Inline_code| $STR_myTag_keyName }}, and without quotation marks; these will be replaced by the preprocessor:


<code>onLoadName = $STR_myTag_missionName;
onLoadMission = $STR_myTag_loadMissionText;
overviewText = $STR_myTag_overviewText;
overviewPicture = $STR_myTag_overviewImage;
</code>


<div dir="ltr" class="" style="border: none; background: #ddf8cb;">[[image:Ico_ok.png|left|22px|Best Practice]] Good Practice:
<syntaxhighlight lang="c">//str_myTag_teamKillers: <English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>


====Dialogs====
// Server
As with Description.ext, the preprocessor will replace the values in configs as long as the key name is formatted correctly (see above) :
if ( [[isServer]] ) then {
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};</syntaxhighlight>
</div>


<code>class RscText_1012: RscText
{
idc = 1012;
text = $STR_myTag_someLabelText;
tooltip = $STR_myTag_someTip;
...</code>


<div dir="ltr" class="" style="border: none; background: #ffdada;">[[image:Ico_none.png|left|22px|Bad Practice]] Bad Practice:
<syntaxhighlight lang="c" enclose="div" highlight="5" line="GESHI_NORMAL_LINE_NUMBERS">//str_myTag_teamKillers: <English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>


====CfgRadio====
// Server
Stringtables can also be used for sounds and radio sentences in [[Description.ext#cfgRadio|CfgRadio]], also residing in Description.ext:
if ( [[isServer]] ) then {
 
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
<code>class CfgRadio
{
sounds[] = {};
class RadioMsg1
{
name = "";
sound[] = {$STR_myTag_sound_RadioMsg1, db-100, 1.0};
title = $STR_myTag_RadioMsg1;
};
};
};
// str_myTag_sound_RadioMsg1: <English>\sound\radiomsg1_en.ogg</English>
</syntaxhighlight></div>
// <Czech>\sound\radiomsg1_cz.ogg</Czech>
// str_myTag_RadioMsg1: <English>I am ready for your orders.</English>
</code>




====Multiplayer====
<div dir="ltr" class="" style="border: none; background: #ddf8cb;">[[image:Ico_ok.png|left|22px|Best Practice]] Best Practice:
<div style="text-align: left; margin: 1em">
<syntaxhighlight lang="c">// some code
{| style="width: 100%;text-align:left; background-color: #C3D6DD; border: 1px solid #aaa; padding: 0.1em; margin: 0"
doThings;</syntaxhighlight>
|-
| valign="top" style="padding:0 0.2em 0 0.4em; font: bold italic 3em serif; font-weight: 1000; color:#112020; width: 0.5em;" | i
| style="padding: 0.1em; font: 1.0em sans-serif" | '''Multiplayer Scripts''' should take care in considering implementation when clients and server are likely in varied localizations, and mindful of commands with global effects
|}</div>


A string name could be passed to all clients for localized display:
Maybe an explanation why, or a reference
<code>str_myTag_teamKillers: <English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>
<syntaxhighlight lang="c">// or more code</syntaxhighlight>
</div>


// Server
if ( [[isServer]] ) then {
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};


// Clients
<div dir="ltr" class="" style="border: none; background: #ffdada;">[[image:Stop_hand.png|left|25px|Bad Practice]] '''Catastrophically Stupid:'''
TAG_fnc_localHint = {
<syntaxhighlight lang="php">stupidCode;</syntaxhighlight>
if ( ! [[isDedicated]] ) then {
</div>
[[hintSilent]] [[parseText]] ([[localize]] _this);
};
};
</code>




Line 139: Line 105:
<!-- Do not include CSS styling in genuine example -->
<!-- Do not include CSS styling in genuine example -->
<code style="white-space:pre-wrap;">{{Lorem|}}</code>
<code style="white-space:pre-wrap;">{{Lorem|}}</code>
==Languages==
;Arma 3
:English, Czech, French, Spanish, Italian, Polish, Portuguese, Russian, German
;Arma 2 OA
:English, Czech, French, Spanish, Italian
==Comments==
<!--[[Category:BIS_File_Formats]]
[[Category:Arma 3: Editing]]-->

Revision as of 23:00, 5 April 2014

just learned about <syntaxhighlight> and geSHi Extension: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi

i'd like to start working on a SQF highlight for use in the wiki, something lightweight and simple, personally i think the notepad++ syntax highlight for a3 is very clean, with minimal color use - comments, command names, strings...i'm not familiar with geshi, but it doesnt seem too hard to get a basic style formed....

one issue i'd read about, and noticed so far, is that bracketed wiki links don't work, so this would remove any links to commands within code...not something im thrilled about - perhaps theres a way to preprocess the url before the highligher handles it, or maybe geshi allows for inserting or ignoring the appropriate code tags

geshi xml lang

<?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
	<Package name="Mission One">
		<Container name="Some Words">
			<Key ID="str_myTag_Yes">
				<Original>yes</Original>
			</Key>
		</Container>
		<Container name="Another Container">
			<Key ID="str_myTag_structured">
				<Original>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</Original>
			</Key>
		</Container>
	</Package>
</Project>


based off submission on mediaWiki: http://www.mediawiki.org/wiki/Extension_talk:SyntaxHighlight_GeSHi

some Template ideas (using language 'c'):

Best Practice
Good Practice:
//str_myTag_teamKillers:	<English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>

// Server
if ( [[isServer]] ) then {
	["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};
Bad Practice
Bad Practice:
//str_myTag_teamKillers:	<English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>

// Server
if ( [[isServer]] ) then {
	["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};


I think i prefer this:


Best Practice
Good Practice:
//str_myTag_teamKillers:	<English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>

// Server
if ( [[isServer]] ) then {
	["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};


Bad Practice
Bad Practice:
//str_myTag_teamKillers:	<English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>

// Server
if ( [[isServer]] ) then {
	["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};


Best Practice
Best Practice:
// some code
doThings;

Maybe an explanation why, or a reference

// or more code


Bad Practice
Catastrophically Stupid:
stupidCode;


Example 2: Template:Lorem