diff --git a/.github/workflows/dev.build.yml b/.github/workflows/dev.build.yml index 6edc4beec0..ace75b0b28 100644 --- a/.github/workflows/dev.build.yml +++ b/.github/workflows/dev.build.yml @@ -14,20 +14,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Number of commits to fetch. 0 indicates all history. # Default: 1 # 0 is needed for the update time plugin to work properly fetch-depth: 0 - name: Install Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 cache: pip - name: Process Python Cache id: cache-requirements - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: venv key: requirements-${{ hashFiles('requirements*.txt') }} @@ -43,7 +43,7 @@ jobs: source venv/bin/activate python -m unittest discover tests/ -v - name: Process MkDocs Plugins & Hooks Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .cache key: mkdocs-${{ github.sha }} diff --git a/.github/workflows/master.build.yml b/.github/workflows/master.build.yml index 7ab67db47c..a78e9bb751 100644 --- a/.github/workflows/master.build.yml +++ b/.github/workflows/master.build.yml @@ -13,20 +13,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Number of commits to fetch. 0 indicates all history. # Default: 1 # 0 is needed for the update time plugin to work properly fetch-depth: 0 - name: Install Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 cache: pip - name: Process Python Cache id: cache-requirements - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: venv key: requirements-${{ hashFiles('requirements*.txt') }} @@ -42,7 +42,7 @@ jobs: source venv/bin/activate python -m unittest discover tests/ -v - name: Process MkDocs Plugins & Hooks Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .cache key: mkdocs-${{ github.sha }} diff --git a/.github/workflows/pull.request.yml b/.github/workflows/pull.request.yml index 33e67a00e4..4164073b0c 100644 --- a/.github/workflows/pull.request.yml +++ b/.github/workflows/pull.request.yml @@ -13,20 +13,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Number of commits to fetch. 0 indicates all history. # Default: 1 # 0 is needed for the update time plugin to work properly fetch-depth: 1 - name: Install Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: 3.11 + python-version: 3.12 cache: pip - name: Process Python Cache id: cache-requirements - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: venv key: requirements-${{ hashFiles('requirements*.txt') }} diff --git a/docs/.pages b/docs/.pages index ff39b93ddb..935044d41e 100644 --- a/docs/.pages +++ b/docs/.pages @@ -1,6 +1,7 @@ nav: - Home: - ... | index*.md + - ... | preferences*.md - zengin - genome - contribute \ No newline at end of file diff --git a/docs/genome/tools/index.md b/docs/genome/tools/index.md index 432f878d20..ccf868efcc 100644 --- a/docs/genome/tools/index.md +++ b/docs/genome/tools/index.md @@ -6,5 +6,5 @@ Piranha Bytes did not release a modkit for their Genome engine, but the modding This page is under construction, for now, only handful of links are present. ## Gothic 3 SDK -Georgeto, inspired by NiceDE's Risen SDK, has created an SDK for Gothic 3. It can be used to manipulate the engine in the similar way Union is able to manipulate ZenGin. +Georgeto, inspired by NicoDE's Risen SDK, has created an SDK for Gothic 3. It can be used to manipulate the engine in the similar way Union is able to manipulate ZenGin. [GitHub repository](https://github.com/georgeto/gothic3sdk) diff --git a/docs/preferences.md b/docs/preferences.md new file mode 100644 index 0000000000..5665708f12 --- /dev/null +++ b/docs/preferences.md @@ -0,0 +1,92 @@ +--- +preferences_i18n: + en: + page-title: "Preferences" + page-description: "This page allows to set various preferences for reading the docs:" + color-title: "Color" + color-description: "You can change the feel of the site with a color change." + color-input-accent-title: "Select accent color" + color-input-hue-title: "Select hue color" + color-button-reset: "Reset colors" + custom-title: "Custom CSS" + custom-description: "You can add custom stylesheets." + custom-textarea-title: "Input CSS" + font-title: "Font" + font-description: "You can change the font to another preset." + font-selection-title: "Select font" + font-selection-default: "Default" + font-selection-opendyslexic: "OpenDyslexic" + heading-shadows-title: "Heading shadows" + heading-shadows-description: "You can enable additional shadows for the heading to make them appear more bold." + pl: + page-title: "Preferencje" + page-description: "Ta strona pozwala ustawić różne preferencje do czytania dokumentacji:" + color-title: "Kolor" + color-description: "Możesz zmienić nastrój strony poprzez zmianę koloru." + color-input-accent-title: "Wybierz kolor akcentujący" + color-input-hue-title: "Wybierz kolor odcienia" + color-button-reset: "Zresetuj kolory" + custom-title: "Własny CSS" + custom-description: "Możesz dodać niestandardowe arkusze stylów." + custom-textarea-title: "Wprowadź CSS" + font-title: "Czcionka" + font-description: "Możesz zmienić czcionkę na predefiniowany." + font-selection-title: "Wybierz czcionkę" + font-selection-default: "Domyślna" + font-selection-opendyslexic: "OpenDyslexic" + heading-shadows-title: "Cienie nagłówków" + heading-shadows-description: "Możesz włączyć dodatkowe cienie do nagłówków żeby wyglądały bardziej pogrubione." +--- +# {{ page-title }} + +{{ page-description }} + +## {{ color-title }} + +{{ color-description }} + + + + + + + +[{{ color-button-reset }} :fontawesome-regular-circle-xmark:](#preference-color-reset){ #preference-color-reset .md-button data-extra="reset" data-option="color" title="{{ color-button-reset }}" } + +## {{ font-title }} + +{{ font-description }} + + + + +## {{ custom-title }} + +{{ custom-description }} +
+ +
+ + \ No newline at end of file diff --git a/docs/zengin/anims/events.md b/docs/zengin/anims/events.md index c8a9aeb7c8..272cdd000d 100644 --- a/docs/zengin/anims/events.md +++ b/docs/zengin/anims/events.md @@ -62,7 +62,7 @@ General Syntax: | [eventSFXGRND](#eventsfxgrnd) | create sound effect on the ground | | [eventTag](#eventtag) | generic event, does action specified in parameters | | Defined in engine but never used ? | | -| [eventPFXGRND](#eventpfxgrnd) | creats particle effect on the ground | +| [eventPFXGRND](#eventpfxgrnd) | create particle effect on the ground | | [eventSetMesh](#eventsetmesh) | ? | | [modelTag](#modeltag) | same as eventTag, but applies to morphmesh? | @@ -260,7 +260,7 @@ Depending on the material of the texture, the character is standing on, the game | default | _Stone | ✔️ | ✔️ | -NPC running on grass texture, with material set to EARTH in world editor, will play sound `Run_Earth` by using `*eventSFXGrnd (12 "Run")` in run animation. `_Earh` suffix is determined and added by the engine. +NPC running on grass texture, with material set to EARTH in world editor, will play sound `Run_Earth` by using `*eventSFXGrnd (12 "Run")` in run animation. `_Earth` suffix is determined and added by the engine. ## eventTag @@ -335,7 +335,7 @@ Syntax: Insert the interaction item into the specified slot. - during mob interaction, inserted item instance is of instance taken from **UseWithItem** mob property. - - during item interation (i.e. drink potion) item that started the **SceneName** will be inserted. + - during item interaction (i.e. drink potion) item that started the **SceneName** will be inserted. In the example below: `(1)` inserts `ItMiSwordrawhot` that is defined in spacer into `ZS_LEFTHAND`, then `(2)` spawns `ItMw_1H_Mace_L_04` (hammer) into `ZS_RIGHTHAND` for anvil interaction. @@ -833,7 +833,7 @@ ani ("s_1hAttack" 1 "s_1hAttack" 0.0 0.1 M. "Hum_1hAttackComboT3_M05.asc } ``` -| Frames | Aniamtion | Description | +| Frames | Animation | Description | |---------------|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------| | 1 | animation start | | | 1..4 | swing of the sword | | diff --git a/docs/zengin/scripts/classes/c_item.md b/docs/zengin/scripts/classes/c_item.md index ea5757085b..741c1ee5b2 100644 --- a/docs/zengin/scripts/classes/c_item.md +++ b/docs/zengin/scripts/classes/c_item.md @@ -41,7 +41,7 @@ Class definition as it is defined in [`Scripts/Content/_intern/Classes.d`](https // Benötigte Attribute zum Benutzen des Items var int cond_atr[3]; // Array of NPC attributes needed to equip the item - var int cond_value[3]; // Array of values corresponding to the cond_atr arry + var int cond_value[3]; // Array of values corresponding to the cond_atr array // Attributes to be changed on equip var int change_atr[3]; // Array of attributes that will be changed on equip diff --git a/docs/zengin/scripts/extenders/ikarus/floats.md b/docs/zengin/scripts/extenders/ikarus/floats.md index c759530204..d9fc9e25fd 100644 --- a/docs/zengin/scripts/extenders/ikarus/floats.md +++ b/docs/zengin/scripts/extenders/ikarus/floats.md @@ -1,5 +1,5 @@ # Floats -This part of ikarus implements support for 32 bit IEEE 754 floats in Daedalus. The script was originally created to edit `zFLOAT` and `zREAL` variables, but can also be used to arthmetic operations on real float values (not to be confused with Daedalus floats). +This part of ikarus implements support for 32 bit IEEE 754 floats in Daedalus. The script was originally created to edit `zFLOAT` and `zREAL` variables, but can also be used to arithmetic operations on real float values (not to be confused with Daedalus floats). ## Initialization The best way to initialize all Ikarus functions is to call `MEM_InitAll()` in the `Init_Global()` initialization function. @@ -15,7 +15,7 @@ MEM_InitAll(); ## Functions !!! Danger - Ikarus floats are saved as int but it doesn't mean that you can use arthmetic operators on them. All operations on floats must be done with functions listed below. + Ikarus floats are saved as int but it doesn't mean that you can use arithmetic operators on them. All operations on floats must be done with functions listed below. ### `mkf` (make float) Converts the input integer x to a float value. diff --git a/docs/zengin/scripts/extenders/ikarus/functions/asm.md b/docs/zengin/scripts/extenders/ikarus/functions/asm.md index 85bc1dd449..137db0caa3 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/asm.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/asm.md @@ -56,7 +56,7 @@ func int ASMINT_Pop() ``` **Return value** -The function returns a data poped form the internal stack. +The function returns a data popped form the internal stack. ## Functions (Core) @@ -195,7 +195,7 @@ func void ASM_RunOnce() ## Example The following function sets the NPC passed as slf as the player, as if you had pressed **O** in Marvin mode with this NPC in focus. This is so short because there is already a function for this exact purpose, it's just not normally accessible from the scripts. It is therefore sufficient to write assembly code that pushes the parameter of the function (the `this` pointer) into the appropriate register and then calls the function. ```dae -func void SetAsPlayer(var C_NPC slf) { /* Adresse der Funktion */ +func void SetAsPlayer(var C_NPC slf) { /* Address of the function */ const int oCNpc__SetAsPlayer = 7612064; //0x7426A0 (Gothic2.exe) var int slfPtr; diff --git a/docs/zengin/scripts/extenders/ikarus/functions/call.md b/docs/zengin/scripts/extenders/ikarus/functions/call.md index f3c252cc45..abf742c1af 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/call.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/call.md @@ -1,7 +1,7 @@ # CALL Package This part of Ikarus makes possible to call engine functions directly from scripts. -In order to be able to invoke an engine function, you must know some of its roperties. This includes the number and types of parameters, the type of return value, address of function and calling convention. +In order to be able to invoke an engine function, you must know some of its properties. This includes the number and types of parameters, the type of return value, address of function and calling convention. Knowledge about engine functions can be obtained using tools like IDA, which can analyze and convert GothicMod.exe / Gothic2.exe into a more human-readable format. @@ -242,7 +242,7 @@ As soon as the function call has taken place, i.e. after step 2, the return valu !!! Note Some return values are not stored in the EAX. In that case the call of the special function `RetValIs` is required to get the return value. - Folowing funcitons are provided: [`CALL_RetValIsFloat`](#call_retvalisfloat), [`CALL_RetValIszString`](#call_retvaliszstring), [`CALL_RetValIsStruct`](#call_retvalisstruct). + Following functions are provided: [`CALL_RetValIsFloat`](#call_retvalisfloat), [`CALL_RetValIszString`](#call_retvaliszstring), [`CALL_RetValIsStruct`](#call_retvalisstruct). ### `CALL_PutRetValTo` Simply places the return value to the given address (mostly the address of a daedalus integer). Must be called before [The Call](#the-call) function. @@ -324,7 +324,7 @@ func string CALL_RetValAszString() `CALL_RetValAszStringPtr` and `CALL_RetValAszString` are quite different and should not be confused. Using `CALL_RetValAszString` frees up memory that may still be needed. In a reverse with `CALL_RetValAszStringPtr` memory that is no longer needed is not freed and can cause memory leak. ### `CALL_RetValAszStringPtr` -Retrievs a `zString` pointer and converts it to the daedalus string. (don't frees the memory) +Retrieves a `zString` pointer and converts it to the daedalus string. (don't frees the memory) ```dae func string CALL_RetValAszStringPtr() ``` @@ -334,7 +334,7 @@ The function returns a daedalus string form a `zString` returned by the previous ### `CALL_RetValAszString` -Retrievs a `zString` pointer and converts it to the daedalus string. (frees the memory) +Retrieves a `zString` pointer and converts it to the daedalus string. (frees the memory) ```dae func string CALL_RetValAszString() ``` diff --git a/docs/zengin/scripts/extenders/ikarus/functions/debug.md b/docs/zengin/scripts/extenders/ikarus/functions/debug.md index 7dce593f06..c12b920418 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/debug.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/debug.md @@ -113,7 +113,7 @@ func void MEM_AssertFail(var string assertFailText) The assertion failure message. ### `MEM_Debug` -Freely conigurable debug chanell. See how to setup it in the [Constants](../constants.md#mem_debug) article. +Freely configurable debug channel. See how to setup it in the [Constants](../constants.md#mem_debug) article. ```dae func void MEM_Debug(var string message) ``` diff --git a/docs/zengin/scripts/extenders/ikarus/functions/ini_access.pl.md b/docs/zengin/scripts/extenders/ikarus/functions/ini_access.pl.md index b04e5c47e9..92b42c74cd 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/ini_access.pl.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/ini_access.pl.md @@ -23,7 +23,7 @@ Zwraca zawartość linii poleceń przekazaną do Gothica. ```dae func string MEM_GetCommandLine() ``` -**Return value** +**Zwracana wartość** Funkcja zwraca zawartość linii poleceń przekazaną do Gothica. Może to wyglądać na przykład tak: @@ -192,7 +192,7 @@ func void MEM_SetKeys(var string name, var int primary, var int secondary) - `#!dae var int primary` Podstawowy klawisz do przypisania, można go pobrać z pliku [Ikarus_Const_G1](https://github.com/Lehona/Ikarus/blob/master/Ikarus_Const_G1.d) / [Ikarus_Const_G2](https://github.com/Lehona/Ikarus/blob/master/Ikarus_Const_G2.d). - `#!dae var int secondary` - Zapasowy klawisz do przypisania, można go pobrać z pliku[Ikarus_Const_G1](https://github.com/Lehona/Ikarus/blob/master/Ikarus_Const_G1.d) / [Ikarus_Const_G2](https://github.com/Lehona/Ikarus/blob/master/Ikarus_Const_G2.d). + Zapasowy klawisz do przypisania, można go pobrać z pliku [Ikarus_Const_G1](https://github.com/Lehona/Ikarus/blob/master/Ikarus_Const_G1.d) / [Ikarus_Const_G2](https://github.com/Lehona/Ikarus/blob/master/Ikarus_Const_G2.d). ### `MEM_SetKey` Ustawia podstawowy klawisz klawiatury dla klawisza logicznego. diff --git a/docs/zengin/scripts/extenders/ikarus/functions/jumps_loops.md b/docs/zengin/scripts/extenders/ikarus/functions/jumps_loops.md index cff22bf6ff..abb34e0d59 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/jumps_loops.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/jumps_loops.md @@ -131,20 +131,20 @@ func void MEM_InitLabels() ## Label and Goto -Besides the normal [Jupms](#jumps) Ikarus implements `MEM_Label` and `MEM_Goto` functions. They work similar to the stack manipulation with `var int label` but the interface is much more user-friendly and defineing new variables is not needed. +Besides the normal [jumps](#jumps) Ikarus implements `MEM_Label` and `MEM_Goto` functions. They work similar to the stack manipulation with `var int label` but the interface is much more user-friendly and defining new variables is not needed. ### `MEM_Label` -Function taht works like a `label = MEM_StackPos.position;`. You could jump to it with [`MEM_Goto`](#mem_goto). +Function that works like a `label = MEM_StackPos.position;`. You could jump to it with [`MEM_Goto`](#mem_goto). ```dae func void MEM_Label(var int lbl) ``` **Parameters** - `#!dae var int lbl` - Number of the label, used for nested loop or multible loops within one functon + Number of the label, used for nested loop or multiple loops within one function ### `MEM_Goto` -Function taht works like a `MEM_StackPos.position = label;`. Executes a jump to a [`MEM_Label`](#mem_label) with specified number. +Function that works like a `MEM_StackPos.position = label;`. Executes a jump to a [`MEM_Label`](#mem_label) with specified number. ```dae func void MEM_Goto(var int lbl) ``` @@ -154,7 +154,7 @@ func void MEM_Goto(var int lbl) Number of the label, the function will jump to ### Usage -Usage of Label and Goto is probably self-explanatory, since it is same as in the regular Ikarus Jump. But before using it reading the [Notes and warnings](#notes-and-warnings) of the Jumps is recomended. +Usage of Label and Goto is probably self-explanatory, since it is same as in the regular Ikarus Jump. But before using it reading the [Notes and warnings](#notes-and-warnings) of the Jumps is recommended. **Label-Goto loop flowchart** ```mermaid @@ -259,7 +259,7 @@ func void LabelGoto_test() { ## While loop -Ikarus also implements a while loop. Its syntax isn't as good as the loop from [zParserExtedner](../../zparserextender/syntax_extensions/while.md), due to the daedalus limitations, but it works as a normal while loop that can be found in many programming languages. +Ikarus also implements a while loop. Its syntax isn't as good as the loop from [zParserExtender](../../zparserextender/syntax_extensions/while.md), due to the daedalus limitations, but it works as a normal while loop that can be found in many programming languages. ### Syntax The Ikarus while loop consist of three things: diff --git a/docs/zengin/scripts/extenders/ikarus/functions/objects.md b/docs/zengin/scripts/extenders/ikarus/functions/objects.md index 3893eae462..0b11fa1422 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/objects.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/objects.md @@ -72,7 +72,7 @@ func void MEM_InitGlobalInst() }; ``` - Full Ikarus definition of this class, with members decription can be found in [`Misc.d`](https://github.com/Lehona/Ikarus/blob/master/EngineClasses_G1/Misc.d#L490-L537) file. The class is same for G1 and G2A engines. + Full Ikarus definition of this class, with members description can be found in [`Misc.d`](https://github.com/Lehona/Ikarus/blob/master/EngineClasses_G1/Misc.d#L490-L537) file. The class is same for G1 and G2A engines. ### `MEM_GetClassDef` Returns a pointer to the `zCClassDef` of the object. For more info see the **About zCClassDef** section above. @@ -194,7 +194,7 @@ func void MEM_DeleteVob(var int vobPtr) **Parameters** - `#!dae var int vobPtr` - Pointer to a [`zCVob`](./../../../worlds/Classes/zCVob.md) object to be deleted + Pointer to a [`zCVob`](../../../../worlds/Classes/zCVob.md) object to be deleted ### `MEM_RenameVob` Renames the passed Vob to the `newName` that is also passed. @@ -206,7 +206,7 @@ func void MEM_RenameVob(var int vobPtr, var string newName) **Parameters** - `#!dae var int vobPtr` - Pointer to a [`zCVob`](./../../../worlds/Classes/zCVob.md) object to be renamed + Pointer to a [`zCVob`](../../../../worlds/Classes/zCVob.md) object to be renamed - `#!dae var string newName` The new Name of the Vob @@ -220,7 +220,7 @@ func void MEM_RenameVob(var int vobPtr, var string newName) **Parameters** - `#!dae var int vobPtr` - Pointer to a triggered [`zCVob`](./../../../worlds/Classes/zCVob.md) + Pointer to a triggered [`zCVob`](../../../../worlds/Classes/zCVob.md) !!! Danger If triggering the Vob has immediate effects (even before MEM_TriggerVob is exited), the name of the Vob is corrupted during this time. It is not advisable to rename, trigger again or destroy the object at this moment, the behavior in such cases is untested. @@ -234,24 +234,24 @@ func void MEM_RenameVob(var int vobPtr, var string newName) **Parameters** - `#!dae var int vobPtr` - Pointer to an untriggered [`zCVob`](./../../../worlds/Classes/zCVob.md) + Pointer to an untriggered [`zCVob`](../../../../worlds/Classes/zCVob.md) !!! Danger If untriggering the Vob has immediate effects (even before MEM_TriggerVob is exited), the name of the Vob is corrupted during this time. It is not advisable to rename, trigger again or destroy the object at this moment, the behavior in such cases is untested. ### `MEM_SearchVobByName` -Returns the address of a [`zCVob`](./../../../worlds/Classes/zCVob.md) named `str` if such a Vob exists. +Returns the address of a [`zCVob`](../../../../worlds/Classes/zCVob.md) named `str` if such a Vob exists. ```dae func int MEM_SearchVobByName(var string str) ``` **Parameters** - `#!dae var string str` - Name of searched [`zCVob`](./../../../worlds/Classes/zCVob.md) + Name of searched [`zCVob`](../../../../worlds/Classes/zCVob.md) **Return value** -The function returns a pointer to the [`zCVob`](./../../../worlds/Classes/zCVob.md) if the object with the given name exist. `0` is returned otherwise. +The function returns a pointer to the [`zCVob`](../../../../worlds/Classes/zCVob.md) if the object with the given name exist. `0` is returned otherwise. ### `MEM_SearchAllVobsByName` @@ -262,11 +262,11 @@ func int MEM_SearchAllVobsByName(var string str) **Parameters** - `#!dae var string str` - Name of searched [`zCVob`](./../../../worlds/Classes/zCVob.md) + Name of searched [`zCVob`](../../../../worlds/Classes/zCVob.md) **Return value** -The function returns a pointer to the created `zCArray`, taht contains pointers to the all Vobs with the specified name. +The function returns a pointer to the created `zCArray`, that contains pointers to the all Vobs with the specified name. ### `MEM_GetBufferCRC32` Calculates the CRC32 hash value from a byte array starting at the address specified by `buf` and having a length of `buflen`. diff --git a/docs/zengin/scripts/extenders/ikarus/functions/string.md b/docs/zengin/scripts/extenders/ikarus/functions/string.md index a07a941cce..fbcfebc76f 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/string.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/string.md @@ -209,7 +209,7 @@ The function returns the index at which the first occurrence of `tok` begins wit ### `STR_SplitCount` Counts the number of parts a string splits into when using a specified separator. ```dae -func int STR_SplitCount(var string str, var string seperator) +func int STR_SplitCount(var string str, var string separator) ``` **Parameters** diff --git a/docs/zengin/scripts/extenders/ikarus/functions/time_benchmark.md b/docs/zengin/scripts/extenders/ikarus/functions/time_benchmark.md index 42f3ffa014..eb281fd746 100644 --- a/docs/zengin/scripts/extenders/ikarus/functions/time_benchmark.md +++ b/docs/zengin/scripts/extenders/ikarus/functions/time_benchmark.md @@ -25,7 +25,7 @@ func int MEM_GetSystemTime() The function returns the elapsed time since the start of Gothic in milliseconds. This value is used for timing measurements, in the `BenchmarkMS` functions. ### `MEM_GetPerformanceCounter` -Call to the WinAPI [`QueryPerformanceCounter`](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter) funciton. +Call to the WinAPI [`QueryPerformanceCounter`](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter) function. ```dae func int MEM_GetPerformanceCounter() ``` diff --git a/docs/zengin/scripts/extenders/ikarus/index.pl.md b/docs/zengin/scripts/extenders/ikarus/index.pl.md index 41accf076e..6d1f1af0b7 100644 --- a/docs/zengin/scripts/extenders/ikarus/index.pl.md +++ b/docs/zengin/scripts/extenders/ikarus/index.pl.md @@ -8,7 +8,7 @@ Ikarus jest biblioteką Daedalusa - języka skryptowego Gothica. Wykorzystuje in | Forum | [:material-forum: Ikarus](https://forum.worldofplayers.de/forum/threads/1299679-Skriptpaket-Ikarus-4) | !!! Trivia "Notatka autora (Sektenspinner)" - Ten pakiet skryptów niebez powodu nazywa się **Ikarus**: + Ten pakiet skryptów nie bez powodu nazywa się **Ikarus**: Można opuścić granice Dedala, ale można też rozbić się i spalić. Na przykład odczyt z nieprawidłowych adresów nie wywoła ostrzeżenia [zSpy](../../../tools/zSpy.md), ale spowoduje wyjście do pulpitu wraz z Access Violation. Nie jest to powód do paniki, ale wymaga tolerancji na frustrację (co może być ogólnie przydatne dla skrypterów). diff --git a/docs/zengin/scripts/extenders/lego/applications/LeGo_applications.d b/docs/zengin/scripts/extenders/lego/applications/LeGo_applications.d index f8f4ecb8f3..9aad19ad0d 100644 --- a/docs/zengin/scripts/extenders/lego/applications/LeGo_applications.d +++ b/docs/zengin/scripts/extenders/lego/applications/LeGo_applications.d @@ -310,7 +310,7 @@ func void Button_Hide(var int hndl) {}; /// @param tex Name of the new texture func void Button_SetTexture(var int hndl, var string tex) {}; -/// Displays a centred text on the button. +/// Displays a centered text on the button. /// /// @param hndl Handle returned from `Button_Create` /// @param caption The text to be displayed diff --git a/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md b/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md index 6469b1a4c2..1ca9bd6cd9 100644 --- a/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md +++ b/docs/zengin/scripts/extenders/lego/applications/bloodsplats.md @@ -42,14 +42,14 @@ func void Bloodsplats_Rage() ``` ### `Npc_GetPercFunc` -`oCNpc::GetPerceptionFunc` engine function wraper +`oCNpc::GetPerceptionFunc` engine function wrapper ```dae func int Npc_GetPercFunc(var C_Npc npc, var int type) ``` **Parameters** - `#!dae var C_NPC npc` - NPC whose percepcion is checked + NPC whose perception is checked - `#!dae var int type` Checked perception type (form [`Constant.d`](https://github.com/VaanaCZ/gothic-2-addon-scripts/blob/Unified-EN/_work/Data/Scripts/Content/_intern/Constants.d#L213-L258)) diff --git a/docs/zengin/scripts/extenders/lego/applications/buffs.md b/docs/zengin/scripts/extenders/lego/applications/buffs.md index 48f3bbb8d2..010649ca42 100644 --- a/docs/zengin/scripts/extenders/lego/applications/buffs.md +++ b/docs/zengin/scripts/extenders/lego/applications/buffs.md @@ -169,7 +169,7 @@ class lCBuff // Internal, no need to set during instance construction var int _startedTime; - var int _endTime; // Not rendundant with durationMS because buffs can be refreshed + var int _endTime; // Not redundant with durationMS because buffs can be refreshed }; ``` diff --git a/docs/zengin/scripts/extenders/lego/applications/buttons.md b/docs/zengin/scripts/extenders/lego/applications/buttons.md index 8bb6ac5353..7446c7c411 100644 --- a/docs/zengin/scripts/extenders/lego/applications/buttons.md +++ b/docs/zengin/scripts/extenders/lego/applications/buttons.md @@ -116,7 +116,7 @@ func void Button_SetTexture(var int hndl, var string tex) Name of the new texture ### `Button_SetCaption` -Displays a centred text on the button. +Displays a centered text on the button. ```dae func void Button_SetCaption(var int hndl, var string caption, var string font) ``` diff --git a/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md b/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md index 4f2c3640c9..57bb2fc502 100644 --- a/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md +++ b/docs/zengin/scripts/extenders/lego/applications/trialoge.pl.md @@ -31,11 +31,11 @@ func void EquipWeapon(var C_NPC slf, var int ItemInstance) - `#!dae var int ItemInstance` Instancja broni do wyposażenia -**Konfigurcja** +**Konfiguracja** `#!dae const int EquipWeapon_TogglesEquip = 1` -Powyższa stała ustala zachowanie funkcji podczas próby założenia już założonej bronii: +Powyższa stała ustala zachowanie funkcji podczas próby założenia już założonej broni: - `0` - `EquipWeapon` nic nie zrobi - `1` - `EquipWeapon` zdejmie tą broń @@ -87,7 +87,7 @@ Podmienia broń założoną przez NPC. ```dae func void Npc_TradeItem(var c_npc slf, var int itm0, var int itm1) ``` -**Parameters** +**Parametry** - `#!dae var C_NPC slf` NPC na którym wykonywana jest operacja @@ -114,7 +114,7 @@ Resetuje kamery dialogowe do ustawień domyślnych. func void DiaCAM_Enable() ``` ### `TRIA_Wait` -Sprawia że `self` i `other` czekają na siebie, np. podaczas dla synchronizacji po wywołaniu `AI_GotoWP`. +Sprawia że `self` i `other` czekają na siebie, np. podczas dla synchronizacji po wywołaniu `AI_GotoWP`. ```dae func void TRIA_Wait() ``` @@ -142,7 +142,7 @@ func void TRIA_Barrier() ``` ### `TRIA_Next` -Ustawia podanego npc na `self`. +Ustawia podanego NPC na `self`. ```dae func void TRIA_Next(var C_NPC n0) ``` diff --git a/docs/zengin/scripts/extenders/lego/tools/ai_function.md b/docs/zengin/scripts/extenders/lego/tools/ai_function.md index ebc99769e9..c6695dc612 100644 --- a/docs/zengin/scripts/extenders/lego/tools/ai_function.md +++ b/docs/zengin/scripts/extenders/lego/tools/ai_function.md @@ -40,7 +40,7 @@ func void AI_Function_SS (var C_NPC slf, var func function, var string param1, v func void AI_Function_IS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Int, String func void AI_Function_SI (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Int func void AI_Function_NS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Instance, String -func void AI_Function_SN (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Istance +func void AI_Function_SN (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Instance func void AI_Function_IN (var C_NPC slf, var func function, var int param1, var int param2) {}; // Int, Instance func void AI_Function_NI (var C_NPC slf, var func function, var int param1, var int param2) {}; // Instance, Int ``` diff --git a/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md b/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md index a82a2c85bf..0357b2d870 100644 --- a/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md +++ b/docs/zengin/scripts/extenders/lego/tools/ai_function.pl.md @@ -17,12 +17,12 @@ LeGo_Init(LeGo_AI_Function); ## Implementacja [:material-github: AI_Function.d na GitHubie](https://github.com/Lehona/LeGo/blob/dev/AI_Function.d) -## Functions +## Funkcje Funkcja `function` jest wywoływana z opóźnieniem: dołącza do kolejki AI `slf`. ```dae func void AI_Function(var C_NPC slf, var func function) ``` -**Parameters** +**Parametry** - `#!dae var C_NPC slf` NPC, do którego kolejki AI dołącza funkcja @@ -40,7 +40,7 @@ func void AI_Function_SS (var C_NPC slf, var func function, var string param1, v func void AI_Function_IS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Int, String func void AI_Function_SI (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Int func void AI_Function_NS (var C_NPC slf, var func function, var int param1, var string param2) {}; // Instance, String -func void AI_Function_SN (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Istance +func void AI_Function_SN (var C_NPC slf, var func function, var string param1, var int param2) {}; // String, Instance func void AI_Function_IN (var C_NPC slf, var func function, var int param1, var int param2) {}; // Int, Instance func void AI_Function_NI (var C_NPC slf, var func function, var int param1, var int param2) {}; // Instance, Int ``` diff --git a/docs/zengin/scripts/extenders/lego/tools/binary_machines.md b/docs/zengin/scripts/extenders/lego/tools/binary_machines.md index 1c874509ac..640d14f1b7 100644 --- a/docs/zengin/scripts/extenders/lego/tools/binary_machines.md +++ b/docs/zengin/scripts/extenders/lego/tools/binary_machines.md @@ -28,7 +28,7 @@ func int BW_NewFile(var string file) **Return value** -The function returns `TRUE` if the file is successfully created and initialized, `FALSE`is returned otherwise. +The function returns `TRUE` if the file is successfully created and initialized, `FALSE` is returned otherwise. ### `BW_Close` Closes the current write stream. diff --git a/docs/zengin/scripts/extenders/lego/tools/hashtables.md b/docs/zengin/scripts/extenders/lego/tools/hashtables.md index cb1df38c68..f0003acd9f 100644 --- a/docs/zengin/scripts/extenders/lego/tools/hashtables.md +++ b/docs/zengin/scripts/extenders/lego/tools/hashtables.md @@ -187,7 +187,7 @@ func void PrintKeyValuePair(var int key, var int val) Print(ConcatStrings(ConcatStrings("Key: ", IntToString(key)), ConcatStrings(", Value: ", IntToString(val)))); }; -func void exapmle() +func void example() { // Create a new hashtable var int hashtableHandle; hashtableHandle = HT_Create(); diff --git a/docs/zengin/scripts/extenders/lego/tools/hook_dae.md b/docs/zengin/scripts/extenders/lego/tools/hook_dae.md index 69893f5d2c..eaaf3ef5d6 100644 --- a/docs/zengin/scripts/extenders/lego/tools/hook_dae.md +++ b/docs/zengin/scripts/extenders/lego/tools/hook_dae.md @@ -128,7 +128,7 @@ The functions can look like that: ```dae func void hooked() { - Print("Orginal function"); + Print("Original function"); }; func void hook() @@ -140,7 +140,7 @@ func void hook() The results should look like that ```dae Our hook -Orginal function +Original function ``` ### Hook after function @@ -152,7 +152,7 @@ The functions are also similar, but the `ContinueCall();` is called first: ```dae func void hooked() { - Print("Orginal function"); + Print("Original function"); }; func void hook() @@ -163,7 +163,7 @@ func void hook() ``` The results should look like that: ```dae -Orginal function +Original function Our hook ``` @@ -172,7 +172,7 @@ If a function to be hooked expects parameters or returns a value, our hooking fu ```dae func int hooked(var int i) { - Print("Orginal function"); + Print("Original function"); return i+1; }; diff --git a/docs/zengin/scripts/extenders/lego/tools/list.md b/docs/zengin/scripts/extenders/lego/tools/list.md index 3809718d6b..884e37d031 100644 --- a/docs/zengin/scripts/extenders/lego/tools/list.md +++ b/docs/zengin/scripts/extenders/lego/tools/list.md @@ -305,10 +305,10 @@ func int List_Compare(var int data1, var int data2, var func compare) - `#!dae var int data2` The second integer value. - `#!dae var func compare` - One of comparsion functions. + One of comparison functions. **Return value** -The function returns the return value of specified comparsion funtion. +The function returns the return value of specified comparison function. ## Comparison Functions diff --git a/docs/zengin/scripts/extenders/lego/tools/misc.md b/docs/zengin/scripts/extenders/lego/tools/misc.md index cfa99abc9b..f20b55745c 100644 --- a/docs/zengin/scripts/extenders/lego/tools/misc.md +++ b/docs/zengin/scripts/extenders/lego/tools/misc.md @@ -20,7 +20,7 @@ Misc package implements the `phi` constant ```dae const int phi = 1070141312; // PI/2 ``` -whitch is actualy `pi` divided by 2 saved as an ikarus float. +which is actually `pi` divided by 2 saved as an ikarus float. Decimal: `1.5707...` diff --git a/docs/zengin/scripts/extenders/zparserextender/classes/c_trigger.md b/docs/zengin/scripts/extenders/zparserextender/classes/c_trigger.md index ba3ab90bf6..a07eda08ef 100644 --- a/docs/zengin/scripts/extenders/zparserextender/classes/c_trigger.md +++ b/docs/zengin/scripts/extenders/zparserextender/classes/c_trigger.md @@ -8,10 +8,10 @@ zParserExtender also implements cyclical functions called triggers - not to be c To define a trigger, the `C_Trigger` class is used: ```dae -/// Union zPraserExtender Trigger class +/// Union zParserExtender Trigger class class C_Trigger { - var int Delay; // defines the frequency (in miliseconds) at which the function will be called. + var int Delay; // defines the frequency (in milliseconds) at which the function will be called. var int Enabled; // determines if the trigger is active. If the value is equal to zero, the trigger is destroyed. var int AIVariables[16]; // user data, which can be set independently when creating trigger (yes, you can write there absolutely everything you want). @@ -93,12 +93,12 @@ To search for a specific trigger, for example by NPC, the [trigger external func ```dae // This way you can disable all triggers running on the `hero` instance -var C_Trigger trigget = FirstTrigger; -var C_Trigger trigget_saved; -while (!Hlp_IsNULL(trigget)) +var C_Trigger trigger = FirstTrigger; +var C_Trigger trigger_saved; +while (!Hlp_IsNULL(trigger)) { - trigget_saved = trigger; + trigger_saved = trigger; trigger = AI_GetNextTriggerBySelf(hero); - trigget_saved.Enabled = false; + trigger_saved.Enabled = false; }; ``` diff --git a/docs/zengin/scripts/extenders/zparserextender/classes/helperclasses.md b/docs/zengin/scripts/extenders/zparserextender/classes/helperclasses.md index a68c5a84fc..513a39cc47 100644 --- a/docs/zengin/scripts/extenders/zparserextender/classes/helperclasses.md +++ b/docs/zengin/scripts/extenders/zparserextender/classes/helperclasses.md @@ -44,7 +44,7 @@ Externals: /// Returns the current position of the object in the world /// /// @param vob vob to ge the position of -/// @return C_Position instace - position of the VOB +/// @return C_Position instance - position of the VOB func C_Position Vob_GetVobPosition( var C_Vob vob ) {}; /// Sets the current position of the object in the world @@ -72,8 +72,8 @@ class C_VOB_DATA var int CollDetectionStatic; // allow collision with static world polygons var int CollDetectionDynamic; // allow collision with dynamic world objects var int CastDynShadow; // display shadow of the object - var int LightColorStatDirty; // allow static liging of the object - var int LightColorDynDirty; // allow dynamic lighing of the object + var int LightColorStatDirty; // allow static lighting of the object + var int LightColorDynDirty; // allow dynamic lighting of the object var int SleepingMode; // sets object's activity mode (0 - inactive, 1 - active, 2 - AI only) var int DontWriteIntoArchive; // turns of the serialization of this object to the save file }; diff --git a/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/meta.md b/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/meta.md index 2abe4d6de7..84ab058708 100644 --- a/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/meta.md +++ b/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/meta.md @@ -17,7 +17,7 @@ META Menu parserMenu Menu.dat Music parserMusic Music.dat */ - MergeMode // 0 - if confilct occurs = comilation error, 1 - if conflict occurs = hook + MergeMode // 0 - if conflict occurs = compilation error, 1 - if conflict occurs = hook Engine // comma separated list of engines for which the scripts will be injected /* Code Engine Human readable name diff --git a/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/other.md b/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/other.md index 05d05ab525..08574b9b2c 100644 --- a/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/other.md +++ b/docs/zengin/scripts/extenders/zparserextender/daedalus_injection/other.md @@ -37,7 +37,7 @@ StringIndexingMode = -1 zParserExtender adds console commands that save copies of the `.dat` files with the injected code. !!! warning - If the mod uses Ikarus, the `CompileDat` option (in the `.ini` file) should be used since a fatal error may occur whe using the command. + If the mod uses Ikarus, the `CompileDat` option (in the `.ini` file) should be used since a fatal error may occur when using the command. ``` Parser SaveDat OU - exports OU.Edited.bin diff --git a/docs/zengin/scripts/extenders/zparserextender/examples/signposts.md b/docs/zengin/scripts/extenders/zparserextender/examples/signposts.md index fc3e2804e2..7b052bf967 100644 --- a/docs/zengin/scripts/extenders/zparserextender/examples/signposts.md +++ b/docs/zengin/scripts/extenders/zparserextender/examples/signposts.md @@ -9,7 +9,7 @@ The goal is to introduce a function that will teleport you to every signpost in In ZenGin you can teleport to named game objects with the `goto vob {vobname}` command. But since the signposts do not have a vobname defined, I had to figure out a different approach. ## ASCII ZEN -We want to get all the signposts position from Khorinis. The game world was loaded into one of the available world editor, I found one of the signposts and noted the `visual` which dictates the model of the in-game object `nw_misc_sign_01.3DS`. Alternatively, you can find the standard vanilla objects from both games on this [website](https://dziejekhorinis.org/dev/vobbilder/). +We want to get all the signposts position from Khorinis. The game world was loaded into one of the available world editor, I found one of the signposts and noted the `visual` which dictates the model of the in-game object `nw_misc_sign_01.3DS`. Alternatively, you can find the standard vanilla objects from both games on this [website](https://vobbilder.dziejekhorinis.org/vobbilder/). Next, the world was saved as a `ASCII ZEN` format. This allows us to write a macro to search for all instances of objects with a specific visual and extract the position vector. ```ini title="One signpost object" hl_lines="6 8" @@ -59,7 +59,7 @@ Next, the world was saved as a `ASCII ZEN` format. This allows us to write a mac ## The injectable script As it is an injectable script, we have to specify the `META` tag. -Lets tell zParseExtender to insert this code into the game parser. +Lets tell zParserExtender to insert this code into the game parser. ```dae META { @@ -87,8 +87,8 @@ class C_VOB_DATA var int CollDetectionStatic; // allow collision with static world polygons var int CollDetectionDynamic; // allow collision with dynamic world objects var int CastDynShadow; // display shadow of the object - var int LightColorStatDirty; // allow static liging of the object - var int LightColorDynDirty; // allow dynamic lighing of the object + var int LightColorStatDirty; // allow static lighting of the object + var int LightColorDynDirty; // allow dynamic lighting of the object var int SleepingMode; // sets object's activity mode (0 - inactive, 1 - active, 2 - AI only) var int DontWriteIntoArchive; // turns of the serialization of this object to the save file }; diff --git a/docs/zengin/scripts/extenders/zparserextender/externals/events_vars.md b/docs/zengin/scripts/extenders/zparserextender/externals/events_vars.md index e035b7fc98..32d6a718cd 100644 --- a/docs/zengin/scripts/extenders/zparserextender/externals/events_vars.md +++ b/docs/zengin/scripts/extenders/zparserextender/externals/events_vars.md @@ -5,10 +5,10 @@ title: Event functions On top of external functions, zParserExtender also adds these event functions and constants. ```dae -/// Every event function with this name is exectued once every frame +/// Every event function with this name is executed once every frame func event GameLoop() {}; -/// Every event function with this name is exectued once on game init +/// Every event function with this name is executed once on game init func event GameInit() {}; /// empty instance diff --git a/docs/zengin/scripts/extenders/zparserextender/index.md b/docs/zengin/scripts/extenders/zparserextender/index.md index a57b0b0adb..ebe4ad3a91 100644 --- a/docs/zengin/scripts/extenders/zparserextender/index.md +++ b/docs/zengin/scripts/extenders/zparserextender/index.md @@ -1,5 +1,5 @@ # zParserExtender -zParserExtender extends ZenGins parser and adds many useful features. It significantly extends the functionality of scripts with added functionality and new external functions. It also enhances script compilation, allowing to compile OU files directly with the game and allowing for runtime script injection. Since the Union version `1.0m` zParserExtender is fully integrated in Union itself. +zParserExtender extends ZenGin's parser and adds many useful features. It significantly extends the functionality of scripts with added functionality and new external functions. It also enhances script compilation, allowing to compile OU files directly with the game and allowing for runtime script injection. Since the Union version `1.0m` zParserExtender is fully integrated in Union itself. !!! note This is mostly a translation of the original [release post](https://worldofplayers.ru/threads/41999/) diff --git a/docs/zengin/scripts/extenders/zparserextender/syntax_extensions/testelse.md b/docs/zengin/scripts/extenders/zparserextender/syntax_extensions/testelse.md index 8f45c5fabe..5d2b45bf46 100644 --- a/docs/zengin/scripts/extenders/zparserextender/syntax_extensions/testelse.md +++ b/docs/zengin/scripts/extenders/zparserextender/syntax_extensions/testelse.md @@ -11,7 +11,7 @@ Valid values: - engine tag - `G1`, `G1A`, `G2`, `G2A` - Steam Overlay activity - `Steam` -The result can be combined from several arguments. Round brackets `()` ca be used to specify priority and expressions support the logical negation operator `!`, logical AND `&&` and OR `||`. +The result can be combined from several arguments. Round brackets `()` can be used to specify priority and expressions support the logical negation operator `!`, logical AND `&&` and OR `||`. The operator can be used anywhere in the script file. It is syntactically similar to `if else` statement, but curly braces `{}` can be omitted for single-line operations. For example: diff --git a/docs/zengin/scripts/externals/doc.md b/docs/zengin/scripts/externals/doc.md index 84ef2fbf7c..9cf648f0dd 100644 --- a/docs/zengin/scripts/externals/doc.md +++ b/docs/zengin/scripts/externals/doc.md @@ -79,7 +79,7 @@ func void Doc_SetLevelCoords(var int docID, var int left, var int top, var int r ``` ## `Doc_SetFont` -Sets a `font` to be used on a `page` in a document with `docID`. Can be called multiple times to diplay different lines with different fonts. +Sets a `font` to be used on a `page` in a document with `docID`. Can be called multiple times to display different lines with different fonts. ```dae func void Doc_SetFont(var int docID, var int page, var string font) {}; @@ -251,7 +251,7 @@ func void Doc_PrintLine(var int docID, var int page, var string text) {}; /// @param text text to be printed func void Doc_PrintLines(var int docID, var int page, var string text) {}; -/// Sets a `font` to be used on a `page` in a document with `docID`. Can be called multiple times to diplay different lines with different fonts. +/// Sets a `font` to be used on a `page` in a document with `docID`. Can be called multiple times to display different lines with different fonts. /// /// @param docID document manager ID /// @param page page index diff --git a/docs/zengin/scripts/externals/externals.d b/docs/zengin/scripts/externals/externals.d index 529fcb5b2f..6750beba60 100644 --- a/docs/zengin/scripts/externals/externals.d +++ b/docs/zengin/scripts/externals/externals.d @@ -129,17 +129,17 @@ func string IntToString(var int x) {}; /// Creates a new log topic with the name `topicName` under the section `logSection` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param logSection [LOG_MISSION, LOG_NOTE] indicates in which section to create the topic in func void Log_CreateTopic(var string topicName, var int logSection) {}; /// Adds an entry to a log topic with the name `topicName` under the section `logSection` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param entry content of the new entry func void Log_AddEntry(var string topicName, var string entry) {}; /// Changes the status of the topic with the name `topicName` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param status [LOG_RUNNING, LOG_SUCCESS, LOG_FAILED, LOG_OBSOLETE] the status to be set func void Log_SetTopicStatus(var string TopicName, var int status) {}; diff --git a/docs/zengin/scripts/externals/externals_clean.d b/docs/zengin/scripts/externals/externals_clean.d index 1591d52b6f..0d67d9eea6 100644 --- a/docs/zengin/scripts/externals/externals_clean.d +++ b/docs/zengin/scripts/externals/externals_clean.d @@ -127,17 +127,17 @@ func string IntToString(var int x) {}; /// Creates a new log topic with the name `topicName` under the section `logSection` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param logSection [LOG_MISSION, LOG_NOTE] indicates in which section to create the topic in func void Log_CreateTopic(var string topicName, var int logSection) {}; /// Adds an entry to a log topic with the name `topicName` under the section `logSection` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param entry content of the new entry func void Log_AddEntry(var string topicName, var string entry) {}; /// Changes the status of the topic with the name `topicName` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param status [LOG_RUNNING, LOG_SUCCESS, LOG_FAILED, LOG_OBSOLETE] the status to be set func void Log_SetTopicStatus(var string TopicName, var int status) {}; diff --git a/docs/zengin/scripts/externals/index.md b/docs/zengin/scripts/externals/index.md index 173b2a37d8..696bcdde8f 100644 --- a/docs/zengin/scripts/externals/index.md +++ b/docs/zengin/scripts/externals/index.md @@ -1,3 +1,3 @@ # Externals External functions are Daedalus functions (defined in the engine itself), that are used to interface with the engine. Gothic 1 and Gothic 2 implements slightly different set of external functions. -There are some external functions, that were used in the course of Gothics development, but are now obsolete/deprecated because the underlying systems implemented in the engine were either turned off, or broken all together. +There are some external functions, that were used in the course of Gothic's development, but are now obsolete/deprecated because the underlying systems implemented in the engine were either turned off, or broken all together. diff --git a/docs/zengin/scripts/externals/log.md b/docs/zengin/scripts/externals/log.md index 3e7ab56d9b..e31119cdaf 100644 --- a/docs/zengin/scripts/externals/log.md +++ b/docs/zengin/scripts/externals/log.md @@ -63,7 +63,7 @@ func void Log_SetTopicStatus(var string topicName, var int status) {}; ## zParserExtender The log external function selection is missing functions to retrieve the status of a log entry. There are only functions to read the log status (as discussed on [Inside Gothic](https://ataulien.github.io/Inside-Gothic/QuestLog/)). As a result of this the original scriptwriters had to define additional variable to track the log status in the scripts, even though the value is being already tracked by the engine. -zParserExtender fixes this by introducing new [log external functions](../extenders/zparserextender/externals/log/). +zParserExtender fixes this by introducing new [log external functions](../extenders/zparserextender/externals/log.md). ## Externals with docu comments @@ -71,19 +71,19 @@ zParserExtender fixes this by introducing new [log external functions](../extend ```dae /// Creates a new log topic with the name `topicName` under the section `logSection` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param logSection [LOG_MISSION, LOG_NOTE] indicates in which section to create the topic in func void Log_CreateTopic(var string topicName, var int logSection) {}; /// Creates a new log topic with the name `topicName` under the section `logSection` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param logSection [LOG_MISSION, LOG_NOTE] indicates in which section to create the topic in func void Log_AddEntry(var string topicName, var string entry) {}; /// Changes the status of the topic with the name `topicName` /// -/// @param topicName unique string used to identifiy and name the topic +/// @param topicName unique string used to identify and name the topic /// @param status [LOG_RUNNING, LOG_SUCCESS, LOG_FAILED, LOG_OBSOLETE] the status to be set func void Log_SetTopicStatus(var string topicName, var int status) {}; ``` diff --git a/docs/zengin/scripts/externals/mdl.md b/docs/zengin/scripts/externals/mdl.md index 375472bbd6..20cedf29a1 100644 --- a/docs/zengin/scripts/externals/mdl.md +++ b/docs/zengin/scripts/externals/mdl.md @@ -208,7 +208,7 @@ func void Mdl_ApplyRandomFaceAni(var c_npc npc, - `#!dae var float timemaxvar` Maximum boundary variation (in seconds) - `#!dae var float probmin` - Probablity (0.0 to 1.0) to choose the lower boundary time + Probability (0.0 to 1.0) to choose the lower boundary time ## Externals with docu comments @@ -235,7 +235,7 @@ func void Mdl_RemoveOverlayMDS(var c_npc npc, var string overlay_name) {}; /// Assign a random animation `ani2` to random animation list of animation `ani1` /// /// @param npc NPC owning the animation -/// @param ani1 the animation to asign random animation to +/// @param ani1 the animation to assign random animation to /// @param ani2 animation to be assigned func void Mdl_ApplyRandomAni(var c_npc npc, var string ani1, var string ani2) {}; @@ -304,7 +304,7 @@ func void Mdl_StartFaceAni(var c_npc npc, /// @param timeminvar minimum boundary variation (in seconds) /// @param timemax maximum time after which the ani should be started (in seconds) /// @param timemaxvar maximum boundary variation (in seconds) -/// @param probmin probablity (0.0 to 1.0) to choose the lower boundary time +/// @param probmin probability (0.0 to 1.0) to choose the lower boundary time func void Mdl_ApplyRandomFaceAni(var c_npc npc, var string name, var float timemin, diff --git a/docs/zengin/sound/index.md b/docs/zengin/sound/index.md index 6bbbc5e30c..027ba1e870 100644 --- a/docs/zengin/sound/index.md +++ b/docs/zengin/sound/index.md @@ -12,7 +12,7 @@ Original gothic sound files has following properties: - 32-bit [depth](https://en.wikipedia.org/wiki/Audio_bit_depth) ## SFX -Sound effects (SFX) are sounds made by monsters, spells, weapons etc. Sound effects are defined in multiple places, in `.mds` files as part of the animation [EventBlocks](../anims/events.md), or in the SFX Daeduls scripts. Sounds are located in the `_work/Data/Sound/SFX` directory. +Sound effects (SFX) are sounds made by monsters, spells, weapons etc. Sound effects are defined in multiple places, in `.mds` files as part of the animation [EventBlocks](../anims/events.md), or in the SFX Daedalus scripts. Sounds are located in the `_work/Data/Sound/SFX` directory. ## Speech Dubbing for dialogues is located into `_work/Data/Sound/Speech` folder. Every single `AI_Output` has its own sound file with name defined in the function itself. diff --git a/docs/zengin/tools/index.md b/docs/zengin/tools/index.md index 4434a39252..8abc5e9999 100644 --- a/docs/zengin/tools/index.md +++ b/docs/zengin/tools/index.md @@ -17,7 +17,7 @@ video games Gothic and Gothic 2 Night of the Raven. **[VDFS tools](../general_info/vdfs.md)** -- [GothicVDFS](vdfs_tools/gothic_vdfs.md) - NiceDE's viewer, extractor and builder for `.vdf` and `.mod` volumes +- [GothicVDFS](vdfs_tools/gothic_vdfs.md) - NicoDE's viewer, extractor and builder for `.vdf` and `.mod` volumes - [VDFS Tool](vdfs_tools/vdfs_tool.md) - Gratt's Union VDFS viewer, extractor, builder, optimizer and ZIP compressor for `.vdf` and `.mod` volumes **[World Editors](../worlds/index.md)** diff --git a/docs/zengin/union/sdk/getting_started.md b/docs/zengin/union/sdk/getting_started.md index 2bf7f5d46e..25262ef68b 100644 --- a/docs/zengin/union/sdk/getting_started.md +++ b/docs/zengin/union/sdk/getting_started.md @@ -21,10 +21,10 @@ We will also check "Place solution and project in the same directory" because ou | Folder / File | Description | |----------------|-------------------------------------------| -| **Engine SDK/** | In this folder, we have the Gothic Engine API in the form of header files. Most of the files between engines are very similar to each other but they can't be used interchangeably because each engine has slighly different API and addresses of functions. | +| **Engine SDK/** | In this folder, we have the Gothic Engine API in the form of header files. Most of the files between engines are very similar to each other but they can't be used interchangeably because each engine has slightly different API and addresses of functions. | | **Engine SDK/User API/** | These are empty files that are included in the corresponding engine headers. There are meant for placing additional methods extending classes that can be used for example in [Hooks](hooks.md). | | **Plugin/System/** | DLL entry point generated by Union. We shouldn't modify anything here. | -| **Plugin/Workspace/Interface/** | These are header files containing headerss and source files important in correct order and an `Interface.cpp` file that merges all the code into one file. | +| **Plugin/Workspace/Interface/** | These are header files containing headers and source files important in correct order and an `Interface.cpp` file that merges all the code into one file. | | **Plugin/Workspace/Plugin/** | Finally, this is the source code of the plugin and especially `Plugin.cpp` where we can create code executed on [Game Events](events.md). | #### Build Configuration diff --git a/docs/zengin/union/sdk/hooks.md b/docs/zengin/union/sdk/hooks.md index 5bf1e76b8b..7b7948b01f 100644 --- a/docs/zengin/union/sdk/hooks.md +++ b/docs/zengin/union/sdk/hooks.md @@ -102,7 +102,7 @@ enum EInterMode // Hook will not intercept the function. IVK_DISABLED = 1 << 1, - // Normal hook. If other hook is alredy defined for the same address, an error pops up. + // Normal hook. If other hook is already defined for the same address, an error pops up. IVK_NORMAL = 1 << 2, // Hook will automatically create an interception tree to allow multiple hooks for the same address. diff --git a/docs/zengin/worlds/spacer.md b/docs/zengin/worlds/spacer.md index 3449773a74..5287809f08 100644 --- a/docs/zengin/worlds/spacer.md +++ b/docs/zengin/worlds/spacer.md @@ -94,7 +94,7 @@ This section covers some of the basic things done in the editor. - Make sure to click the Apply button. Do this after making any changes in the Object window or they will be lost. !!! tip - You can use the VOB Bilder tool to comfortably browse model images and names. An online version is currently available [here](https://dziejekhorinis.org/dev/vobbilder/). The UI on the website is in Polish but it's simple enough to not matter. + You can use the VOB Bilder tool to comfortably browse model images and names. An online version is currently available [here](https://vobbilder.dziejekhorinis.org/vobbilder/). The UI on the website is in Polish but it's simple enough to not matter. - To make the VOB have collision in-game, double click on `cdDyn` ("collision detection dynamic") to set it to true. Sometimes this is unadvised, e.g. with bushes or grass. @@ -103,7 +103,7 @@ This section covers some of the basic things done in the editor. ### Common VOB settings -VOB settings vary depending on what the VOB type is. They all have common parameters of the base VOB class though. The full descripton of a zCVob class can be found [here](Classes/zCVob.md). +VOB settings vary depending on what the VOB type is. They all have common parameters of the base VOB class though. The full description of a zCVob class can be found [here](Classes/zCVob.md). ## Issues diff --git a/mkdocs.yml b/mkdocs.yml index e3e98cbbd3..ae946e0038 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,13 +7,16 @@ repo_url: https://github.com/Gothic-Modding-Community/gmc/ edit_uri: edit/main/docs/ watch: - - overrides + - overrides/assets + - overrides/.snippets + - overrides/main.html hooks: - overrides/.hooks/theme_overrides_manager.py - overrides/.hooks/language_flags.py - overrides/.hooks/git_redirects.py - - overrides/.hooks/social_patch.py + - overrides/.hooks/all_plugin_patch.py + - overrides/.hooks/preferences.py theme: name: material @@ -50,6 +53,7 @@ theme: - content.code.copy - content.action.edit - content.action.view + - content.tooltips extra_css: - assets/stylesheets/extra.css @@ -85,6 +89,7 @@ markdown_extensions: # it's required for the links to work and to allow highlighting via JavaScript line_anchors: example line_spans: example + pygments_lang_class: true - pymdownx.inlinehilite - pymdownx.snippets: base_path: ['./overrides/.snippets/'] @@ -95,8 +100,8 @@ markdown_extensions: - footnotes - attr_list - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg - pymdownx.smartsymbols - pymdownx.tabbed: alternate_style: true @@ -128,8 +133,8 @@ plugins: js_files: - assets/javascripts/extra.js - i18n: + build_only_locale: !ENV [GMC_DEV_LOCALE] docs_structure: suffix - development_locale: !ENV [GMC_DEV_LOCALE] languages: - name: en - English locale: en @@ -181,10 +186,11 @@ plugins: timezone: Europe/Warsaw exclude: - index*.md + - preferences*.md - genome/index*.md - zengin/index*.md - redirects: # Empty dict to fill with the `meta_redirects.py` hook. redirect_maps: {} - social: - cards: !ENV [GMC_ENABLE_ON_PUBLISH, False] \ No newline at end of file + enabled: !ENV [GMC_ENABLE_ON_PUBLISH, False] \ No newline at end of file diff --git a/overrides/.hooks/all_plugin_patch.py b/overrides/.hooks/all_plugin_patch.py new file mode 100644 index 0000000000..c6a64451e2 --- /dev/null +++ b/overrides/.hooks/all_plugin_patch.py @@ -0,0 +1,283 @@ +"""MkDocs hook, which patches different plugins and modules used within Gothic Modding Community. + +Social Plugin (from the Material theme) +- The hook fixes a crash when using theme.font.code without theme.font.text. +- The hook overrides the `theme.logo` file lookup to use the custom_dir instead of the docs_dir. +- The hook does not override `theme.logo.icon` file lookup. +- The hook overrides the `on_page_markdown` function to make it compatible with the i18n plugin + +Pygments Lexers (used to highlight code) +- The hook decorates the pygments.lexers.get_lexer_by_name function, + adding cache for custom lexers, like the Gothic Lexer used in GMC + +i18n Plugin (mkdocs-static-i18n) +- The hook creates redirects for all built alternate languages using the mkdocs-redirects plugin +- The hook merges nav_translations of alternate languages with the default language + +Search Plugin (from the Material theme) +- The hook separates page.meta.title from page.markdown.title. + In turn the result heading should use the page.markdown.title. + +MIT Licence 2023 Kamil Krzyśków (HRY) +""" +import logging +from copy import deepcopy +from pathlib import Path +from typing import Optional + +from mkdocs import plugins +from mkdocs.config import Config +from mkdocs.config.defaults import MkDocsConfig +from mkdocs.plugins import PrefixedLogger +from mkdocs.utils import get_markdown_title +from pygments import lexers +from pymdownx import highlight + + +@plugins.event_priority(100) +def on_config(config: MkDocsConfig) -> Optional[Config]: + social_plugin = config.plugins.get("material/social") or config.plugins.get("social") + i18n_plugin = config.plugins.get("i18n") + redirects_plugin = config.plugins.get("redirects") + + has_been_patched = hasattr(config.extra, "all_plugin_patch") + + # these patches can be run multiple times + # as they are aware of multiple executions + if i18n_plugin and redirects_plugin: + process_i18n_redirects(has_been_patched, i18n_plugin, redirects_plugin) + + # the rest of the patches only need to be applied once + # as they aren't aware of multiple executions + if has_been_patched: + return None + + LOG.info("Adding cache to custom lexers") + + highlight.get_lexer_by_name = patch_lexers_cache(lexers.get_lexer_by_name) + lexers.get_lexer_by_name = patch_lexers_cache(lexers.get_lexer_by_name) + + if social_plugin: + LOG.info("Fixing possible social card plugin crash") + social_plugin._load_font = patch_social_font_crash(social_plugin._load_font) + social_plugin._load_logo = patch_social_custom_dir(social_plugin._load_logo) + + if i18n_plugin: + process_i18n_nav_translations(i18n_plugin) + + return None + + +@plugins.event_priority(100) +def on_pre_build(config): + search_plugin = config.plugins.get("material/search") or config.plugins.get("search") + + if search_plugin and hasattr(search_plugin, "search_index"): + LOG.info("Separating page.title from page.meta.title in SearchIndex") + search_plugin.search_index.create_entry_for_section = patch_search_entry_title( + search_plugin.search_index.create_entry_for_section + ) + + +@plugins.event_priority(100) +def on_env(env, config, **_): + has_been_patched = hasattr(config.extra, "all_plugin_patch") + if not has_been_patched: + LOG.info("Enabling simple whitespace trimming in the Jinja2 environment") + + env.trim_blocks = True + env.lstrip_blocks = True + + return env + + +@plugins.event_priority(100) +def on_post_build(config) -> None: + has_been_patched = hasattr(config.extra, "all_plugin_patch") + if has_been_patched: + return + + social_plugin = config.plugins.get("material/social") or config.plugins.get("social") + i18n_plugin = config.plugins.get("i18n") + + if social_plugin and i18n_plugin: + LOG.info("Wrapping social plugin to prevent overlapping file names") + process_social_cards_i18n(config, social_plugin, i18n_plugin) + + config.extra.all_plugin_patch = True + + +class Mock: + ... + + +def patch_social_font_crash(func): + """Patch the theme["font"]["text"] crash""" + + def wrap_load_font(config): + theme = config.theme + if "font" in theme and "text" not in theme["font"]: + mock_config = Mock() + mock_config.theme = deepcopy(config.theme) + mock_config.theme["font"]["text"] = "Roboto" + return func(mock_config) + return func(config) + + return wrap_load_font + + +def patch_social_custom_dir(func): + """Patch support for paths in `custom_dir`""" + + def wrap_load_logo(config): + mock_config = Mock() + mock_config.theme = config.theme + mock_config.docs_dir = str(Path(config.docs_dir).parent / CUSTOM_DIR_PATH) + return func(mock_config) + + return wrap_load_logo + + +def patch_lexers_cache(func): + """Patch cache into the get_lexer_by_name function""" + + def wrap_get_lexer_by_name(alias, **options): + cached_class = LEXER_CLASS_CACHE.get(alias) + + if cached_class: + return cached_class(**options) + + lexer = func(alias, **options) + LEXER_CLASS_CACHE[alias] = lexer.__class__ + return lexer + + return wrap_get_lexer_by_name + + +def process_i18n_redirects(has_been_patched, i18n_plugin, redirects_plugin): + import mkdocs_redirects.plugin as module + + # clear the redirects_maps in the alternate builds, + # because everything is created in the default build + if has_been_patched: + redirects_plugin.config["redirect_maps"].clear() + return + + # assert API is available to change + if not hasattr(module, "write_html"): + LOG.warning("Current version of mkdocs-redirects plugin isn't compatible with the patch") + return + + LOG.info("Wrapping mkdocs-redirects to also create redirects for alternate languages") + + def write_html_decorator(func): + def write_html_wrapper(site_dir, old_path, new_path): + # write html for default build + func(site_dir, old_path, new_path) + # write html for each built alternate + for lang in i18n_plugin.config.languages: + if lang.build is True and lang.default is False: + func(site_dir, lang.link[1:] + old_path, new_path) + + return write_html_wrapper + + module.write_html = write_html_decorator(module.write_html) + + +def process_i18n_nav_translations(i18n_plugin): + for lang in i18n_plugin.config.languages: + if lang.default is True: + default_translations = lang.nav_translations or {} + + if not default_translations: + return + + LOG.info("Merging nav_translations of alternate languages with default") + + for lang in i18n_plugin.config.languages: + if lang.default is False and lang.build is True: + lang.nav_translations = {**default_translations, **(lang.nav_translations or {})} + + +def process_social_cards_i18n(config, social_plugin, i18n_plugin): + """ + The social plugin uses the page.file.src_path and page.file.src_uri + to generate both the card image filename and html meta tag url to that file. + To avoid overwriting the default language cards, when another language page + isn't translated it's required to wrap the plugin's on_page_markdown event + and provide the page object with replaced values + TODO The Insiders Social Plugin could behave differently, and the wrapper might not work + """ + + def on_page_markdown_decorator(func): + def on_page_markdown_wrapper(markdown, page, config, files): + src_path = Path(page.file.src_path) + + # if the source path has multiple suffixes it won't override the default language + if len(src_path.suffixes) > 1: + return func(markdown, page, config, files) + + src_uri = Path(page.file.src_uri) + + page.file.src_path = str( + src_path.parent / f"{src_path.stem}.{i18n_plugin.current_language}{src_path.suffix}" + ) + page.file.src_uri = ( + src_uri.parent / f"{src_uri.stem}.{i18n_plugin.current_language}{src_uri.suffix}" + ).as_posix() + + output = func(markdown, page, config, files) + + # restore the page object paths to initial state + page.file.src_path = str(src_path) + page.file.src_uri = src_uri.as_posix() + + return output + + return on_page_markdown_wrapper + + for i, event in enumerate(config.plugins.events["page_markdown"]): + if not hasattr(event, "__self__"): + continue + if event.__self__.__class__ is social_plugin.__class__: + config.plugins.events["page_markdown"][i] = on_page_markdown_decorator(event) + break + + +def patch_search_entry_title(func): + """ + Navigation / social card titles should be controlled separately in the page front matter. + Search result titles should be like the first h1 heading in the markdown content. + The search plugin implementation in the Material theme doesn't work like that, so + we patch it. + """ + + def wrap_create_entry_for_section(section, toc, url, page): + old_meta_title = page.meta.get("title") + old_page_title = page.title + page_markdown_title = get_markdown_title(page.markdown) + + page.meta["title"] = page_markdown_title + page.title = page_markdown_title + + result = func(section, toc, url, page) + + page.meta["title"] = old_meta_title + page.title = old_page_title + + return result + + return wrap_create_entry_for_section + + +CUSTOM_DIR_PATH = "overrides" +"""A relative path to the custom directory based from the `docs_dir` parent directory.""" + +HOOK_NAME: str = "all_plugin_patch" +"""Name of this hook. Used in logging.""" + +LEXER_CLASS_CACHE = {} +"""Lexer class cache dictionary for patch_lexers_cache""" + +LOG: PrefixedLogger = PrefixedLogger(HOOK_NAME, logging.getLogger(f"mkdocs.hooks.{HOOK_NAME}")) +"""Logger instance for this hook.""" diff --git a/overrides/.hooks/git_redirects.py b/overrides/.hooks/git_redirects.py index 1977c1052d..97550784f8 100644 --- a/overrides/.hooks/git_redirects.py +++ b/overrides/.hooks/git_redirects.py @@ -4,7 +4,7 @@ by the `MAX_DATE` and `MAX_HASH` constants. It checks the diff between 2 adjacent commits and processes the diff items marked with the "R" (moved/renamed) status. -MIT Licence 2023 Kamil Krzyśków +MIT Licence 2023 Kamil Krzyśków (HRY) """ import datetime import json @@ -21,6 +21,7 @@ GIT_MODULE = True from mkdocs.config import Config from mkdocs.config.defaults import MkDocsConfig +from mkdocs.plugins import PrefixedLogger # region Core Logic @@ -31,33 +32,33 @@ def on_config(config: MkDocsConfig) -> Optional[Config]: try: hook_enabled = custom_getenv(HOOK_VAR, False) except ValueError as err: - LOG.error(f"{HOOK_NAME}: {err}") + LOG.error(err) return None if not hook_enabled: - LOG.info(f"{HOOK_NAME}: {HOOK_VAR} is not set to True in the environment") + LOG.info(f"{HOOK_VAR} is not set to True in the environment") return None if not GIT_MODULE: - LOG.warning(f"{HOOK_NAME}: The `GitPython` module is not installed") + LOG.warning("The `GitPython` module is not installed") return None if "redirects" not in config["plugins"]: - LOG.warning(f"{HOOK_NAME}: The `redirects` plugin is not in the config") + LOG.warning("The `redirects` plugin is not in the config") return None if "redirect_maps" not in config["plugins"]["redirects"].config: - LOG.warning(f"{HOOK_NAME}: The `redirects` plugin is not configured correctly") + LOG.warning("The `redirects` plugin is not configured correctly") return None if config.extra.get("git_redirects_finished", False): - LOG.info(f"{HOOK_NAME}: MkDocsConfig wasn't reset since last run, skipping run...") + LOG.info("MkDocsConfig wasn't reset since last run, skipping run...") return None try: cache_enabled = custom_getenv(CACHE_VAR, False) except ValueError as err: - LOG.error(f"{HOOK_NAME}: {err}") + LOG.error(err) return None if cache_enabled: @@ -102,23 +103,23 @@ def _add_redirects_based_on_git_history( project_root: Path = docs_dir.parent repo = Repo(project_root) + redirects: Dict[str, str] = config["plugins"]["redirects"].config["redirect_maps"] + if cache_enabled: + redirects.update(CacheHelper.cache_obj["redirects"]) + if MAX_HASH and len(repo.commit(MAX_HASH).parents) > 1: - LOG.warning(f"{HOOK_NAME}: Using a Merge commit revision for 'MAX_HASH' is not supported") + LOG.warning("Using a Merge commit revision for 'MAX_HASH' is not supported") return None if cache_enabled and repo.head.commit.hexsha == CacheHelper.cache_obj["commit_hash"]: - LOG.info(f"{HOOK_NAME}: HEAD commit already cached") + LOG.info("HEAD commit already cached") return None file_paths: Set[str] = {str(path) for path in docs_dir.glob("**/*.md")} - redirects: Dict[str, str] = config["plugins"]["redirects"].config["redirect_maps"] - - if cache_enabled: - redirects.update(CacheHelper.cache_obj["redirects"]) initial_len: int = len(redirects) - LOG.info(f"{HOOK_NAME}: Processing Git history with{'' if cache_enabled else 'out'} cache...") + LOG.info(f"Processing Git history with{'' if cache_enabled else 'out'} cache...") for commit in repo.iter_commits(since=MAX_DATE, max_parents=1): if not commit.parents: @@ -157,21 +158,19 @@ def _add_redirects_based_on_git_history( if old_inner not in redirects: redirects[old_inner] = new_inner else: - LOG.info( - f"{HOOK_NAME}: '{old_inner}' already in redirects, keeping more recent one" - ) + LOG.info(f"'{old_inner}' already in redirects, keeping more recent one") if commit.hexsha == MAX_HASH: break if cache_enabled and commit.parents[0].hexsha == CacheHelper.cache_obj["commit_hash"]: - LOG.info(f"{HOOK_NAME}: Reached cached commits") + LOG.info("Reached cached commits") break len_diff: int = len(redirects) - initial_len if len_diff > 0: - LOG.info(f"{HOOK_NAME}: Created {len_diff} redirects") + LOG.info(f"Created {len_diff} redirects") if cache_enabled: return repo.head.commit.hexsha @@ -225,7 +224,7 @@ def save(cls, *, config: MkDocsConfig) -> None: HOOK_VAR: str = "GMC_ENABLE_ON_PUBLISH" """Name of the environmental variable to enable the hook.""" -LOG: logging.Logger = logging.getLogger(f"mkdocs.hooks.{HOOK_NAME}") +LOG: PrefixedLogger = PrefixedLogger(HOOK_NAME, logging.getLogger(f"mkdocs.hooks.{HOOK_NAME}")) """Logger instance for this hook.""" # MAX_DATE: datetime.datetime = datetime.datetime.now() - datetime.timedelta(days=99) diff --git a/overrides/.hooks/language_flags.py b/overrides/.hooks/language_flags.py index a38888283e..266674f0f7 100644 --- a/overrides/.hooks/language_flags.py +++ b/overrides/.hooks/language_flags.py @@ -5,7 +5,7 @@ It uses the theme_overrides_manager hook to assure original file preservation. Works both with and without the "i18n" MkDocs plugin. -MIT Licence 2023 Kamil Krzyśków +MIT Licence 2023 Kamil Krzyśków (HRY) Parts adapted from the translations.py hook https://github.com/squidfunk/mkdocs-material/blob/master/src/.overrides/hooks/translations.py and from the materialx.emoji and pymdownx.emoji modules. @@ -16,6 +16,7 @@ from jinja2 import Environment from mkdocs.config.defaults import MkDocsConfig +from mkdocs.plugins import PrefixedLogger from pymdownx import twemoji_db, util from pymdownx.emoji import TWEMOJI_SVG_CDN @@ -25,19 +26,19 @@ def on_env(*_, config: MkDocsConfig, **__) -> Optional[Environment]: """Main function. Triggers just before the build begins.""" - LOG.debug(f'{HOOK_NAME}: Running "on_env"') + LOG.debug('Running "on_env"') if not _is_runnable(config=config): return None import material - partials: Path = Path(material.__file__).parent / "partials" - header: Path = partials / "header.html" + partials: Path = Path(material.__file__).parent / "templates" / "partials" + header: Path = partials / "alternate.html" config.extra[HOOK_MANAGER].paths_with_processors.append((header, _add_flags)) - LOG.info(f"{HOOK_NAME}: Registered processors") + LOG.info(f"Registered processors") return None @@ -46,19 +47,19 @@ def _is_runnable(*, config: MkDocsConfig) -> bool: """Make sure the hook should run.""" if HOOK_MANAGER not in config["extra"]: - LOG.info(f'{HOOK_NAME}: "{HOOK_MANAGER}" not detected') + LOG.info(f'"{HOOK_MANAGER}" not detected') return False if config.theme["name"] != "material": - LOG.info(f'{HOOK_NAME}: Only the "material" theme is supported') + LOG.info('Only the "material" theme is supported') return False if "alternate" not in config["extra"]: - LOG.info(f'{HOOK_NAME}: "extra.alternate" not detected') + LOG.info('"extra.alternate" not detected') return False if len(config["extra"]["alternate"]) < 2: - LOG.info(f"{HOOK_NAME}: Not enough languages") + LOG.info(f"Not enough languages") return False return True @@ -69,11 +70,11 @@ def _add_flags(*, partial: Path, config: MkDocsConfig, **__) -> None: # Configure the tokens tokens: Dict[str, str] = { - "START": "{% if config.extra.alternate %}", + "START": '