Strangepete/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Fix Pages using deprecated enclose attributes syntaxhighlight auto-category)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Stringtable.xml==
{{Feature|informative|Some years later… we have our very own [[Extension:SQFHighlighter|SQFHighlighter]] :-) - [[User:Lou Montana|Lou Montana]] ([[User talk:Lou Montana|talk]]) 22:24, 9 July 2023 (CEST)}}
{{note|Work-in-Progress : input on relevance/implementation in arma 2 requested, im looking...}}
just learned about <syntaxhighlight> and geSHi Extension: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi
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" 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 12: Line 14:
<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 40: Line 23:
</Package>
</Package>
</Project>
</Project>
</code>
</syntaxhighlight>
 
<!--
<style>
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>
-->
<!--
 
<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:
<syntaxhighlight lang="c">blah</syntaxhighlight>
</div>
-->
 
based off submission on mediaWiki: http://www.mediawiki.org/wiki/Extension_talk:SyntaxHighlight_GeSHi
 
some Template ideas (using language 'c'):
 
<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:
<syntaxhighlight lang="c" highlight="5">
//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]];
};
</syntaxhighlight>
</div>
 
<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" 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>
 
// Server
if ( [[isServer]] ) then {
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};
</syntaxhighlight>
</div>
 
 
I think i prefer this:


*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
*Package and container names appear to only be for organizational use; use them for your own sanity
{{Important|Stringtable.xml must be saved with UTF-8 Encoding for international characters to display and save correctly}}


==Usage==
<div dir="ltr" class="" style="border: none; background: #ddf8cb;">[[image:Ico_ok.png|left|22px|Best Practice]] Good Practice:
====Scripts====
<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>
A string from stringtable.xml can be retrieved and used in a script by using the [[localize]] command:


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


<code>_twoStrings = ( [[localize]] "str_myTag_String1" ) + ( [[localize]] "str_tag_String2" );</code>


<code>[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; // "Hello, Dave."
<div dir="ltr" class="" style="border: none; background: #ffdada;">
&nbsp;
[[image:Ico_none.png|left|22px|Bad Practice]] Bad Practice:
// stringtable: <Original>Hello, %1.</Original></code>
<syntaxhighlight lang="c" 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>


// 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]


<code>[[hint]] [[parseText]] [[format]] [ [[localize]] "str_myTag_structured", "#FF0000", "with Color!" ]; //show 'with Color!' in Red
<div dir="ltr" class="" style="border: none; background: #ddf8cb;">
&nbsp;
[[image:Ico_ok.png|left|22px|Best Practice]] Best Practice:
// stringtable: <English>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</English>
<syntaxhighlight lang="c">// some code
// after format & parseText: Some text <t color='#FF0000'>with Color!</t></code>
doThings;</syntaxhighlight>


====Description.ext====
Maybe an explanation why, or a reference
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:
<syntaxhighlight lang="c">// or more code</syntaxhighlight>
</div>


<code>onLoadName = $STR_myTag_missionName;
onLoadMission = $STR_myTag_loadMissionText;
overviewText = $STR_myTag_overviewText;
overviewPicture = "intro.paa";
loadScreen = "intro.paa";
author="me";</code>


====Dialogs & Configs====
<div dir="ltr" class="" style="border: none; background: #ffdada;">
As with Description.ext, the preprocessor will replace the values in configs as long as the key name is formatted correctly (see above) :
[[image:Stop_hand.png|left|25px|Bad Practice]] '''Catastrophically Stupid:'''
<syntaxhighlight lang="php">stupidCode;</syntaxhighlight>
</div>


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


==Languages==
;Arma 3
:Czech
:English
:French
:German
:Italian
:Polish
:Portuguese
:Russian
:Spanish
;Arma 2
:...?


==Comments==
Example 2:
<!-- Do not include CSS styling in genuine example -->
<code style="white-space:pre-wrap;">{{Wiki|lorem|}}</code>


[[Category:BIS_File_Formats]]
[[Category:Sandbox]]
[[Category:Arma 3: Editing]]

Latest revision as of 21:24, 9 July 2023

Some years later… we have our very own SQFHighlighter :-) - Lou Montana (talk) 22:24, 9 July 2023 (CEST)

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: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.