From 11a767d1193e98fd7507a4f38c253eed040dd034 Mon Sep 17 00:00:00 2001 From: Seemann Date: Sun, 19 Jun 2022 22:18:58 -0400 Subject: [PATCH] update to 1.0.0-dev --- .gitignore | 1 + SDK/cleo_redux.lib | Bin 5788 -> 6398 bytes SDK/cleo_redux64.lib | Bin 5842 -> 6444 bytes SDK/cleo_redux_sdk.h | 16 +++- SDK/cleo_redux_sdk.rs | 44 ++++++++++ docs/en/SUMMARY.md | 8 +- docs/en/first-run-notes.md | 4 +- docs/en/imports.md | 2 +- docs/en/installation-classic-games.md | 10 --- docs/en/installation-definitive-edition.md | 8 -- docs/en/installation-plugins.md | 7 +- docs/en/installation-re3-revc.md | 9 -- docs/en/installation.md | 30 +++++-- docs/en/introduction.md | 7 +- docs/en/prerequisites.md | 7 +- docs/en/relation-to-cleo-library.md | 2 +- docs/en/using-fxt.md | 5 +- installer/cleo_redux.iss | 42 +++++++-- plugins/Input/.cargo/config | 17 ++++ plugins/Input/Cargo.lock | 85 ++++++++++++++++++ plugins/Input/Cargo.toml | 16 ++++ plugins/Input/build/.gitkeep | 0 plugins/Input/src/impl.rs | 96 +++++++++++++++++++++ plugins/Input/src/lib.rs | 26 ++++++ 24 files changed, 376 insertions(+), 66 deletions(-) delete mode 100644 docs/en/installation-classic-games.md delete mode 100644 docs/en/installation-definitive-edition.md delete mode 100644 docs/en/installation-re3-revc.md create mode 100644 plugins/Input/.cargo/config create mode 100644 plugins/Input/Cargo.lock create mode 100644 plugins/Input/Cargo.toml create mode 100644 plugins/Input/build/.gitkeep create mode 100644 plugins/Input/src/impl.rs create mode 100644 plugins/Input/src/lib.rs diff --git a/.gitignore b/.gitignore index 3c180d8..7f553ca 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ target *.asi *.pdb Release +Debug x64 *.exe \ No newline at end of file diff --git a/SDK/cleo_redux.lib b/SDK/cleo_redux.lib index 11b17144af3190f644ff21a11442f7d7aaa2dc32..58b16960aea95e9fee0ca57bc44ab7aa84d6c5a6 100644 GIT binary patch delta 950 zcmajeQAkr^6bJDC)>hp)x4YeYw>ejdSUrTnf>{j{%!ddRVJ3t~EA=|>!>%^3kPt{O zLk5z0s2=huio^$z_7dcS1>uW|_#WX)P>7+uNkr${u9fSd3qKC$`_A_r?z!CA#-H)& z%Mm4f)U#!M`626 z=^X%+Ubb4MCV>(@q%tjP%X1X=%0hiW$p%LjZnn*FWD#yyQs7vio}-s&+7m0@bX;>x zbegS$mY(bC&lw}uDAH*oJCaUUu6CMN^}*qs{!dxOa;KRZGc6;lUpEcw&t-=eQ+mc2 z<(6&3+3X$KaJ!0&&bN+CE$9VPy30STI_Ps#L2Q0A$KQP1g*^mruvX%fa&muu! zl5MkI1z2TCmG@Xw1M+N-^@V^9)*J@rn3zj}ITG~A)hN{D`il3DO?hZMsMK0J7uQemXsU1=6<>&+ zR=3i!qQ;c9w)b^h<1N=5YBS@z;cwY)|8|o1tIPW|rlh4W1BpFx#z&`v87W{s|0=rp z=`m-;?)o+HIb?Dx{nG0v_jW}Vpu3!PM2p|+I1AE8B_p-Jc=kiwtWbxl`#h1yzhuf(GlN1lVXN%jj5cs#dB|gc#axv&Jf@! zF)6__d5TP>*_NCIJas0y!%8iseb!{vOxJRHRol)^JYTJs>#UnVg_mrFfJqxDQ#1^0 zQH$myz!8n`lKW)DfHgX&TpVc7kOP!R9jZu8noRvFev3fR_m4D zf%h_{56FgY%O~Bgop$84+NxOz%16hsF1{?DWVmKXb`u4wTJ8UrX6urBw%03ne^YF> z6p~B!-Mf>fYGIhjOFEIa&KkE@8IDBcm0Pgt`iJX&wy1n_m#xF;AAi*BnDliog)jF~ z7ple8yK_>Cy^%g{{(r`3sqGxO?Jji9JRbiXWJ_?8>==%0_RNKfH~C-uFG#|auZAnv GJ&`A94RmDy diff --git a/SDK/cleo_redux64.lib b/SDK/cleo_redux64.lib index 44e7b0f1cfd4db62201664e0f0388b1765131b5d..d53fd030ad10caa372cb6367c9f62e3a64c7e32c 100644 GIT binary patch delta 929 zcmajbPe>GT6bJC{EUPl@y0bffb~klvBZ|PZHZqnDL23stttff0gZ4XP98+? zlyvD2{JaFAMB%AREEpL`2Maqzo(ptA>5r$N6(XwdtfRPlY2d?~_nY_L%)Hf>=VuAp1;l)6I!F{f$`f5(5UC%KLQ{HUBJwn81EMb#Q#eAl**uq0S6 zshBOUs-5DLqJ^Zz6I+K_Q(vwTkF^`}yKkA2+ZGaCswF=ez4tT8OcAfuA^B6{&gTTP zuxQpy*}9S~x>-a#V%CwF_~rJgqE5H!jpOgP-N70M_lk_tEfh_YNAu6VxE;Fqs+;PE zna*W5Gu#@}>9QU1(TIthdP$x!9{f)7QB=G&hUEOl+Qw04G0_&i6_o6=e~vMWvrVkk J>EcaP{Rd(9>LmaG delta 549 zcmYMwKS&!<90&04HHppT@8xoLO{B$$c#}nuf(dkJamf&uOb#iuf(=s0WFd`1C`EL# zg&#Ntp%`#+(Le@qt6XRn0--}7+y|n?p<^b+?4fO@~?nh#qI0*4&#hk;@gI3_y= zY|}ke;y{P;8qg*?!EZF6iVk$CkOYos$^aS^GJz`fsARc64}JtNf`_smn2=gvMoG&- zpw?O(*-*sxX_E29TF--bA=xmJDqg((G0wY%W!G3yuU>usmSKyCX_nQOAL_rKutjCv zT#n>A)3;8G@qEb|OX|*yec_D8<&CwXHsA049b?nv%qpv&e&zo-n-ensXjyGOurHma r%K_WT()o3UEh%HEvbuI+bSBsg`J8$e-uilaGs$McFCYD;jHdN}hmvl+ diff --git a/SDK/cleo_redux_sdk.h b/SDK/cleo_redux_sdk.h index 9b22321..539f96c 100644 --- a/SDK/cleo_redux_sdk.h +++ b/SDK/cleo_redux_sdk.h @@ -29,9 +29,12 @@ enum class HostId }; typedef void* Context; +typedef intptr_t isize; + typedef HandlerResult (*CommandHandler)(Context); typedef void* (*CustomLoader)(const char*); -typedef intptr_t isize; +typedef void (*OnTickCallback)(unsigned int current_time, int time_step); +typedef void (*OnRuntimeInitCallback)(); extern "C" { // since v1 @@ -97,5 +100,14 @@ extern "C" { // since v3 // Frees up the memory chunk allocated with AllocMem void FreeMem(void *ptr); - + // since v4 + // Registers a new callback invoked on each main loop iteration (before scripts are executed) + void OnBeforeScripts(OnTickCallback callback); + // since v4 + // Registers a new callback invoked on each main loop iteration (after scripts are executed) + void OnAfterScripts(OnTickCallback callback); + // since v4 + // Registers a new callback invoked on each runtime init event (new game, saved game load, or SDK's RuntimeInit) + void OnRuntimeInit(OnRuntimeInitCallback callback); } + diff --git a/SDK/cleo_redux_sdk.rs b/SDK/cleo_redux_sdk.rs index 08394a9..da6a6d4 100644 --- a/SDK/cleo_redux_sdk.rs +++ b/SDK/cleo_redux_sdk.rs @@ -35,6 +35,8 @@ pub type c_void = std::ffi::c_void; pub type Context = *const c_void; pub type CustomCommand = extern "C" fn(Context) -> HandlerResult; pub type CustomLoader = extern "C" fn(*const c_char) -> *mut c_void; +pub type OnTickCallback = extern "C" fn(current_time: u32, time_step: i32); +pub type OnRuntimeInitCallback = extern "C" fn(); #[cfg_attr(target_arch = "x86", link(name = "cleo_redux"))] #[cfg_attr(target_arch = "x86_64", link(name = "cleo_redux64"))] @@ -128,6 +130,18 @@ extern "C" { /// /// since v3 fn FreeMem(ptr: *mut c_void); + /// Registers a new callback invoked on each main loop iteration (before scripts are executed) + /// + /// since v4 + fn OnBeforeScripts(cb: OnTickCallback); + /// Registers a new callback invoked on each main loop iteration (after scripts are executed) + /// + /// since v4 + fn OnAfterScripts(cb: OnTickCallback); + /// Registers a new callback invoked on each runtime init event (new game, saved game load, or SDK's RuntimeInit) + /// + /// since v4 + fn OnRuntimeInit(cb: OnRuntimeInitCallback); } macro_rules! sz { @@ -317,3 +331,33 @@ pub fn alloc_mem(size: usize) -> *mut c_void { pub fn free_mem(ptr: *mut c_void) { unsafe { FreeMem(ptr) } } + +/// Registers a new callback invoked on each main loop iteration (before scripts are executed) +/// +/// since v4 +#[allow(dead_code)] +pub fn on_before_scripts(cb: OnTickCallback) { + unsafe { + OnBeforeScripts(cb); + } +} + +/// Registers a new callback invoked on each main loop iteration (after scripts are executed) +/// +/// since v4 +#[allow(dead_code)] +pub fn on_after_scripts(cb: OnTickCallback) { + unsafe { + OnAfterScripts(cb); + } +} + +/// Registers a new callback invoked on each runtime init event (new game, saved game load, or SDK's RuntimeInit) +/// +/// since v4 +#[allow(dead_code)] +pub fn on_runtime_init(cb: OnRuntimeInitCallback) { + unsafe { + OnRuntimeInit(cb); + } +} diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md index 1a91976..0a9f44b 100644 --- a/docs/en/SUMMARY.md +++ b/docs/en/SUMMARY.md @@ -6,12 +6,8 @@ - [Installation](./installation.md) - - [Classic GTA III, GTA VC, GTA SA](./installation-classic-games.md) - - [re3 or reVC](./installation-re3-revc.md) - - [The Definitive Edition](./installation-definitive-edition.md) - - [CLEO Directory](./cleo-directory.md) - - [Plugins](./installation-plugins.md) - - [Scripts](./installation-scripts.md) + - [Plugins](./installation-plugins.md) + - [Scripts](./installation-scripts.md) - [Configuration](./config.md) diff --git a/docs/en/first-run-notes.md b/docs/en/first-run-notes.md index 0472f30..c8bb254 100644 --- a/docs/en/first-run-notes.md +++ b/docs/en/first-run-notes.md @@ -1,5 +1,5 @@ -There could be a noticeable lag during the first game run as CLEO Redux downloads the files necessary for [JavaScript support](./prerequisites.md). It won't happen on subsequent runs. +During the first game run CLEO Redux downloads extra files necessary for [JavaScript support](./prerequisites.md). It doesn't happen on subsequent runs. -A new folder named `CLEO` should appear in the game directory. This is the primary location for all CLEO scripts, plugins and configs. +After that a new folder named `CLEO` should appear in the game directory. This is the primary location for all CLEO scripts, plugins and configs. {{#include ./cleo-directory-note.md}} diff --git a/docs/en/imports.md b/docs/en/imports.md index 45f987d..a0cf9e6 100644 --- a/docs/en/imports.md +++ b/docs/en/imports.md @@ -63,7 +63,7 @@ log(lines.join("")); // prints the entire file - Extensions: `.ide` - Plugin name: `IdeLoader.cleo` -The IDE loader transforms an item definition file (`*.ide`) that is widely used in GTA 3D series games. The file is imported as an object where each key corresponds to a section in the file and the value is an array of array of strings: +The IDE loader transforms an item definition file (`*.ide`) that is widely used in GTA series games. The file is imported as an object where each key corresponds to a section in the file and the value is an array of array of strings: ```ts interface Ide { diff --git a/docs/en/installation-classic-games.md b/docs/en/installation-classic-games.md deleted file mode 100644 index 529d367..0000000 --- a/docs/en/installation-classic-games.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Classic GTA III, GTA VC, GTA SA - -- Copy `cleo_redux.asi` to the game directory (with the main executable file). - -- Run the game once to complete the installation. - -{{#include ./first-run-notes.md}} - -CLEO Redux does not alter any game files. It exploits the fact that the game natively loads `.asi` files as addons to the Miles Sound System library. No extra software is required. diff --git a/docs/en/installation-definitive-edition.md b/docs/en/installation-definitive-edition.md deleted file mode 100644 index 3a96101..0000000 --- a/docs/en/installation-definitive-edition.md +++ /dev/null @@ -1,8 +0,0 @@ -# The Definitive Edition - -- Download and install [Ultimate ASI Loader x64](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/x64-latest/version.zip) by ThirteenAG (place `version.dll` to the `Gameface\Binaries\Win64` directory) -- Copy `cleo_redux64.asi` to the same directory. - -- Run the game once to complete the installation. - -{{#include ./first-run-notes.md}} diff --git a/docs/en/installation-plugins.md b/docs/en/installation-plugins.md index dfa67c5..73e0725 100644 --- a/docs/en/installation-plugins.md +++ b/docs/en/installation-plugins.md @@ -8,6 +8,7 @@ Plugins should be copied to the `CLEO\CLEO_PLUGINS` directory. | Name | Description | Link | | ---------- | ----------------------------------------- | ---- | -| IniFiles | Reading from and writing to INI files | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/IniFiles) - [download](https://github.com/cleolibrary/CLEO-Redux/releases/download/0.9.2/CLEO_Redux-0.9.2+IniFiles+Dylib.zip) | -| Dylib | Loading DLL files and importing functions | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/Dylib) - [download](https://github.com/cleolibrary/CLEO-Redux/releases/download/0.9.2/CLEO_Redux-0.9.2+IniFiles+Dylib.zip) | -| ImGuiRedux | Dear ImGui bindings | [https://github.com/user-grinch/ImGuiRedux](https://github.com/user-grinch/ImGuiRedux) | +| [IniFiles](https://library.sannybuilder.com/#/unknown_x86/ini) | Reading from and writing to INI files | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/IniFiles) - [download](https://github.com/cleolibrary/CLEO-Redux/releases/download/0.9.2/CLEO_Redux-0.9.2+IniFiles+Dylib.zip) | +| [Dylib](https://library.sannybuilder.com/#/unknown_x86/dylib) | Loading DLL files and importing functions | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/Dylib) - [download](https://github.com/cleolibrary/CLEO-Redux/releases/download/0.9.2/CLEO_Redux-0.9.2+IniFiles+Dylib.zip) | +| [ImGuiRedux](https://library.sannybuilder.com/#/unknown_x86/imgui) | Dear ImGui bindings | [GitHub repo](https://github.com/user-grinch/ImGuiRedux) | +| [MemoryOperations](https://library.sannybuilder.com/#/unknown_x86/memops) | Low-level memory operations | [GitHub repo](https://github.com/cleolibrary/CLEO-REDUX-PLUGINS) | diff --git a/docs/en/installation-re3-revc.md b/docs/en/installation-re3-revc.md deleted file mode 100644 index 6d70f3d..0000000 --- a/docs/en/installation-re3-revc.md +++ /dev/null @@ -1,9 +0,0 @@ -# re3 or reVC - -- Copy `cleo_redux.asi` to the game directory (with the main executable file). - -- Run the game once to complete the installation. - -{{#include ./first-run-notes.md}} - -{{#include ./re3-reVC-notes.md}} \ No newline at end of file diff --git a/docs/en/installation.md b/docs/en/installation.md index 075dad3..43a64a9 100644 --- a/docs/en/installation.md +++ b/docs/en/installation.md @@ -1,23 +1,39 @@ # Installation -Depending on the game CLEO Redux installation may require a few extra steps. Check the relevant guides below: +CLEO Redux comes with a hassle-free installer that identifies the selected game and downloads all the dependencies. Just run `cleo_redux_setup.exe` and follow its steps. -- [Installation for Classic GTA III, GTA VC, GTA SA](./installation-classic-games.md) -- [Installation for re3 or reVC](./installation-re3-revc.md) -- [Installation for The Trilogy: The Definitive Edition](./installation-definitive-edition.md) - -> Note that CLEO Redux recognizes the target game purely by the executable name it is running from. +> CLEO Redux and its installer recognize the target game purely by the executable name in the selected/working directory. > > * GTA III - `gta3.exe` > * GTA VC - `gta-vc.exe` > * GTA SA - `gta_sa.exe`, `gta-sa.exe`, or `gta_sa_compact.exe` +> * GTA IV - `GTAIV.exe` > * re3 - `re3.exe` > * reVC - `reVC.exe` > * GTA III: DE - `libertycity.exe` > * GTA VC: DE - `vicecity.exe` > * GTA SA: DE - `sanandreas.exe` > -> Names matching is case-insensitive. For classic games CLEO Redux always assumes version 1.0. +> Names matching is case-insensitive. If the exe file does not contain a version information CLEO Redux always assumes version 1.0. + + +Once the installation is complete, run the game once. During the first run CLEO Redux downloads and generates extra files necessary for [JavaScript support](./prerequisites.md). + +## CLEO Directory + +CLEO directory is the primary location where you install [CLEO scripts](./installation-scripts.md), [CLEO plugins](./installation-plugins.md) and [custom texts](./using-fxt.md). CLEO Redux automatically creates this folder when the game starts. + +In most cases this directory can be found in the game folder. If, however, CLEO lacks write permissions there and fails to create new files, it uses an alternate path at `C:\Users\\AppData\Roaming\CLEO Redux`. `cleo_redux.log` and the `CLEO` directory can be found there. + +## Dependency on ASI Loader + +CLEO Redux is distributed as a dynamic-load library with an `.asi` extension. Historically ASI files have been used in GTA 3 and Vice City as addons to the Miles Sound System library (Mss32) which loads them into the game process. More recent titles didn't use MSS, so the modding community developed custom loaders commonly named "ASI Loader" to continue using ASI for any custom code to be injected into the game. + +[Ultimate ASI Loader](https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases) by ThirteenAG can be used to load CLEO Redux in all games except GTA3/VC/re3/reVC. It gets downloaded during CLEO Redux setup. You may opt out of installing Ultimate ASI Loader if you have other means of injecting ASI files into the game (i.e. an alternative loader). + +## Note on re3 or reVC + +{{#include ./re3-reVC-notes.md}} ## Uninstallation diff --git a/docs/en/introduction.md b/docs/en/introduction.md index 30154b0..3b31bb7 100644 --- a/docs/en/introduction.md +++ b/docs/en/introduction.md @@ -1,8 +1,6 @@ # Introduction - -CLEO Redux is a scripting runtime for the GTA 3D era games. It is a proud member of the CLEO family and provides familiar experience to anyone who used original CLEO Library for the classic GTA San Andreas or its re-implementations for other games. The main goal of CLEO is to provide a way to easily customize the game with countless user-made scripts. -If you're new to CLEO visit the [official website](https://cleo.li/) to find more information about it. +CLEO Redux is an [embeddable](https://re.cleo.li/docs/en/embedding.html) and [extensible](https://re.cleo.li/docs/en/using-sdk.html) JavaScript runtime capable of running user-made scripts in games and desktop applications. It is inspired by [CLEO Library](https://cleo.li/) and is [partially compatible](https://re.cleo.li/docs/en/relation-to-cleo-library.html) with its scripts and plugins. CLEO Redux, however, aims to provide a better developer and user experience and support games beyond just GTA 3D series. ## Supported Releases @@ -11,6 +9,7 @@ Classic: - GTA III 1.0 - GTA Vice City 1.0 - GTA San Andreas 1.0 (only with [CLEO 4.4](https://github.com/cleolibrary/CLEO4)) +- GTA IV 1.2.0.43 (The Complete Edition, Steam) Remasters (The Trilogy): @@ -22,8 +21,6 @@ Other: - reVC (see [details](./troubleshooting.md#cleo-does-not-work-with-re3-or-revc)) - unknown host (see [details](./embedding.md)) -CLEO Redux only supports the PC version of each game. - For the complete reference on supported features [refer to this page](https://github.com/cleolibrary/CLEO-Redux/wiki/Feature-Support-Matrix). Also there are known limitations [listed here](unsupported.md). ## License diff --git a/docs/en/prerequisites.md b/docs/en/prerequisites.md index 136941e..2c8cca1 100644 --- a/docs/en/prerequisites.md +++ b/docs/en/prerequisites.md @@ -8,9 +8,10 @@ On the first run CLEO tries to download a definition file (see the table below) | ----------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------ | | GTA III, re3 | [gta3.json](https://github.com/sannybuilder/library/blob/master/gta3/gta3.json) | `0.218` | | GTA VC, reVC | [vc.json](https://github.com/sannybuilder/library/blob/master/vc/vc.json) | `0.220` | -| GTA San Andreas (Classic) 1.0 | [sa.json](https://github.com/sannybuilder/library/blob/master/sa/sa.json) | `0.236` | +| GTA San Andreas (Classic) 1.0 | [sa.json](https://github.com/sannybuilder/library/blob/master/sa/sa.json) | `0.245` | +| GTA IV | [gta_iv.json](https://github.com/sannybuilder/library/blob/master/gta_iv/gta_iv.json) | `0.34` | | GTA III: The Definitive Edition | [gta3_unreal.json](https://github.com/sannybuilder/library/blob/master/gta3_unreal/gta3_unreal.json) | `0.213` | | Vice City: The Definitive Edition | [vc_unreal.json](https://github.com/sannybuilder/library/blob/master/vc_unreal/vc_unreal.json) | `0.215` | | San Andreas: The Definitive Edition | [sa_unreal.json](https://github.com/sannybuilder/library/blob/master/sa_unreal/sa_unreal.json) | `0.220` | -| Unknown (32-bit) | [unknown_x86.json](https://github.com/sannybuilder/library/blob/master/unknown_x86/unknown_x86.json) | `0.1` | -| Unknown (64-bit) | [unknown_x64.json](https://github.com/sannybuilder/library/blob/master/unknown_x64/unknown_x64.json) | `0.1` | +| Unknown (32-bit) | [unknown_x86.json](https://github.com/sannybuilder/library/blob/master/unknown_x86/unknown_x86.json) | `0.203` | +| Unknown (64-bit) | [unknown_x64.json](https://github.com/sannybuilder/library/blob/master/unknown_x64/unknown_x64.json) | `0.207` | diff --git a/docs/en/relation-to-cleo-library.md b/docs/en/relation-to-cleo-library.md index edbfca6..4e7016c 100644 --- a/docs/en/relation-to-cleo-library.md +++ b/docs/en/relation-to-cleo-library.md @@ -1,6 +1,6 @@ # Relation to CLEO Library -CLEO is a common name for the custom libraries designed and created for GTA III, Vice City or San Andreas. Each version can be found and downloaded [here](https://cleo.li/download.html). CLEO Redux is _another_ CLEO implementation made from scratch with a few distinctive features, such as single code base for all games and JavaScript support. +CLEO is a common name for the custom libraries designed and created for GTA III, Vice City or San Andreas. Each version can be found and downloaded [here](https://cleo.li/download.html). CLEO Redux is _another_ CLEO implementation made from scratch with a few distinctive features, such as shared code base between all games and JavaScript support. At the moment CLEO Redux can not be considered as a complete replacement for CLEO Library due to the lack of support for many widely used CLEO commands. To solve this issue and get the best out of the two libraries, CLEO Redux supports two different usage strategies. diff --git a/docs/en/using-fxt.md b/docs/en/using-fxt.md index 2271d9b..7782a24 100644 --- a/docs/en/using-fxt.md +++ b/docs/en/using-fxt.md @@ -31,6 +31,9 @@ Text.PrintHelp('KEY1') // displays You can find the commands available in each game in the Sanny Builder Library, e.g. [for San Andreas: DE](https://library.sannybuilder.com/#/sa_unreal/classes/Text). + +> CLEO Redux only supports texts encoded in UTF-8. It means that any non-standard encoding (e.g. for Russian localization by 1C) most likely will not work. + ## FxtStore @@ -53,7 +56,7 @@ declare interface FxtStore { } ``` -Using `FxtStore` you can create unique keys and values in the script and put it in local FXT storage. Each script owns a private storage and keys from one script will not conflict with other scripts. Also keys defined in the FxtStore will shadow the same keys defined in static FXT files. Consider the example: +Using `FxtStore` you can create unique keys and values in the script and put it in local FXT storage. Each script owns a private storage and keys from one script will not conflict with other scripts. Also keys defined in the FxtStore shadow the same keys defined in static FXT files. Consider the example: custom.fxt: diff --git a/installer/cleo_redux.iss b/installer/cleo_redux.iss index b43ac2d..4e49d7c 100644 --- a/installer/cleo_redux.iss +++ b/installer/cleo_redux.iss @@ -1,5 +1,5 @@ #define AppName "CLEO Redux" -#define AppVersion "0.9.4" +#define AppVersion "1.0.0-dev.20220619" #define AppPublisher "Seemann" #define AppURL "https://re.cleo.li" #define SourceDir "..\" @@ -14,6 +14,9 @@ #define SilentPatchVC = "https://silent.rockstarvision.com/uploads/SilentPatchVC.zip" #define SilentPatchSA = "https://silent.rockstarvision.com/uploads/SilentPatchSA.zip" +#define MemOps32 = "https://github.com/cleolibrary/CLEO-REDUX-PLUGINS/releases/download/latest/MemoryOperations.zip" +#define MemOps64 = "https://github.com/cleolibrary/CLEO-REDUX-PLUGINS/releases/download/latest/MemoryOperations64.zip" + [Setup] AppId={{511AFCDA-FD5E-491C-A1B7-22BAC8F93711} AppName={#AppName} @@ -48,15 +51,17 @@ Name: "full"; Description: "Full"; Flags: iscustom [Components] Name: "program"; Description: "CLEO Redux"; Types: full; Flags: fixed -Name: "plugins"; Description: "New Commands"; Types: full +Name: "plugins"; Description: "Extensions"; Types: full Name: "plugins/ini"; Description: "IniFiles 1.2"; Types: full Name: "plugins/dylib"; Description: "Dylib 1.1"; Types: full Name: "plugins/imgui"; Description: "ImGuiRedux (by Grinch_)"; Types: full Name: "plugins/imgui/d3d8to9"; Description: "d3d8to9 Wrapper - for games using DirectX 8"; Types: full Name: "plugins/imgui/SilentPatch"; Description: "SilentPatch - needed for the mouse to work properly in classic GTA"; Types: full +Name: "plugins/memops"; Description: "MemoryOperations (by ThirteenAG)"; Types: full +Name: "plugins/input"; Description: "Input 1.0"; Types: full Name: "loaders"; Description: "File Loaders"; Types: full Name: "loaders/text"; Description: "*.txt files"; Types: full -Name: "loaders/ide"; Description: "*.ide files (for 32-bit GTA3, VC, SA)"; Types: full +Name: "loaders/ide"; Description: "*.ide files (for 32-bit GTA3, VC, SA, IV)"; Types: full Name: "asiloader"; Description: "Ultimate ASI Loader (by ThirteenAG)"; Types: full @@ -79,6 +84,8 @@ Source: "{#SourceDir}\plugins\Dylib\build\dylib.cleo"; DestDir: "{app}\CLEO\CLEO Source: "{#SourceDir}\plugins\Dylib\build\dylib64.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX64; Components: plugins/dylib Source: "{#SourceDir}\plugins\IniFiles\build\IniFiles.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX86; Components: plugins/ini Source: "{#SourceDir}\plugins\IniFiles\build\IniFiles64.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX64; Components: plugins/ini +Source: "{#SourceDir}\plugins\Input\build\Input.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX86; Components: plugins/input +Source: "{#SourceDir}\plugins\Input\build\Input64.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX64; Components: plugins/input Source: "{tmp}\ImGuiRedux.zip"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: deleteafterinstall external; Check: IsX86; AfterInstall: InstallImGuiRedux32; Components: plugins/imgui; Source: "{tmp}\ImGuiRedux.zip"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: deleteafterinstall external; Check: IsX64; AfterInstall: Extract('{app}\CLEO\CLEO_PLUGINS\ImGuiRedux.zip', 'ImGuiReduxWin64.cleo', '{app}\CLEO\CLEO_PLUGINS'); Components: plugins/imgui; @@ -86,6 +93,10 @@ Source: "{tmp}\ImGuiRedux.zip"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: delet Source: "{tmp}\d3d8.zip"; DestDir: "{app}"; Flags: deleteafterinstall external; AfterInstall: Extract('{app}\d3d8.zip', 'd3d8.dll', '{app}'); Components: plugins/imgui/d3d8to9; Source: "{tmp}\SilentPatch.zip"; DestDir: "{app}"; Flags: deleteafterinstall external; AfterInstall: ExtractAll('{app}\SilentPatch.zip', '{app}'); Components: plugins/imgui/SilentPatch; +Source: "{tmp}\MemoryOperations.zip"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: deleteafterinstall external; Check: IsX86; AfterInstall: Extract('{app}\CLEO\CLEO_PLUGINS\MemoryOperations.zip', 'MemoryOperations.cleo', '{app}\CLEO\CLEO_PLUGINS'); Components: plugins/memops; +Source: "{tmp}\MemoryOperations.zip"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: deleteafterinstall external; Check: IsX64; AfterInstall: Extract('{app}\CLEO\CLEO_PLUGINS\MemoryOperations.zip', 'MemoryOperations64.cleo', '{app}\CLEO\CLEO_PLUGINS'); Components: plugins/memops; + + ; Custom File Loaders Source: "{#SourceDir}\loaders\TextLoader\build\TextLoader.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX86; Components: loaders/text Source: "{#SourceDir}\loaders\TextLoader\build\TextLoader64.cleo"; DestDir: "{app}\CLEO\CLEO_PLUGINS"; Flags: ignoreversion; Check: IsX64; Components: loaders/text @@ -273,6 +284,13 @@ begin FNeedsAL := True; Exit; end; + if FileExists(Dir + '\GTAIV.exe') then + begin + Result := 9; + FIsX64 := False; + FNeedsAL := True; + Exit; + end; FNeedsAL := True; // unknown Result := 0; // unknown end; @@ -313,7 +331,7 @@ begin if CurPageID = wpSelectComponents then begin // reset all checkboxes to their initial state first - for I := 1 to 9 do + for I := 1 to 12 do begin WizardForm.ComponentsList.ItemEnabled[I] := True; WizardForm.ComponentsList.Checked[I] := True; @@ -329,8 +347,8 @@ begin WizardForm.ComponentsList.ItemEnabled[6] := False; // ide loader - WizardForm.ComponentsList.Checked[9] := False; - WizardForm.ComponentsList.ItemEnabled[9] := False; + WizardForm.ComponentsList.Checked[11] := False; + WizardForm.ComponentsList.ItemEnabled[11] := False; end // 32-bit else begin @@ -350,7 +368,7 @@ begin if (FGameId = 0) then begin // ide loader - WizardForm.ComponentsList.Checked[9] := False; + WizardForm.ComponentsList.Checked[11] := False; end; end; end; @@ -367,6 +385,7 @@ function NextButtonClick(CurPageID: Integer): Boolean; var FDlAsiLoader: Boolean; FDlImGuiPlugin: Boolean; + FDlMemOpsPlugin: Boolean; begin Result := True; @@ -382,8 +401,9 @@ begin FDlAsiLoader := (WizardIsComponentSelected('asiloader') and (FGameId in [0, 5, 6, 7, 8])); FDlImGuiPlugin := WizardIsComponentSelected('plugins/imgui'); + FDlMemOpsPlugin := WizardIsComponentSelected('plugins/memops'); - if FDlAsiLoader or FDlImGuiPlugin then + if FDlAsiLoader or FDlImGuiPlugin or FDlMemOpsPlugin then begin DownloadPage.Clear; @@ -393,6 +413,12 @@ begin if IsX86() then DownloadPage.Add('{#UAL32}/vorbisFile.zip', 'vorbisFile.zip', ''); end; + if FDlMemOpsPlugin then + begin + if IsX64() then DownloadPage.Add('{#MemOps64}', 'MemoryOperations.zip', ''); + if IsX86() then DownloadPage.Add('{#MemOps32}', 'MemoryOperations.zip', ''); + end; + if FDlImGuiPlugin then begin if IsX86() then DownloadPage.Add('{#ImGuiRedux32}/ImGuiReduxWin32.zip', 'ImGuiRedux.zip', ''); diff --git a/plugins/Input/.cargo/config b/plugins/Input/.cargo/config new file mode 100644 index 0000000..2b5e5bb --- /dev/null +++ b/plugins/Input/.cargo/config @@ -0,0 +1,17 @@ +[build] +target = "i686-pc-windows-msvc" +#target = "x86_64-pc-windows-msvc" + +[target.i686-pc-windows-msvc] +rustflags = [ + "-C", "target-feature=+crt-static", + "-C", "link-arg=/OUT:build/Input.cleo", + "-L", "../../SDK" +] + +[target.x86_64-pc-windows-msvc] +rustflags = [ + "-C", "target-feature=+crt-static", + "-C", "link-arg=/OUT:build/Input64.cleo", + "-L", "../../SDK" +] diff --git a/plugins/Input/Cargo.lock b/plugins/Input/Cargo.lock new file mode 100644 index 0000000..5882aeb --- /dev/null +++ b/plugins/Input/Cargo.lock @@ -0,0 +1,85 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cleo_redux_sdk" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a3396b36fca9df454f883719e033605ae861e5f72c4d7ef7971fe0947035a2" + +[[package]] +name = "ctor" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "input" +version = "0.0.1" +dependencies = [ + "cleo_redux_sdk", + "ctor", + "winapi", +] + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/plugins/Input/Cargo.toml b/plugins/Input/Cargo.toml new file mode 100644 index 0000000..b9481bd --- /dev/null +++ b/plugins/Input/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "input" +version = "0.0.1" +edition = "2021" +authors = ["Seemann "] + +[lib] +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ctor = "0.1.21" +[target.'cfg(windows)'.dependencies] +winapi = { version = "0.3", features = ["winuser"] } +cleo_redux_sdk = "^0.0.10" \ No newline at end of file diff --git a/plugins/Input/build/.gitkeep b/plugins/Input/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/plugins/Input/src/impl.rs b/plugins/Input/src/impl.rs new file mode 100644 index 0000000..2da4d2a --- /dev/null +++ b/plugins/Input/src/impl.rs @@ -0,0 +1,96 @@ +use cleo_redux_sdk::*; +use winapi::um::winuser::GetKeyState; + +#[derive(Copy, Clone)] +struct KeyState { + is_pressed: bool, + is_toggled: bool, +} + +static mut KEYS: [KeyState; 256] = [KeyState { + is_pressed: false, + is_toggled: false, +}; 256]; + +static mut LAST_KEY: u8 = 0; +const CHEAT_STRING_LEN: usize = 30; +static mut CHEAT_STRING: [char; CHEAT_STRING_LEN] = ['\0'; CHEAT_STRING_LEN]; + +pub extern "C" fn is_key_pressed(ctx: Context) -> HandlerResult { + let key = get_int_param(ctx) as usize; + unsafe { update_compare_flag(ctx, KEYS[key].is_pressed) }; + HandlerResult::CONTINUE +} + +pub extern "C" fn is_key_down(ctx: Context) -> HandlerResult { + let key = get_int_param(ctx) as usize; + unsafe { update_compare_flag(ctx, KEYS[key].is_pressed && KEYS[key].is_toggled) }; + HandlerResult::CONTINUE +} + +pub extern "C" fn is_key_up(ctx: Context) -> HandlerResult { + let key = get_int_param(ctx) as usize; + unsafe { update_compare_flag(ctx, !KEYS[key].is_pressed && KEYS[key].is_toggled) }; + HandlerResult::CONTINUE +} + +pub extern "C" fn get_last_key(ctx: Context) -> HandlerResult { + unsafe { set_int_param(ctx, LAST_KEY as _) }; + HandlerResult::CONTINUE +} + +pub extern "C" fn test_cheat(ctx: Context) -> HandlerResult { + let cheat = get_string_param(ctx); + for (i, c) in cheat.chars().rev().enumerate() { + if i < CHEAT_STRING_LEN && c != unsafe { CHEAT_STRING[i] } { + update_compare_flag(ctx, false); + return HandlerResult::CONTINUE; + } + } + update_compare_flag(ctx, true); + HandlerResult::CONTINUE +} + +pub extern "C" fn on_before_scripts_callback(_current_time: u32, _time_step: i32) { + // state change + // 0 -> 0 // pressed=false, keydown=false, keyup=false + // 0 -> 1 // pressed=true, keydown=true, keyup=false + // 1 -> 0 // pressed=false, keydown=false, keyup=true + // 1 -> 1 // pressed=true, keydown=false, keyup=false + + for i in 0..=255u8 { + let key_state = unsafe { GetKeyState(i as i32) }; + let is_pressed = key_state as u16 & 0x8000 != 0; + unsafe { + let key = &mut KEYS[i as usize]; + key.is_toggled = is_pressed != key.is_pressed; + if key.is_toggled { + LAST_KEY = i; + if is_pressed { + if (LAST_KEY as char).is_ascii_alphanumeric() { + CHEAT_STRING[0] = LAST_KEY as char; + } + } + } + key.is_pressed = is_pressed; + } + } +} + +pub extern "C" fn on_after_scripts_callback(_current_time: u32, _time_step: i32) { + unsafe { + if CHEAT_STRING[0] != '\0' { + for j in (1..CHEAT_STRING_LEN).rev() { + CHEAT_STRING[j] = CHEAT_STRING[j - 1]; + } + CHEAT_STRING[0] = '\0'; + } + } +} + +pub extern "C" fn on_runtime_init_callback() { + // reset cheat string + unsafe { + CHEAT_STRING = ['\0'; CHEAT_STRING_LEN]; + } +} diff --git a/plugins/Input/src/lib.rs b/plugins/Input/src/lib.rs new file mode 100644 index 0000000..2bbc290 --- /dev/null +++ b/plugins/Input/src/lib.rs @@ -0,0 +1,26 @@ +use ctor::*; +#[cfg_attr(target_arch = "x86", link(name = "cleo_redux"))] +#[cfg_attr(target_arch = "x86_64", link(name = "cleo_redux64"))] +extern crate cleo_redux_sdk; + +mod r#impl; + +#[ctor] +fn init() { + use cleo_redux_sdk::{ + log, on_after_scripts, on_before_scripts, on_runtime_init, register_command, + }; + use r#impl::*; + + log("Input plugin 1.0"); + register_command("c", is_key_pressed, None); + register_command("IS_KEY_DOWN", is_key_down, None); + register_command("IS_KEY_UP", is_key_up, None); + register_command("GET_LAST_KEY", get_last_key, None); + register_command("TEST_CHEAT", test_cheat, None); + + // update state on host events + on_before_scripts(on_before_scripts_callback); + on_after_scripts(on_after_scripts_callback); + on_runtime_init(on_runtime_init_callback); +}