1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//! A data parsing and building library for GameMaker data files (`data.win`).
//!
//! This library provides structs and functions to handle GameMaker game assets
//! in a meaningful way.
//!
//! ## Usage
//! For most purposes, using the [`parse_file`] and [`build_file`] functions is
//! enough.
//!
//! ```no_run
//! use libgm::wad::GMData;
//! use libgm::wad::elements::game_object::GMGameObject;
//! use libgm::wad::elements::GMNamedListChunk;
//!
//! # fn main() -> libgm::Result<()> {
//!
//! // Load data file
//! let mut data: GMData = libgm::wad::parse_file("./data.win")?;
//! println!("Loaded {}", data.general_info.display_name);
//!
//! // Modify data file
//! let obj: &mut GMGameObject = data.game_objects.by_name_mut("obj_time")?;
//! obj.visible = true;
//!
//! // Write data file
//! libgm::wad::build_file(&data, "./modified_data.win")?;
//!
//! # Ok(())
//! # }
//! ```
//!
//! If you need more control, you can use [`parse_bytes`], [`build_bytes`] or
//! [`ParsingOptions`].
//!
//! For more information on the GameMaker specifics, check out the [`wad`]
//! module.
//!
//! ## Disclaimer
//! This library is still in testing stages
//! ([SemVer](https://semver.org/) major 0)
//! and may have issues.
//! Please report them to the attached Codeberg repository.
//!
//! If you have any questions or concerns about my code
//! or documentation, please contact me via either:
//! - Discord DM: `@biotomate.de`
//! - [Codeberg Issue](https://codeberg.org/BioTomateDE/LibGM/issues/new)
//! - [Email](mailto:biotomatede@proton.me?Subject=LibGM%20Question)
//!
//! ## Panicking
//! This library *should* **never panic**.
//! All malformed data files are caught into LibGM's custom error type.
//! However, since this library is not mature yet, there might still be a few
//! bugs. For GUI applications, I would definitely recommend to enable the
//! `catch-panic` crate feature (which is enabled by default anyway).
//!
//! ## Missing features
//! The following features are not yet supported by LibGM:
//! - **Null pointers**.
//! These typically occur in newer games compiled with `GMAC` (GameMaker Asset Compiler),
//! which may null out pointers to unused elements.
//! See [Issue#2](https://github.com/BioTomateDE/LibGM/issues/2) for more information.
//! - Special Vector Sprites
//! - Only partial pre WAD version 15 support
//! - Only partial/untested big endian support
//!
//! ## Breaking changes
//! Some things in this library are **not** considered "breaking changes" and
//! may be modified in `SemVer` patch updates. These could bring unwanted change
//! of behavior to your program if you don't have a `Cargo.lock` set/commited.
//! Some of these things include:
//! - All log messages (using the [`log`](https://crates.io/crates/log) crate),
//! including:
//! - Timing
//! - Code Origin/Location
//! - Message string
//! - All error contents:
//! - Error message string
//! - Context chain
//! - All structs and enums marked with `#[non_exhaustive]`
//! - Implementing traits like `GMElement` (These traits are only meant for
//! writing generic code, not for implementing it for your own types)
//!
//! There might be some other struct fields or type names
//! with docstrings saying "this may change in the future".
//! These changes will still require a SemVer minor increment, though.
//! In other words, they are definitely version-safe to use,
//! but they might be renamed or reworked soon.
//!
//! ## Credits
//! Please note that this project is effectively a Rust port of
//! [UndertaleModTool](https://github.com/UnderminersTeam/UndertaleModTool)
//! (UndertaleModLib, to be exact).
//! Most of the GameMaker elements' docstrings and struct field (names) are
//! taken from there.
// Activate all lint groups.
// Pedantic is really strong, so many lints will be whitelisted (with a reason).
//
//
// Const assertion for soundness
const _: = assert!;
use ;
// Private modules
// Public modules
// Convenience re-exports
pub use Error;
pub use Result;
// === Some TODOs for the entire library ===
//
// When Rust finally drops Macros 2.0:
// * Migrate all `macro_rules!` to `macro`s and remove exporting from crate
// root.
// Reference: https://github.com/rust-lang/rust/issues/39412
//
// When most traits (`Into`, `TryInto`, `Iterator`, `PartialEq`) are
// const-stable:
// * Clean up all `const-hack`s