├── .editorconfig
├── .gitignore
├── DATA
├── CASC-D2R
│ └── .gitignore
├── FS-fallback
│ ├── README.md
│ └── data
│ │ └── global
│ │ └── ui
│ │ └── layouts
│ │ ├── CharacterCreatePanel.json
│ │ ├── GlobalData.json
│ │ ├── GlobalDataHD.json
│ │ ├── _profilehd.json
│ │ └── _profilesd.json
├── MPQ-D2
│ └── .loadorder
└── README
├── LICENSE
├── README.md
├── bootstrap.lua
├── common
├── enum
│ ├── language.lua
│ ├── music.lua
│ ├── region.lua
│ └── resource.lua
├── globals.lua
├── interface
│ ├── label.lua
│ └── node.lua
├── json.lua
├── language.lua
├── layout.lua
├── ui.lua
└── util.lua
├── config.ini
├── media
├── ss1.png
└── ss2.png
└── screens
├── character-creation.lua
├── character-selection.lua
├── credits.lua
├── internal-error.lua
├── main-menu.lua
├── map-engine-test.lua
└── screens.lua
/.editorconfig:
--------------------------------------------------------------------------------
1 | root=true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_size = 4
7 | indent_style = space
8 | insert_final_newline = true
9 | tab_width = 4
10 | trim_trailing_whitespace = true
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Linker output
11 | *.ilk
12 | *.map
13 | *.exp
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Libraries
20 | *.lib
21 | *.a
22 | *.la
23 | *.lo
24 |
25 | # Shared objects (inc. Windows DLLs)
26 | *.dll
27 | *.so
28 | *.so.*
29 | *.dylib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 | *.i*86
36 | *.x86_64
37 | *.hex
38 |
39 | # Debug files
40 | *.dSYM/
41 | *.su
42 | *.idb
43 | *.pdb
44 |
45 | # Kernel Module Compile Results
46 | *.mod*
47 | *.cmd
48 | .tmp_versions/
49 | modules.order
50 | Module.symvers
51 | Mkfile.old
52 | dkms.conf
53 |
54 | # Mac and temporary folders
55 | .DS_Store
56 | .vs/
57 | .vscode/
58 | .idea/
59 |
60 |
61 | d2*.mpq
62 | *_d2.mpq
63 | mpqs/extracted/
64 | DATA/MPQ-D2/extracted/
65 | tags
66 | /.disable*
67 |
--------------------------------------------------------------------------------
/DATA/CASC-D2R/.gitignore:
--------------------------------------------------------------------------------
1 | /.build.info
2 | /Data
3 |
--------------------------------------------------------------------------------
/DATA/FS-fallback/README.md:
--------------------------------------------------------------------------------
1 | Substitutions for files which exist only in D2R, but which we use in MPQ-only setup too. If D2RData assets are provided, these fallbacks are skipped.
2 |
--------------------------------------------------------------------------------
/DATA/FS-fallback/data/global/ui/layouts/CharacterCreatePanel.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "CharacterCreatePanel", "name": "CharacterCreatePanel",
3 | "fields": {
4 | "anchor": { "x": 0.5 },
5 | "amazonNames": ["Amka"],
6 | "assassinNames": ["Aska"],
7 | "barbarianNames": ["Varvar"],
8 | "druidNames": ["Druid"],
9 | "necromancerNames": ["Necr"],
10 | "paladinNames": ["Palych"],
11 | "sorceressNames": ["Sorca"],
12 | },
13 | "children": [{
14 | "type": "GridImageWidget", "name": "background",
15 | "fields": {
16 | "rect": { "x": -400 },
17 | "filename": "FrontEnd/charactercreationscreenEXP",
18 | "frames": 12,
19 | "rows": 3,
20 | }
21 | }, {
22 | "type": "CharacterCreateContainerWidget", "name": "CharacterContainer",
23 | "children": [{
24 | "type": "CharacterCreateWidget", "name": "Amazon",
25 | "fields": {
26 | "rect": { "x": -300, "y": 337, },
27 | "stateAnimations": {
28 | "base": { "basePath": "FrontEnd/amazon/amnu1", "speedMultiplier": 3 },
29 | "onHover": { "basePath": "FrontEnd/amazon/amnu2", "speedMultiplier": 3 },
30 | "onSelect": { "basePath": "FrontEnd/amazon/amfw" },
31 | "selected": { "basePath": "FrontEnd/amazon/amnu3", "speedMultiplier": 2 },
32 | "onUnselect": { "basePath": "FrontEnd/amazon/ambw" },
33 | },
34 | }
35 | }, {
36 | "type": "CharacterCreateWidget", "name": "Barbarian",
37 | "fields": {
38 | "rect": { "x": 0, "y": 330, },
39 | "stateAnimations": {
40 | "base": { "basePath": "FrontEnd/barbarian/banu1", "speedMultiplier": 2 },
41 | "onHover": { "basePath": "FrontEnd/barbarian/banu2", "speedMultiplier": 2 },
42 | "onSelect": { "basePath": "FrontEnd/barbarian/bafw", "overlayPath": "FrontEnd/barbarian/bafws" },
43 | "selected": { "basePath": "FrontEnd/barbarian/banu3", "speedMultiplier": 1 },
44 | "onUnselect": { "basePath": "FrontEnd/barbarian/babw" },
45 | },
46 | }
47 | }, {
48 | "type": "CharacterCreateWidget", "name": "Necromancer",
49 | "fields": {
50 | "rect": { "x": -99, "y": 333, },
51 | "stateAnimations": {
52 | "base": { "basePath": "FrontEnd/necromancer/nenu1", "speedMultiplier": 3 },
53 | "onHover": { "basePath": "FrontEnd/necromancer/nenu2", "speedMultiplier": 3 },
54 | "onSelect": { "basePath": "FrontEnd/necromancer/nefw", "overlayPath": "FrontEnd/necromancer/nefws", "overlayBlendMode": "black" },
55 | "selected": { "basePath": "FrontEnd/necromancer/nenu3", "overlayPath": "FrontEnd/necromancer/nenu3s", "overlayBlendMode": "black", "speedMultiplier": 2 },
56 | "onUnselect": { "basePath": "FrontEnd/necromancer/nebw", "overlayPath": "FrontEnd/necromancer/nebws", "overlayBlendMode": "black" },
57 | },
58 | }
59 | }, {
60 | "type": "CharacterCreateWidget", "name": "Assassin",
61 | "fields": {
62 | "rect": { "x": -168, "y": 364, },
63 | "stateAnimations": {
64 | "base": { "basePath": "FrontEnd/assassin/asnu1", "speedMultiplier": 3 },
65 | "onHover": { "basePath": "FrontEnd/assassin/asnu2", "speedMultiplier": 3 },
66 | "onSelect": { "basePath": "FrontEnd/assassin/asfw" },
67 | "selected": { "basePath": "FrontEnd/assassin/asnu3", "speedMultiplier": 2 },
68 | "onUnselect": { "basePath": "FrontEnd/assassin/asbw" },
69 | },
70 | }
71 | }, {
72 | "type": "CharacterCreateWidget", "name": "Paladin",
73 | "fields": {
74 | "rect": { "x": 121, "y": 339, },
75 | "stateAnimations": {
76 | "base": { "basePath": "FrontEnd/paladin/panu1", "speedMultiplier": 2 },
77 | "onHover": { "basePath": "FrontEnd/paladin/panu2", "speedMultiplier": 2 },
78 | "onSelect": { "basePath": "FrontEnd/paladin/pafw", "overlayPath": "FrontEnd/paladin/pafws" },
79 | "selected": { "basePath": "FrontEnd/paladin/panu3", "speedMultiplier": 2 },
80 | "onUnselect": { "basePath": "FrontEnd/paladin/pabw" },
81 | },
82 | }
83 | }, {
84 | "type": "CharacterCreateWidget", "name": "Sorceress",
85 | "fields": {
86 | "rect": { "x": 226, "y": 353, },
87 | "stateAnimations": {
88 | "base": { "basePath": "FrontEnd/sorceress/sonu1", "speedMultiplier": 2 },
89 | "onHover": { "basePath": "FrontEnd/sorceress/sonu2", "speedMultiplier": 2 },
90 | "onSelect": { "basePath": "FrontEnd/sorceress/sofw", "overlayPath": "FrontEnd/sorceress/sofws", "overlayBlendMode": "black" },
91 | "selected": { "basePath": "FrontEnd/sorceress/sonu3", "overlayPath": "FrontEnd/sorceress/sonu3s", "overlayBlendMode": "black" },
92 | "onUnselect": { "basePath": "FrontEnd/sorceress/sobw", "overlayPath": "FrontEnd/sorceress/sobws", "overlayBlendMode": "black" },
93 | },
94 | }
95 | }, {
96 | "type": "CharacterCreateWidget", "name": "Druid",
97 | "fields": {
98 | "rect": { "x": 320, "y": 370, },
99 | "stateAnimations": {
100 | "base": { "basePath": "FrontEnd/druid/dznu1", "speedMultiplier": 2 },
101 | "onHover": { "basePath": "FrontEnd/druid/dznu2", "speedMultiplier": 2 },
102 | "onSelect": { "basePath": "FrontEnd/druid/dzfw" },
103 | "selected": { "basePath": "FrontEnd/druid/dznu3", "speedMultiplier": 2 },
104 | "onUnselect": { "basePath": "FrontEnd/druid/dzbw" },
105 | },
106 | }
107 | }]
108 | }, {
109 | "type": "TextBoxWidget",
110 | "fields": {
111 | "rect": { "x": -400, "y": 20, "width": 800, "height": 50 },
112 | "fontType": "30pt",
113 | "text": "@strSelectHeroClass#5127",
114 | "style": {
115 | "alignment": { "h": "center" }
116 | }
117 | }
118 | }, {
119 | "type": "TextBoxWidget", "name": "ClassTitle",
120 | "fields": {
121 | "rect": { "x": -400, "y": 110, "width": 800, "height": 50 },
122 | "fontType": "30pt",
123 | "style": {
124 | "alignment": { "h": "center" },
125 | },
126 | }
127 | }, {
128 | "type": "TextBoxWidget", "name": "ClassDescription",
129 | "fields": {
130 | "fontType": "16pt",
131 | "rect": { "x": -150, "y": 146, "width": 300, "height": 50 },
132 | "style": {
133 | "alignment": { "h": "center" },
134 | },
135 | }
136 | }, {
137 | "type": "ImageWidget", "name": "InputBackground",
138 | "fields": {
139 | "rect": { "x": -100, "y": 494 },
140 | "filename": "FrontEnd/textbox"
141 | },
142 | }, {
143 | "type": "InputTextBoxWidget", "name": "InputText",
144 | "fields": {
145 | "rect": { "x": -93, "y": 495, "width": 165, "height": 22 },
146 | "maxStringLength": 15,
147 | "fontType": "12ptF",
148 | "fontStyle": {
149 | "alignment": { "v": "top" },
150 | },
151 | }
152 | }, {
153 | "type": "TextBoxWidget", "name": "NameLabel",
154 | "fields": {
155 | "rect": { "x": -99, "y": 475, "width": 200, "height": 50 },
156 | "text": "@#5125",
157 | "fontType": "16pt",
158 | "style": {
159 | "fontColor": { "r": 199, "g": 179, "b": 119 }
160 | },
161 | }
162 | }, {
163 | "type": "ButtonWidget", "name": "ToMainMenu",
164 | "fields": {
165 | "rect": { "x": -365, "y": 537 },
166 | "filename": "FrontEnd/MediumSelButtonBlank",
167 | "textString": "@strExit#5101",
168 | "pressedFrame": 1,
169 | "fontType": "10ptE",
170 | "textColor": { "r": 255, "g": 255, "b": 255 },
171 | }
172 | }, {
173 | "type": "AnimatedImageWidget", "name": "Campfire",
174 | "fields": {
175 | "rect": { "x": -23, "y": 211 },
176 | "filename": "FrontEnd/fire",
177 | "blendMode": "black"
178 | },
179 | }]
180 | }
181 |
--------------------------------------------------------------------------------
/DATA/FS-fallback/data/global/ui/layouts/GlobalData.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "GlobalData", "name": "GlobalData"
3 | }
4 |
--------------------------------------------------------------------------------
/DATA/FS-fallback/data/global/ui/layouts/GlobalDataHD.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "GlobalData", "name": "GlobalData"
3 | }
4 |
--------------------------------------------------------------------------------
/DATA/FS-fallback/data/global/ui/layouts/_profilehd.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/DATA/FS-fallback/data/global/ui/layouts/_profilesd.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/DATA/MPQ-D2/.loadorder:
--------------------------------------------------------------------------------
1 | patch_d2.mpq,d2exp.mpq,d2xmusic.mpq,d2xtalk.mpq,d2xvideo.mpq,d2data.mpq,d2char.mpq,d2music.mpq,d2sfx.mpq,d2video.mpq,d2speech.mpq
--------------------------------------------------------------------------------
/DATA/README:
--------------------------------------------------------------------------------
1 | Place the *d2*.mpq files in the MPQ-D2 folder.
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://www.gnu.org/licenses/gpl-3.0)
2 | [](https://www.patreon.com/bePatron?u=37261055)
3 | [](https://discord.gg/pRy8tdc)
4 | [](https://www.twitch.tv/essial)
5 |
6 | Join us on IRC: [irc.libera.chat #opendiablo2](https://web.libera.chat/#opendiablo2)
7 |
8 | # OpenDiablo2
9 | OpenDiablo2 is an implementation of Diablo 2 in AbyssEngine.
10 |
11 | This game requires the [Abyss Engine](https://github.com/AbyssEngine/AbyssEngine) to run, as well as the MPQ files provided by the official Diablo 2 + LOD installers (online, CD, or digital).
12 |
13 | Please note that we only support users who are using an official and legally owned copy of the original game (not D2 Resurrected). If you do not have a copy of the game and/or do not use a Windows computer, it is recommend that you purchase the Windows edition of the [Diablo 2](https://us.shop.battle.net/en-us/product/diablo-ii) and [LOD Expansion](https://us.shop.battle.net/en-us/product/diablo-ii-lord-of-destruction) from the Blizzard store directly, and install/patch it on another machine, or in a virtual machine in order to obtain the MPQ files. MPQs/disks downloaded from unofficial sources tend to have mods/changes that are not supported.
14 |
15 | # General Information
16 | This project is currently in very early stages of development, and is not in a playable state yet. The game is being developed in tandem with the Abyss Engine, though all contributors are encouraged to help directly with this project instead of the core engine itself.
17 |
18 | Current Features:
19 | * Main Menu
20 | * Cinematics Screen
21 |
22 | In Progress:
23 | * Map Engine Tests Screen
24 | * Credits Screen
25 | * New Hero Screen
26 |
27 | Todo:
28 | * Gameplay (when the engine supports it)
29 |
30 | # Installation
31 |
32 | 1. Download OpenDiablo2 to a folder (or clone the repo)
33 | 1. Copy the data files over from the copy of Diablo II you have. You need to do at least one of the following:
34 | 1. If you have good old Diablo II (latest LOD patch required), copy the MPQs from the game's installation folder into the DATA\MPQ-D2 folder of this project (there should be 11 MPQs).
35 | * DO NOT DELETE THE `.loadorder` file from this folder, it should be a hidden file on most systems.
36 | 1. If you have Resurrected, copy Data/ and .build.info files from it into D2RData folder of this project. Speficially, the file structure should be like this:
37 | * DATA/CASC-D2R/.build.info
38 | * DATA/CASC-D2R/Data/indices
39 | * DATA/CASC-D2R/Data/config
40 | * DATA/CASC-D2R/Data/data
41 | 1. Download a binary of the Abyss Engine for [Windows](https://github.com/AbyssEngine/AbyssEngine/releases/download/unstable/abyss-windows.zip), [Linux](https://github.com/AbyssEngine/AbyssEngine/releases/download/unstable/abyss-linux.tar.gz), or [MacOS](https://github.com/AbyssEngine/AbyssEngine/releases/download/unstable/abyss-darwin.dmg), and extract it to the root OpenDiablo2 folder.
42 | 1. Run the Abyss Engine application.
43 |
44 | Please note that the Abyss Engine is in very active development, and new features are added on a daily basis. It is recommended that you grab a new copy of the engine any time you update your copy of this repo.
45 |
46 | # Screenshots
47 |
48 | 
49 | 
50 |
--------------------------------------------------------------------------------
/bootstrap.lua:
--------------------------------------------------------------------------------
1 | --[[ /$$$$$$ /$$$$$$$ /$$ /$$ /$$ /$$$$ /$$$$
2 | /$$__ $$ | $$__ $$|__/ | $$ | $$ |_ $$| $$_/
3 | | $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$$ | $$ \ $$ /$$ /$$$$$$ | $$$$$$$ | $$ /$$$$$$ | $$| $$
4 | | $$ | $$ /$$__ $$ /$$__ $$| $$__ $$| $$ | $$| $$ |____ $$| $$__ $$| $$ /$$__ $$ | $$| $$
5 | | $$ | $$| $$ \ $$| $$$$$$$$| $$ \ $$| $$ | $$| $$ /$$$$$$$| $$ \ $$| $$| $$ \ $$ | $$| $$
6 | | $$ | $$| $$ | $$| $$_____/| $$ | $$| $$ | $$| $$ /$$__ $$| $$ | $$| $$| $$ | $$ | $$| $$
7 | | $$$$$$/| $$$$$$$/| $$$$$$$| $$ | $$| $$$$$$$/| $$| $$$$$$$| $$$$$$$/| $$| $$$$$$/ /$$$$| $$$$
8 | \______/ | $$____/ \_______/|__/ |__/|_______/ |__/ \_______/|_______/ |__/ \______/ |____/|____/
9 | | $$ OpenDiablo II - An Abyss Engine Game
10 | | $$ https://github.com/abyssengine/opendiablo2
11 | |__/ ]]
12 |
13 |
14 | ------------------------------------------------------------------------------------------------------------------------
15 | -- OpenDiablo2 Bootstrap Script
16 | ------------------------------------------------------------------------------------------------------------------------
17 |
18 | require 'common/globals'
19 |
20 | ------------------------------------------------------------------------------------------------------------------------
21 | -- Create load providers for all of the available MPQs and CASCs
22 | ------------------------------------------------------------------------------------------------------------------------
23 |
24 | local function loadGameData()
25 | local baseDataDir = abyss.getConfig("OpenDiablo2", "BASE_DATA_DIR")
26 |
27 | local casc, mpq
28 |
29 | local function loadBaseCASC()
30 | local errored = false
31 | local missingCASCs = {}
32 | local erroredCASCs = {}
33 |
34 | if abyss.fileExists(".disableCASC") then
35 | local missingText = "D2R CASC LOADING DISABLED BY FILE: .disableCASC"
36 | return { loaded = false, data={missing = {missingText}, errored = erroredCASCs} }
37 | end
38 |
39 | local cascs = Split(abyss.getConfig("OpenDiablo2", "CASCs"), ",")
40 | for _, _casc in ipairs(cascs) do
41 | abyss.log("info", string.format("Loading CASC %s...", baseDataDir .. "/" .. _casc))
42 | local loaded = pcall(function()
43 | abyss.addLoaderProvider("casc", baseDataDir .. "/" .. _casc)
44 | end)
45 | if not loaded then
46 | abyss.log("error", string.format("Possible corrupt or missing CASC: %s", baseDataDir .. "/" .. _casc))
47 | table.insert(erroredCASCs, baseDataDir .. "/" .. _casc)
48 | errored = true
49 | end
50 | end
51 | return {loaded = not errored, data={missing = missingCASCs, errored = erroredCASCs}}
52 | end
53 |
54 | local function loadBaseMPQs()
55 | local errored = false
56 | local toLoadMPQs = {}
57 | local missingMPQs = {}
58 | local erroredMPQs = {}
59 |
60 | if abyss.fileExists(".disableMPQ") then
61 | local missingText = "MPQ LOADING DISABLED BY FILE: .disableMPQ"
62 | return { loaded = false, data={missing = {missingText}, errored = erroredMPQs} }
63 | end
64 |
65 | local mpqFolderNames = Split(abyss.getConfig("OpenDiablo2", "MPQs"), ",")
66 |
67 | for i in pairs(mpqFolderNames) do
68 | local mpqPath = baseDataDir .. "/" .. mpqFolderNames[i]
69 | local mpqLoadOrderFileName = mpqPath .. "/" .. ".loadorder"
70 | local file = io.open (mpqLoadOrderFileName, "r")
71 | local fileData = file:read("a")
72 | file:close()
73 | local mpqFiles = Split(fileData, ",")
74 | for _, mpqFile in ipairs(mpqFiles) do
75 | if file_exists(mpqPath .. "/" .. mpqFile) then
76 | table.insert(toLoadMPQs,mpqPath .. "/" .. mpqFile)
77 | else
78 | table.insert(missingMPQs, mpqPath .. "/" .. mpqFile)
79 | errored = true
80 | end
81 | end
82 | end
83 |
84 | -- If no files are missing then really load them
85 | for _, _mpq in ipairs(toLoadMPQs) do
86 | local mpqPath = baseDataDir .. "/" .. _mpq
87 | local loadStr = string.format("Loading MPQ %s...", _mpq)
88 | abyss.log("info", loadStr)
89 | local loaded = pcall(function() abyss.addLoaderProvider("mpq", _mpq) end)
90 | if not loaded then
91 | table.insert(erroredMPQs, _mpq)
92 | abyss.log("error", string.format("Possible corrupt MPQ: %s", _mpq))
93 | errored = true
94 | end
95 | end
96 | local result = {loaded = not errored, data={ missing = missingMPQs, errored = erroredMPQs}}
97 | return result
98 | end
99 |
100 | casc = loadBaseCASC()
101 | mpq = loadBaseMPQs()
102 | abyss.addLoaderProvider("filesystem", "./DATA/FS-fallback")
103 |
104 | local resultData = { missing = {}, errored = {}}
105 | for _,obj in ipairs(casc.data.missing) do table.insert(resultData.missing, obj) end
106 | for _,obj in ipairs(casc.data.errored) do table.insert(resultData.errored, obj) end
107 | for _,obj in ipairs(mpq.data.missing) do table.insert(resultData.missing, obj) end
108 | for _,obj in ipairs(mpq.data.errored) do table.insert(resultData.errored, obj) end
109 |
110 | return casc.loaded or mpq.loaded, {message = resultData}
111 | end
112 |
113 | ------------------------------------------------------------------------------------------------------------------------
114 | -- Load in all of the palettes
115 | ------------------------------------------------------------------------------------------------------------------------
116 | local function loadPalettes()
117 | for _, name in ipairs(ResourceDefs.Palettes) do
118 | local lineLog = string.format("Loading Palette: %s...", name[1])
119 | abyss.log("info", lineLog)
120 | abyss.createPalette(name[1], name[2])
121 | end
122 | end
123 |
124 | ------------------------------------------------------------------------------------------------------------------------
125 | -- Detect the language
126 | ------------------------------------------------------------------------------------------------------------------------
127 | local function detectLanguage()
128 | local configLanguageCode = abyss.getConfig("OpenDiablo2", "Language")
129 |
130 | if configLanguageCode ~= "auto" then
131 | Language:setLanguage(configLanguageCode)
132 | else
133 | Language:autoDetect()
134 | end
135 |
136 | abyss.log("info", "System language has been set to " .. Language:name() or '' .. ".")
137 | end
138 |
139 | ------------------------------------------------------------------------------------------------------------------------
140 | -- Actually load everything
141 | ------------------------------------------------------------------------------------------------------------------------
142 |
143 | local loaded, data = loadGameData()
144 | if not loaded then
145 | local ErrorScreen = require("screens/internal-error")
146 | data.header = "Crash"
147 | data.errortype = "bootstrap"
148 | ErrorScreen:new(data)
149 | return
150 | end
151 | loaded = nil
152 | data = nil
153 |
154 | loadPalettes()
155 | detectLanguage()
156 |
157 | ------------------------------------------------------------------------------------------------------------------------
158 | -- Load the global objects
159 | ------------------------------------------------------------------------------------------------------------------------
160 | LoadGlobals()
161 |
162 |
163 | ------------------------------------------------------------------------------------------------------------------------
164 | -- Play Startup Videos
165 | ------------------------------------------------------------------------------------------------------------------------
166 | local function StartGame()
167 | abyss.setCursor(CursorSprite, 1, -24)
168 | abyss.showSystemCursor(true)
169 | SetScreen(Screen.MAIN_MENU)
170 | end
171 |
172 | if abyss.getConfig("OpenDiablo2", "SkipStartupVideos") ~= "1" then
173 | if abyss.fileExists("/data/hd/global/video/blizzardlogos.webm") then
174 | abyss.playVideoAndAudio("/data/hd/global/video/blizzardlogos.webm", "/data/hd/local/video/blizzardlogos.flac", StartGame)
175 | else
176 | abyss.playVideo("/data/local/video/New_Bliz640x480.bik", function()
177 | abyss.playVideo("/data/local/video/BlizNorth640x480.bik", StartGame)
178 | end)
179 | end
180 | else
181 | StartGame()
182 | end
183 |
184 |
185 |
--------------------------------------------------------------------------------
/common/enum/language.lua:
--------------------------------------------------------------------------------
1 | return {
2 | Language3Codes = {
3 | enUS = "eng",
4 | esES = "esp",
5 | esMX = "esp", -- d2r only
6 | deDE = "deu",
7 | frFR = "fra",
8 | itIT = "ita",
9 | jaJP = "jpn",
10 | koKR = "kor",
11 | plPL = "pol",
12 | ptBR = "por",
13 | ruRU = "rus",
14 | zhCN = "chi",
15 | zhTW = "chi", -- d2r only
16 | },
17 | LanguageNames = {
18 | enUS = "English",
19 | esES = "Spanish (Spain)",
20 | esMX = "Spanish (Latinoam.)",
21 | deDE = "German",
22 | frFR = "French",
23 | itIT = "Italian",
24 | jaJP = "Japanese",
25 | koKR = "Korean",
26 | plPL = "Polish",
27 | ptBR = "Portuguese",
28 | ruRU = "Russian",
29 | -- That's not quite what these strings mean, but it seems that D2R uses them this way...
30 | -- TODO: verify
31 | zhCN = "Chinese (Simplified)",
32 | zhTW = "Chinese (Traditional)",
33 | },
34 | LanguageFontNames = {
35 | enUS = "LATIN",
36 | -- TODO: Confirm everything
37 | esES = "LATIN",
38 | esMX = "LATIN",
39 | deDE = "LATIN",
40 | frFR = "LATIN",
41 | itIT = "LATIN",
42 | jaJP = "LATIN",
43 | koKR = "kor",
44 | plPL = "LATIN",
45 | ptBR = "LATIN",
46 | ruRU = "cyr",
47 | zhCN = "chi",
48 | zhTW = "chi",
49 | },
50 | }
51 |
--------------------------------------------------------------------------------
/common/enum/music.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (C) 2021 Tim Sarbin
2 | -- This file is part of OpenDiablo2 .
3 | --
4 | -- OpenDiablo2 is free software: you can redistribute it and/or modify
5 | -- it under the terms of the GNU General Public License as published by
6 | -- the Free Software Foundation, either version 3 of the License, or
7 | -- (at your option) any later version.
8 | --
9 | -- OpenDiablo2 is distributed in the hope that it will be useful,
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | -- GNU General Public License for more details.
13 | --
14 | -- You should have received a copy of the GNU General Public License
15 | -- along with OpenDiablo2. If not, see .
16 | --
17 | return {
18 | RegionAct1Town = "BGMAct1Town1",
19 | RegionAct1Wilderness = "BGMAct1Wild",
20 | RegionAct1Cave = "BGMAct1Caves",
21 | RegionAct1Crypt = "BGMAct1Crypt",
22 | RegionAct1Monestary = "BGMAct1Monastery",
23 | RegionAct1Courtyard = "BGMAct1Monastery",
24 | RegionAct1Barracks = "BGMAct1Monastery",
25 | RegionAct1Jail = "BGMAct1Monastery",
26 | RegionAct1Cathedral = "BGMAct1Monastery",
27 | RegionAct1Catacombs = "BGMAct1Monastery",
28 | RegionAct1Tristram = "BGMAct1Tristram",
29 | RegionAct2Town = "BGMAct2Town2",
30 | RegionAct2Sewer = "BGMAct2Sewer",
31 | RegionAct2Harem = "BGMAct2Harem",
32 | RegionAct2Basement = "BGMAct2Harem",
33 | RegionAct2Desert = "BGMAct2Desert",
34 | RegionAct2Tomb = "BGMAct2Tombs",
35 | RegionAct2Lair = "BGMAct2Lair",
36 | RegionAct2Arcane = "BGMAct2Sanctuary",
37 | RegionAct3Town = "BGMAct3Town3",
38 | RegionAct3Jungle = "BGMAct3Jungle",
39 | RegionAct3Kurast = "BGMAct3Kurast",
40 | RegionAct3Spider = "BGMAct3Spider",
41 | RegionAct3Dungeon = "BGMAct3KurastSewer",
42 | RegionAct3Sewer = "BGMAct3KurastSewer",
43 | RegionAct4Town = "BGMAct4Town4",
44 | RegionAct4Mesa = "BGMAct4Mesa",
45 | RegionAct4Lava = "BGMAct4Mesa",
46 | RegonAct5Town = "BGMAct5XTown",
47 | RegionAct5Siege = "BGMAct5Siege",
48 | RegionAct5Barricade = "BGMAct5Siege", -- ?
49 | RegionAct5Temple = "BGMAct5XTemple",
50 | RegionAct5IceCaves = "BGMAct5IceCaves",
51 | RegionAct5Baal = "BGMAct5Baal",
52 | RegionAct5Lava = "BGMAct5Nihlathak" -- ?
53 | }
54 |
--------------------------------------------------------------------------------
/common/enum/region.lua:
--------------------------------------------------------------------------------
1 | return {
2 | None = 0,
3 | Act1 = {
4 | Town = 1,
5 | Wilderness = 2,
6 | Cave = 3,
7 | Crypt = 4,
8 | Monastary = 5,
9 | Courtyard = 6,
10 | Barracks = 7,
11 | Jail = 8,
12 | Cathedral = 9,
13 | Catacombs = 10,
14 | Tristram = 11
15 | },
16 | Act2 = {
17 | Town = 12,
18 | Sewer = 13,
19 | Harem = 14,
20 | Basement = 15,
21 | Desert = 16,
22 | Tomb = 17,
23 | Lair = 18,
24 | Arcane = 19
25 | },
26 | Act3 = {
27 | Town = 20,
28 | Jungle = 21,
29 | Kurast = 22,
30 | Spider = 23,
31 | Dungeon = 24,
32 | Sewer = 25
33 | },
34 | Act4 = {
35 | Town = 26,
36 | Mesa = 27,
37 | Lava = 28
38 | },
39 | Act5 = {
40 | Town = 29,
41 | Siege = 30,
42 | Barricade = 31,
43 | Temple = 32,
44 | IceCaves = 33,
45 | Baal = 34,
46 | Lava = 35
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/common/enum/resource.lua:
--------------------------------------------------------------------------------
1 | local LanguageFontToken = "{LANG_FONT}"
2 | local LanguageTableToken = "{LANG}"
3 |
4 | return {
5 | LocalLanguage = "/data/local/use",
6 |
7 | -- --- Screens ---
8 |
9 | LoadingScreen = "/data/global/ui/Loading/loadingscreen.dc6",
10 |
11 | -- --- Main Menu ---
12 |
13 | TrademarkScreen = "/data/global/ui/FrontEnd/trademarkscreenEXP.dc6",
14 | GameSelectScreen = "/data/global/ui/FrontEnd/gameselectscreenEXP.dc6",
15 | TCPIPBackground = "/data/global/ui/FrontEnd/TCPIPscreen.dc6",
16 | Diablo2LogoFireLeft = "/data/global/ui/FrontEnd/D2logoFireLeft.DC6",
17 | Diablo2LogoFireRight = "/data/global/ui/FrontEnd/D2logoFireRight.DC6",
18 | Diablo2LogoBlackLeft = "/data/global/ui/FrontEnd/D2logoBlackLeft.DC6",
19 | Diablo2LogoBlackRight = "/data/global/ui/FrontEnd/D2logoBlackRight.DC6",
20 |
21 | -- --- Credits ---
22 |
23 | CreditsBackground = "/data/global/ui/CharSelect/creditsbckgexpand.dc6",
24 | CreditsText = "/data/local/ui/" .. LanguageTableToken .. "/ExpansionCredits.txt",
25 |
26 | -- --- Cinematics ---
27 |
28 | CinematicsBackground = "/data/global/ui/FrontEnd/CinematicsSelectionEXP.dc6",
29 |
30 | -- --- Video Paths ---
31 |
32 | Act1Intro = "/data/local/video/" .. LanguageTableToken .. "/d2intro640x292.bik",
33 | Act2Intro = "/data/local/video/" .. LanguageTableToken .. "/act02start640x292.bik",
34 | Act3Intro = "/data/local/video/" .. LanguageTableToken .. "/act03start640x292.bik",
35 | Act4Intro = "/data/local/video/" .. LanguageTableToken .. "/act04start640x292.bik",
36 | Act4Outro = "/data/local/video/" .. LanguageTableToken .. "/act04end640x292.bik",
37 | Act5Intro = "/data/local/video/" .. LanguageTableToken .. "/d2x_intro_640x292.bik",
38 | Act5Outro = "/data/local/video/" .. LanguageTableToken .. "/d2x_out_640x292.bik",
39 |
40 | -- --- Character Select Screen ---
41 |
42 | CharacterSelectBackground = "/data/global/ui/FrontEnd/charactercreationscreenEXP.dc6",
43 | CharacterSelectCampfire = "/data/global/ui/FrontEnd/fire.DC6",
44 |
45 | CharacterSelectBarbarianUnselected = "/data/global/ui/FrontEnd/barbarian/banu1.DC6",
46 | CharacterSelectBarbarianUnselectedH = "/data/global/ui/FrontEnd/barbarian/banu2.DC6",
47 | CharacterSelectBarbarianSelected = "/data/global/ui/FrontEnd/barbarian/banu3.DC6",
48 | CharacterSelectBarbarianForwardWalk = "/data/global/ui/FrontEnd/barbarian/bafw.DC6",
49 | CharacterSelectBarbarianForwardWalkOverlay = "/data/global/ui/FrontEnd/barbarian/BAFWs.DC6",
50 | CharacterSelectBarbarianBackWalk = "/data/global/ui/FrontEnd/barbarian/babw.DC6",
51 |
52 | CharacterSelectSorceressUnselected = "/data/global/ui/FrontEnd/sorceress/SONU1.DC6",
53 | CharacterSelectSorceressUnselectedH = "/data/global/ui/FrontEnd/sorceress/SONU2.DC6",
54 | CharacterSelectSorceressSelected = "/data/global/ui/FrontEnd/sorceress/SONU3.DC6",
55 | CharacterSelectSorceressSelectedOverlay = "/data/global/ui/FrontEnd/sorceress/SONU3s.DC6",
56 | CharacterSelectSorceressForwardWalk = "/data/global/ui/FrontEnd/sorceress/SOFW.DC6",
57 | CharacterSelectSorceressForwardWalkOverlay = "/data/global/ui/FrontEnd/sorceress/SOFWs.DC6",
58 | CharacterSelectSorceressBackWalk = "/data/global/ui/FrontEnd/sorceress/SOBW.DC6",
59 | CharacterSelectSorceressBackWalkOverlay = "/data/global/ui/FrontEnd/sorceress/SOBWs.DC6",
60 |
61 | CharacterSelectNecromancerUnselected = "/data/global/ui/FrontEnd/necromancer/NENU1.DC6",
62 | CharacterSelectNecromancerUnselectedH = "/data/global/ui/FrontEnd/necromancer/NENU2.DC6",
63 | CharacterSelectNecromancerSelected = "/data/global/ui/FrontEnd/necromancer/NENU3.DC6",
64 | CharacterSelectNecromancerSelectedOverlay = "/data/global/ui/FrontEnd/necromancer/NENU3s.DC6",
65 | CharacterSelectNecromancerForwardWalk = "/data/global/ui/FrontEnd/necromancer/NEFW.DC6",
66 | CharacterSelectNecromancerForwardWalkOverlay = "/data/global/ui/FrontEnd/necromancer/NEFWs.DC6",
67 | CharacterSelectNecromancerBackWalk = "/data/global/ui/FrontEnd/necromancer/NEBW.DC6",
68 | CharacterSelectNecromancerBackWalkOverlay = "/data/global/ui/FrontEnd/necromancer/NEBWs.DC6",
69 |
70 | CharacterSelectPaladinUnselected = "/data/global/ui/FrontEnd/paladin/PANU1.DC6",
71 | CharacterSelectPaladinUnselectedH = "/data/global/ui/FrontEnd/paladin/PANU2.DC6",
72 | CharacterSelectPaladinSelected = "/data/global/ui/FrontEnd/paladin/PANU3.DC6",
73 | CharacterSelectPaladinForwardWalk = "/data/global/ui/FrontEnd/paladin/PAFW.DC6",
74 | CharacterSelectPaladinForwardWalkOverlay = "/data/global/ui/FrontEnd/paladin/PAFWs.DC6",
75 | CharacterSelectPaladinBackWalk = "/data/global/ui/FrontEnd/paladin/PABW.DC6",
76 |
77 | CharacterSelectAmazonUnselected = "/data/global/ui/FrontEnd/amazon/AMNU1.DC6",
78 | CharacterSelectAmazonUnselectedH = "/data/global/ui/FrontEnd/amazon/AMNU2.DC6",
79 | CharacterSelectAmazonSelected = "/data/global/ui/FrontEnd/amazon/AMNU3.DC6",
80 | CharacterSelectAmazonForwardWalk = "/data/global/ui/FrontEnd/amazon/AMFW.DC6",
81 | CharacterSelectAmazonForwardWalkOverlay = "/data/global/ui/FrontEnd/amazon/AMFWs.DC6",
82 | CharacterSelectAmazonBackWalk = "/data/global/ui/FrontEnd/amazon/AMBW.DC6",
83 |
84 | CharacterSelectAssassinUnselected = "/data/global/ui/FrontEnd/assassin/ASNU1.DC6",
85 | CharacterSelectAssassinUnselectedH = "/data/global/ui/FrontEnd/assassin/ASNU2.DC6",
86 | CharacterSelectAssassinSelected = "/data/global/ui/FrontEnd/assassin/ASNU3.DC6",
87 | CharacterSelectAssassinForwardWalk = "/data/global/ui/FrontEnd/assassin/ASFW.DC6",
88 | CharacterSelectAssassinBackWalk = "/data/global/ui/FrontEnd/assassin/ASBW.DC6",
89 |
90 | CharacterSelectDruidUnselected = "/data/global/ui/FrontEnd/druid/DZNU1.dc6",
91 | CharacterSelectDruidUnselectedH = "/data/global/ui/FrontEnd/druid/DZNU2.dc6",
92 | CharacterSelectDruidSelected = "/data/global/ui/FrontEnd/druid/DZNU3.DC6",
93 | CharacterSelectDruidForwardWalk = "/data/global/ui/FrontEnd/druid/DZFW.DC6",
94 | CharacterSelectDruidBackWalk = "/data/global/ui/FrontEnd/druid/DZBW.DC6",
95 |
96 | -- -- Character Selection
97 |
98 | CharacterSelectionBackground = "/data/global/ui/CharSelect/characterselectscreenEXP.dc6",
99 | CharacterSelectionSelectBox = "/data/global/ui/CharSelect/charselectbox.dc6",
100 | PopUpOkCancel = "/data/global/ui/FrontEnd/PopUpOKCancel.dc6",
101 |
102 | -- --- Game ---
103 |
104 | GamePanels = "/data/global/ui/PANEL/800ctrlpnl7.dc6",
105 | GameGlobeOverlap = "/data/global/ui/PANEL/overlap.DC6",
106 | HealthManaIndicator = "/data/global/ui/PANEL/hlthmana.DC6",
107 | AddSkillButton = "/data/global/ui/PANEL/level.DC6",
108 | MoveGoldDialog = "/data/global/ui/menu/dialogbackground.DC6",
109 | WPTabs = "/data/global/ui/menu/expwaygatetabs.dc6",
110 | WPBg = "/data/global/ui/menu/waygatebackground.dc6",
111 | WPIcons = "/data/global/ui/menu/waygateicons.dc6",
112 | UpDownArrows = "/data/global/ui/BIGMENU/numberarrows.dc6",
113 |
114 | -- --- Escape Menu ---
115 | -- main
116 | EscapeOptions = "/data/local/ui/" .. LanguageTableToken .. "/options.dc6",
117 | EscapeExit = "/data/local/ui/" .. LanguageTableToken .. "/exit.dc6",
118 | EscapeReturnToGame = "/data/local/ui/" .. LanguageTableToken .. "/returntogame.dc6",
119 | -- options
120 | EscapeOptSoundOptions = "/data/local/ui/" .. LanguageTableToken .. "/soundoptions.dc6",
121 | EscapeOptVideoOptions = "/data/local/ui/" .. LanguageTableToken .. "/videoOptions.dc6",
122 | EscapeOptAutoMapOptions = "/data/local/ui/" .. LanguageTableToken .. "/automapOptions.dc6",
123 | EscapeOptCfgOptions = "/data/local/ui/" .. LanguageTableToken .. "/cfgOptions.dc6",
124 | EscapeOptPrevious = "/data/local/ui/" .. LanguageTableToken .. "/previous.dc6",
125 |
126 | -- sound options
127 | EscapeSndOptSoundVolume = "/data/local/ui/" .. LanguageTableToken .. "/sound.dc6",
128 | EscapeSndOptMusicVolume = "/data/local/ui/" .. LanguageTableToken .. "/music.dc6",
129 | EscapeSndOpt3DBias = "/data/local/ui/" .. LanguageTableToken .. "/3dbias.dc6",
130 | -- EscapeSndOptHWAcceleration =
131 | -- EscapeSndOptENVEffects =
132 | EscapeSndOptNPCSpeech = "/data/local/ui/" .. LanguageTableToken .. "/npcspeech.dc6",
133 | EscapeSndOptNPCSpeechAudioAndText = "/data/local/ui/" .. LanguageTableToken .. "/audiotext.dc6",
134 | EscapeSndOptNPCSpeechAudioOnly = "/data/local/ui/" .. LanguageTableToken .. "/audioonly.dc6",
135 | EscapeSndOptNPCSpeechTextOnly = "/data/local/ui/" .. LanguageTableToken .. "/textonly.dc6",
136 |
137 | -- video options
138 | EscapeVidOptRes = "/data/local/ui/" .. LanguageTableToken .. "/resolution.dc6",
139 | EscapeVidOptLightQuality = "/data/local/ui/" .. LanguageTableToken .. "/lightquality.dc6",
140 | EscapeVidOptBlendShadow = "/data/local/ui/" .. LanguageTableToken .. "/blendshadow.dc6",
141 | EscapeVidOptPerspective = "/data/local/ui/" .. LanguageTableToken .. "/prespective.dc6",
142 | EscapeVidOptGamma = "/data/local/ui/" .. LanguageTableToken .. "/gamma.dc6",
143 | EscapeVidOptContrast = "/data/local/ui/" .. LanguageTableToken .. "/contrast.dc6",
144 |
145 | -- auto map
146 | EscapeAutoMapOptSize = "/data/local/ui/" .. LanguageTableToken .. "/automapmode.dc6",
147 | EscapeAutoMapOptFade = "/data/local/ui/" .. LanguageTableToken .. "/automapfade.dc6",
148 | EscapeAutoMapOptCenter = "/data/local/ui/" .. LanguageTableToken .. "/automapcenter.dc6",
149 | EscapeAutoMapOptNames = "/data/local/ui/" .. LanguageTableToken .. "/automappartynames.dc6",
150 |
151 | -- automap size
152 | EscapeAutoMapOptFullScreen = "/data/local/ui/" .. LanguageTableToken .. "/full.dc6",
153 | EscapeAutoMapOptMiniMap = "/data/local/ui/" .. LanguageTableToken .. "/mini.dc6",
154 |
155 | -- resolutions
156 | EscapeVideoOptRes640x480 = "/data/local/ui/" .. LanguageTableToken .. "/640x480.dc6",
157 | EscapeVideoOptRes800x600 = "/data/local/ui/" .. LanguageTableToken .. "/800x800.dc6",
158 |
159 | EscapeOn = "/data/local/ui/" .. LanguageTableToken .. "/smallon.dc6",
160 | EscapeOff = "/data/local/ui/" .. LanguageTableToken .. "/smalloff.dc6",
161 | EscapeYes = "/data/local/ui/" .. LanguageTableToken .. "/smallyes.dc6",
162 | EscapeNo = "/data/local/ui/" .. LanguageTableToken .. "/smallno.dc6",
163 | EscapeSlideBar = "/data/global/ui/widgets/optbarc.dc6",
164 | EscapeSlideBarSkull = "/data/global/ui/widgets/optskull.dc6",
165 |
166 | -- --- Help Overlay ---
167 |
168 | -- HelpBorder = "/data/global/ui/MENU/helpborder.DC6",
169 | HelpBorder = "/data/global/ui/MENU/800helpborder.DC6",
170 | HelpYellowBullet = "/data/global/ui/MENU/helpyellowbullet.DC6",
171 | HelpWhiteBullet = "/data/global/ui/MENU/helpwhitebullet.DC6",
172 |
173 | -- Box pieces, used in all in game boxes like npc interaction menu on click,
174 | -- the chat window and the key binding menu
175 | BoxPieces = "/data/global/ui/MENU/boxpieces.DC6",
176 |
177 | -- TextSlider contains the pieces to build a scrollbar in the
178 | -- menus, such as the one in the configure keys menu
179 | TextSlider = "/data/global/ui/MENU/textslid.DC6",
180 |
181 | -- Issue #685 - used in the mini-panel
182 | GameSmallMenuButton = "/data/global/ui/PANEL/menubutton.DC6",
183 | SkillIcon = "/data/global/ui/PANEL/Skillicon.DC6",
184 |
185 | -- --- Quest Log---
186 | QuestLogBg = "/data/global/ui/MENU/questbackground.dc6",
187 | QuestLogDone = "/data/global/ui/MENU/questdone.dc6",
188 | QuestLogTabs = "/data/global/ui/MENU/expquesttabs.dc6",
189 | QuestLogQDescrBtn = "/data/global/ui/MENU/questlast.dc6",
190 | QuestLogSocket = "/data/global/ui/MENU/questsockets.dc6",
191 | QuestLogAQuestAnimation = "/data/global/ui/MENU/a%dq%d.dc6",
192 | QuestLogDoneSfx = "cursor/questdone.wav",
193 |
194 | -- --- Mouse Pointers ---
195 |
196 | CursorDefault = "/data/global/ui/CURSOR/ohand.DC6",
197 |
198 | -- --- Fonts & Locale (strings) ---
199 | Font6 = "/data/local/FONT/" .. LanguageFontToken .. "/font6",
200 | Font8 = "/data/local/FONT/" .. LanguageFontToken .. "/font8",
201 | Font16 = "/data/local/FONT/" .. LanguageFontToken .. "/font16",
202 | Font24 = "/data/local/FONT/" .. LanguageFontToken .. "/font24",
203 | Font30 = "/data/local/FONT/" .. LanguageFontToken .. "/font30",
204 | Font42 = "/data/local/FONT/" .. LanguageFontToken .. "/font42",
205 | FontFormal12 = "/data/local/FONT/" .. LanguageFontToken .. "/fontformal12",
206 | FontFormal11 = "/data/local/FONT/" .. LanguageFontToken .. "/fontformal11",
207 | FontFormal10 = "/data/local/FONT/" .. LanguageFontToken .. "/fontformal10",
208 | FontExocet10 = "/data/local/FONT/" .. LanguageFontToken .. "/fontexocet10",
209 | FontExocet8 = "/data/local/FONT/" .. LanguageFontToken .. "/fontexocet8",
210 | FontSucker = "/data/local/FONT/" .. LanguageFontToken .. "/ReallyTheLastSucker",
211 | FontRidiculous = "/data/local/FONT/" .. LanguageFontToken .. "/fontridiculous",
212 |
213 | ExpansionStringTable = "/data/local/lng/" .. LanguageTableToken .. "/expansionstring.tbl",
214 | StringTable = "/data/local/lng/" .. LanguageTableToken .. "/string.tbl",
215 | PatchStringTable = "/data/local/lng/" .. LanguageTableToken .. "/patchstring.tbl",
216 |
217 | -- --- UI ---
218 |
219 | WideButtonBlank = "/data/global/ui/FrontEnd/WideButtonBlank.dc6",
220 | MediumButtonBlank = "/data/global/ui/FrontEnd/MediumButtonBlank.dc6",
221 | CancelButton = "/data/global/ui/FrontEnd/CancelButtonBlank.dc6",
222 | NarrowButtonBlank = "/data/global/ui/FrontEnd/NarrowButtonBlank.dc6",
223 | ShortButtonBlank = "/data/global/ui/CharSelect/ShortButtonBlank.dc6",
224 | TextBox2 = "/data/global/ui/FrontEnd/textbox2.dc6",
225 | TallButtonBlank = "/data/global/ui/CharSelect/TallButtonBlank.dc6",
226 | Checkbox = "/data/global/ui/FrontEnd/clickbox.dc6",
227 | Scrollbar = "/data/global/ui/PANEL/scrollbar.dc6",
228 |
229 | PopUpLarge = "/data/global/ui/FrontEnd/PopUpLarge.dc6",
230 | PopUpLargest = "/data/global/ui/FrontEnd/PopUpLargest.dc6",
231 | PopUpWide = "/data/global/ui/FrontEnd/PopUpWide.dc6",
232 | PopUpOk = "/data/global/ui/FrontEnd/PopUpOk.dc6",
233 | PopUpOk2 = "/data/global/ui/FrontEnd/PopUpOk.dc6",
234 | PopUpOkCancel2 = "/data/global/ui/FrontEnd/PopUpOkCancel2.dc6",
235 | PopUp340x224 = "/data/global/ui/FrontEnd/PopUp_340x224.dc6",
236 |
237 | -- --- GAME UI ---
238 |
239 | PentSpin = "/data/global/ui/CURSOR/pentspin.DC6",
240 | Minipanel = "/data/global/ui/PANEL/minipanel.DC6",
241 | MinipanelSmall = "/data/global/ui/PANEL/minipanel_s.dc6",
242 | MinipanelButton = "/data/global/ui/PANEL/minipanelbtn.DC6",
243 |
244 | Frame = "/data/global/ui/PANEL/800borderframe.dc6",
245 | InventoryCharacterPanel = "/data/global/ui/PANEL/invchar6.DC6",
246 | PartyPanel = "/data/global/ui/MENU/party.dc6",
247 | PartyButton = "/data/global/ui/MENU/partybuttons.dc6",
248 | PartyBoxes = "/data/global/ui/MENU/partyboxes.dc6",
249 | PartyBar = "/data/global/ui/MENU/partybar.dc6",
250 | HeroStatsPanelStatsPoints = "/data/global/ui/PANEL/skillpoints.dc6",
251 | HeroStatsPanelSocket = "/data/global/ui/PANEL/levelsocket.dc6",
252 | InventoryWeaponsTab = "/data/global/ui/PANEL/invchar6Tab.DC6",
253 | SkillsPanelAmazon = "/data/global/ui/SPELLS/skltree_a_back.DC6",
254 | SkillsPanelBarbarian = "/data/global/ui/SPELLS/skltree_b_back.DC6",
255 | SkillsPanelDruid = "/data/global/ui/SPELLS/skltree_d_back.DC6",
256 | SkillsPanelAssassin = "/data/global/ui/SPELLS/skltree_i_back.DC6",
257 | SkillsPanelNecromancer = "/data/global/ui/SPELLS/skltree_n_back.DC6",
258 | SkillsPanelPaladin = "/data/global/ui/SPELLS/skltree_p_back.DC6",
259 | SkillsPanelSorcerer = "/data/global/ui/SPELLS/skltree_s_back.DC6",
260 |
261 | GenericSkills = "/data/global/ui/SPELLS/Skillicon.DC6",
262 | AmazonSkills = "/data/global/ui/SPELLS/AmSkillicon.DC6",
263 | BarbarianSkills = "/data/global/ui/SPELLS/BaSkillicon.DC6",
264 | DruidSkills = "/data/global/ui/SPELLS/DrSkillicon.DC6",
265 | AssassinSkills = "/data/global/ui/SPELLS/AsSkillicon.DC6",
266 | NecromancerSkills = "/data/global/ui/SPELLS/NeSkillicon.DC6",
267 | PaladinSkills = "/data/global/ui/SPELLS/PaSkillicon.DC6",
268 | SorcererSkills = "/data/global/ui/SPELLS/SoSkillicon.DC6",
269 |
270 | RunButton = "/data/global/ui/PANEL/runbutton.dc6",
271 | MenuButton = "/data/global/ui/PANEL/menubutton.DC6",
272 | GoldCoinButton = "/data/global/ui/panel/goldcoinbtn.dc6",
273 | BuySellButton = "/data/global/ui/panel/buysellbtn.dc6",
274 |
275 | ArmorPlaceholder = "/data/global/ui/PANEL/inv_armor.DC6",
276 | BeltPlaceholder = "/data/global/ui/PANEL/inv_belt.DC6",
277 | BootsPlaceholder = "/data/global/ui/PANEL/inv_boots.DC6",
278 | HelmGlovePlaceholder = "/data/global/ui/PANEL/inv_helm_glove.DC6",
279 | RingAmuletPlaceholder = "/data/global/ui/PANEL/inv_ring_amulet.DC6",
280 | WeaponsPlaceholder = "/data/global/ui/PANEL/inv_weapons.DC6",
281 |
282 | -- --- Data ---
283 |
284 | LevelPreset = "/data/global/excel/LvlPrest.txt",
285 | LevelType = "/data/global/excel/LvlTypes.txt",
286 | ObjectType = "/data/global/excel/objtype.txt",
287 | LevelWarp = "/data/global/excel/LvlWarp.txt",
288 | LevelDetails = "/data/global/excel/Levels.txt",
289 | LevelMaze = "/data/global/excel/LvlMaze.txt",
290 | LevelSubstitutions = "/data/global/excel/LvlSub.txt",
291 |
292 | ObjectDetails = "/data/global/excel/Objects.txt",
293 | ObjectMode = "/data/global/excel/ObjMode.txt",
294 | SoundSettings = "/data/global/excel/Sounds.txt",
295 | ItemStatCost = "/data/global/excel/ItemStatCost.txt",
296 | ItemRatio = "/data/global/excel/itemratio.txt",
297 | ItemTypes = "/data/global/excel/ItemTypes.txt",
298 | QualityItems = "/data/global/excel/qualityitems.txt",
299 | LowQualityItems = "/data/global/excel/lowqualityitems.txt",
300 | Overlays = "/data/global/excel/Overlay.txt",
301 | Runes = "/data/global/excel/runes.txt",
302 | Sets = "/data/global/excel/Sets.txt",
303 | SetItems = "/data/global/excel/SetItems.txt",
304 | AutoMagic = "/data/global/excel/automagic.txt",
305 | BodyLocations = "/data/global/excel/bodylocs.txt",
306 | Events = "/data/global/excel/events.txt",
307 | Properties = "/data/global/excel/Properties.txt",
308 | Hireling = "/data/global/excel/hireling.txt",
309 | HirelingDescription = "/data/global/excel/HireDesc.txt",
310 | DifficultyLevels = "/data/global/excel/difficultylevels.txt",
311 | AutoMap = "/data/global/excel/AutoMap.txt",
312 | CubeRecipes = "/data/global/excel/cubemain.txt",
313 | CubeModifier = "/data/global/excel/CubeMod.txt",
314 | CubeType = "/data/global/excel/CubeType.txt",
315 | Skills = "/data/global/excel/skills.txt",
316 | SkillDesc = "/data/global/excel/skilldesc.txt",
317 | SkillCalc = "/data/global/excel/skillcalc.txt",
318 | MissileCalc = "/data/global/excel/misscalc.txt",
319 | TreasureClass = "/data/global/excel/TreasureClass.txt",
320 | TreasureClassEx = "/data/global/excel/TreasureClassEx.txt",
321 | States = "/data/global/excel/states.txt",
322 | SoundEnvirons = "/data/global/excel/soundenviron.txt",
323 | Shrines = "/data/global/excel/shrines.txt",
324 | MonProp = "/data/global/excel/Monprop.txt",
325 | ElemType = "/data/global/excel/ElemTypes.txt",
326 | PlrMode = "/data/global/excel/PlrMode.txt",
327 | PetType = "/data/global/excel/pettype.txt",
328 | NPC = "/data/global/excel/npc.txt",
329 | MonsterUniqueModifier = "/data/global/excel/monumod.txt",
330 | MonsterEquipment = "/data/global/excel/monequip.txt",
331 | UniqueAppellation = "/data/global/excel/UniqueAppellation.txt",
332 | MonsterLevel = "/data/global/excel/monlvl.txt",
333 | MonsterSound = "/data/global/excel/monsounds.txt",
334 | MonsterSequence = "/data/global/excel/monseq.txt",
335 | PlayerClass = "/data/global/excel/PlayerClass.txt",
336 | PlayerType = "/data/global/excel/PlrType.txt",
337 | Composite = "/data/global/excel/Composit.txt",
338 | HitClass = "/data/global/excel/HitClass.txt",
339 | ObjectGroup = "/data/global/excel/objgroup.txt",
340 | CompCode = "/data/global/excel/compcode.txt",
341 | Belts = "/data/global/excel/belts.txt",
342 | Gamble = "/data/global/excel/gamble.txt",
343 | Colors = "/data/global/excel/colors.txt",
344 | StorePage = "/data/global/excel/StorePage.txt",
345 |
346 | -- --- Animations ---
347 |
348 | ObjectData = "/data/global/objects",
349 | AnimationData = "/data/global/animdata.d2",
350 | PlayerAnimationBase = "/data/global/CHARS",
351 | MissileData = "/data/global/missiles",
352 | ItemGraphics = "/data/global/items",
353 |
354 | -- --- Inventory Data ---
355 |
356 | Inventory = "/data/global/excel/inventory.txt",
357 | Weapons = "/data/global/excel/weapons.txt",
358 | Armor = "/data/global/excel/armor.txt",
359 | ArmorType = "/data/global/excel/ArmType.txt",
360 | WeaponClass = "/data/global/excel/WeaponClass.txt",
361 | Books = "/data/global/excel/books.txt",
362 | Misc = "/data/global/excel/misc.txt",
363 | UniqueItems = "/data/global/excel/UniqueItems.txt",
364 | Gems = "/data/global/excel/gems.txt",
365 |
366 | -- --- Affixes ---
367 |
368 | MagicPrefix = "/data/global/excel/MagicPrefix.txt",
369 | MagicSuffix = "/data/global/excel/MagicSuffix.txt",
370 | RarePrefix = "/data/global/excel/RarePrefix.txt", -- these are for item names
371 | RareSuffix = "/data/global/excel/RareSuffix.txt",
372 |
373 | -- --- Monster Prefix/Suffixes (?) ---
374 | UniquePrefix = "/data/global/excel/UniquePrefix.txt",
375 | UniqueSuffix = "/data/global/excel/UniqueSuffix.txt",
376 |
377 | -- --- Character Data ---
378 |
379 | Experience = "/data/global/excel/experience.txt",
380 | CharStats = "/data/global/excel/charstats.txt",
381 |
382 | -- --- Music ---
383 |
384 | BGMTitle = "/data/global/music/introedit.wav",
385 | BGMOptions = "/data/global/music/Common/options.wav",
386 | BGMAct1AndarielAction = "/data/global/music/Act1/andarielaction.wav",
387 | BGMAct1BloodRavenResolution = "/data/global/music/Act1/bloodravenresolution.wav",
388 | BGMAct1Caves = "/data/global/music/Act1/caves.wav",
389 | BGMAct1Crypt = "/data/global/music/Act1/crypt.wav",
390 | BGMAct1DenOfEvilAction = "/data/global/music/Act1/denofevilaction.wav",
391 | BGMAct1Monastery = "/data/global/music/Act1/monastery.wav",
392 | BGMAct1Town1 = "/data/global/music/Act1/town1.wav",
393 | BGMAct1Tristram = "/data/global/music/Act1/tristram.wav",
394 | BGMAct1Wild = "/data/global/music/Act1/wild.wav",
395 | BGMAct2Desert = "/data/global/music/Act2/desert.wav",
396 | BGMAct2Harem = "/data/global/music/Act2/harem.wav",
397 | BGMAct2HoradricAction = "/data/global/music/Act2/horadricaction.wav",
398 | BGMAct2Lair = "/data/global/music/Act2/lair.wav",
399 | BGMAct2RadamentResolution = "/data/global/music/Act2/radamentresolution.wav",
400 | BGMAct2Sanctuary = "/data/global/music/Act2/sanctuary.wav",
401 | BGMAct2Sewer = "/data/global/music/Act2/sewer.wav",
402 | BGMAct2TaintedSunAction = "/data/global/music/Act2/taintedsunaction.wav",
403 | BGMAct2Tombs = "/data/global/music/Act2/tombs.wav",
404 | BGMAct2Town2 = "/data/global/music/Act2/town2.wav",
405 | BGMAct2Valley = "/data/global/music/Act2/valley.wav",
406 | BGMAct3Jungle = "/data/global/music/Act3/jungle.wav",
407 | BGMAct3Kurast = "/data/global/music/Act3/kurast.wav",
408 | BGMAct3KurastSewer = "/data/global/music/Act3/kurastsewer.wav",
409 | BGMAct3MefDeathAction = "/data/global/music/Act3/mefdeathaction.wav",
410 | BGMAct3OrbAction = "/data/global/music/Act3/orbaction.wav",
411 | BGMAct3Spider = "/data/global/music/Act3/spider.wav",
412 | BGMAct3Town3 = "/data/global/music/Act3/town3.wav",
413 | BGMAct4Diablo = "/data/global/music/Act4/diablo.wav",
414 | BGMAct4DiabloAction = "/data/global/music/Act4/diabloaction.wav",
415 | BGMAct4ForgeAction = "/data/global/music/Act4/forgeaction.wav",
416 | BGMAct4IzualAction = "/data/global/music/Act4/izualaction.wav",
417 | BGMAct4Mesa = "/data/global/music/Act4/mesa.wav",
418 | BGMAct4Town4 = "/data/global/music/Act4/town4.wav",
419 | BGMAct5Baal = "/data/global/music/Act5/baal.wav",
420 | BGMAct5Siege = "/data/global/music/Act5/siege.wav",
421 | BGMAct5Shenk = "/data/global/music/Act5/shenkmusic.wav",
422 | BGMAct5XTown = "/data/global/music/Act5/xtown.wav",
423 | BGMAct5XTemple = "/data/global/music/Act5/xtemple.wav",
424 | BGMAct5IceCaves = "/data/global/music/Act5/icecaves.wav",
425 | BGMAct5Nihlathak = "/data/global/music/Act5/nihlathakmusic.wav",
426 |
427 | -- --- Sound Effects ---
428 |
429 | SFXCursorSelect = "cursor_select",
430 | SFXButtonClick = "cursor_button_click",
431 | SFXAmazonDeselect = "cursor_amazon_deselect",
432 | SFXAmazonSelect = "cursor_amazon_select",
433 | SFXAssassinDeselect = "Cursor/intro/assassin deselect.wav",
434 | SFXAssassinSelect = "Cursor/intro/assassin select.wav",
435 | SFXBarbarianDeselect = "cursor_barbarian_deselect",
436 | SFXBarbarianSelect = "cursor_barbarian_select",
437 | SFXDruidDeselect = "Cursor/intro/druid deselect.wav",
438 | SFXDruidSelect = "Cursor/intro/druid select.wav",
439 | SFXNecromancerDeselect = "cursor_necromancer_deselect",
440 | SFXNecromancerSelect = "cursor_necromancer_select",
441 | SFXPaladinDeselect = "cursor_paladin_deselect",
442 | SFXPaladinSelect = "cursor_paladin_select",
443 | SFXSorceressDeselect = "cursor_sorceress_deselect",
444 | SFXSorceressSelect = "cursor_sorceress_select",
445 |
446 | -- --- Enemy Data ---
447 |
448 | MonStats = "/data/global/excel/monstats.txt",
449 | MonStats2 = "/data/global/excel/monstats2.txt",
450 | MonPreset = "/data/global/excel/monpreset.txt",
451 | MonType = "/data/global/excel/Montype.txt",
452 | SuperUniques = "/data/global/excel/SuperUniques.txt",
453 | MonMode = "/data/global/excel/monmode.txt",
454 | MonsterPlacement = "/data/global/excel/MonPlace.txt",
455 | MonsterAI = "/data/global/excel/monai.txt",
456 |
457 | -- --- Skill Data ---
458 |
459 | Missiles = "/data/global/excel/Missiles.txt",
460 |
461 | -- --- Palettes ---
462 |
463 | Palette = {
464 | Act1 = "PaletteAct1",
465 | Act2 = "PaletteAct2",
466 | Act3 = "PaletteAct3",
467 | Act4 = "PaletteAct4",
468 | Act5 = "PaletteAct5",
469 | EndGame = "PaletteEndGame",
470 | EndGame2 = "PaletteEndGame2",
471 | Fechar = "PaletteFechar",
472 | Loading = "PaletteLoading",
473 | Menu0 = "PaletteMenu0",
474 | Menu1 = "PaletteMenu1",
475 | Menu2 = "PaletteMenu2",
476 | Menu3 = "PaletteMenu3",
477 | Menu4 = "PaletteMenu4",
478 | Sky = "PaletteSky",
479 | Static = "PaletteStatic",
480 | Trademark = "PaletteTrademark",
481 | Units = "PaletteUnits"
482 |
483 | },
484 |
485 | Palettes = {{"PaletteAct1", "/data/global/palette/act1/pal.pl2"},
486 | {"PaletteAct2", "/data/global/palette/act2/pal.pl2"},
487 | {"PaletteAct3", "/data/global/palette/act3/pal.pl2"},
488 | {"PaletteAct4", "/data/global/palette/act4/pal.pl2"},
489 | {"PaletteAct5", "/data/global/palette/act5/pal.pl2"},
490 | {"PaletteEndGame", "/data/global/palette/endgame/pal.pl2"},
491 | {"PaletteEndGame2", "/data/global/palette/endgame2/pal.pl2"},
492 | {"PaletteFechar", "/data/global/palette/fechar/pal.pl2"},
493 | {"PaletteLoading", "/data/global/palette/loading/pal.pl2"},
494 | {"PaletteMenu0", "/data/global/palette/menu0/pal.pl2"},
495 | {"PaletteMenu1", "/data/global/palette/menu1/pal.pl2"},
496 | {"PaletteMenu2", "/data/global/palette/menu2/pal.pl2"},
497 | {"PaletteMenu3", "/data/global/palette/menu3/pal.pl2"},
498 | {"PaletteMenu4", "/data/global/palette/menu4/pal.pl2"},
499 | {"PaletteSky", "/data/global/palette/sky/pal.pl2"},
500 | {"PaletteStatic", "/data/global/palette/static/pal.dat"},
501 | {"PaletteTrademark", "/data/global/palette/trademark/pal.pl2"},
502 | {"PaletteUnits", "/data/global/palette/units/pal.dat"}}
503 | }
504 |
--------------------------------------------------------------------------------
/common/globals.lua:
--------------------------------------------------------------------------------
1 | print = function (message) abyss.log("info", message); end;
2 | require ('common/util')
3 | require ('common/ui')
4 | require ('screens/screens')
5 |
6 | Language = require('common/language')
7 | MusicDefs = require('common/enum/music')
8 | RegionDefs = require('common/enum/region')
9 | ResourceDefs = require("common/enum/resource")
10 | BasePath = abyss.getConfig("#Abyss", "BasePath")
11 | IsOnButton = false
12 | ShowTrademarkScreen = true
13 |
14 | function LoadGlobals()
15 | ResurrectedMode = abyss.fileExists('/data/local/lng/strings/ui.json')
16 |
17 | -- Load the fonts
18 | SystemFonts = {}
19 | SpriteFontIsActuallyTTF = false
20 | -- D2R doesn't have Cyrillic sprite font, so if Russian is selected, try sprite font, and fallback to TTF font (which looks more ugly on the old-style buttons).
21 | -- TODO use LanguageFontRemapper from GlobalData
22 | local function loadFormal(size)
23 | local filename = Language:i18nPath(ResourceDefs['FontFormal' .. tostring(size)])
24 | if abyss.fileExists(filename .. '.dc6') then
25 | return abyss.createSpriteFont(filename, ResourceDefs.Palette.Static, true, 'blend')
26 | end
27 | SpriteFontIsActuallyTTF = true
28 | return abyss.createTtfFont('/data/hd/ui/fonts/philosopher-bolditalic.ttf', math.floor(size * 1.2), 'slight')
29 | end
30 | local function loadFnt(size)
31 | local filename = Language:i18nPath(ResourceDefs['Font' .. tostring(size)])
32 | if abyss.fileExists(filename .. '.dc6') then
33 | return abyss.createSpriteFont(filename, ResourceDefs.Palette.Static, false, 'blend')
34 | end
35 | SpriteFontIsActuallyTTF = true
36 | return abyss.createTtfFont('/data/hd/ui/fonts/ExocetBlizzardOT-Medium.otf', math.floor(size * 0.8), 'none')
37 | end
38 | local function loadExocet(size)
39 | local filename = Language:i18nPath(ResourceDefs['FontExocet' .. tostring(size)])
40 | if abyss.fileExists(filename .. '.dc6') then
41 | return abyss.createSpriteFont(filename, ResourceDefs.Palette.Static, false, 'multiply')
42 | end
43 | SpriteFontIsActuallyTTF = true
44 | return abyss.createTtfFont('/data/hd/ui/fonts/ExocetBlizzardOT-Medium.otf', math.floor(size * 1.4), 'none')
45 | end
46 | local function loadSucker()
47 | local filename = Language:i18nPath(ResourceDefs.FontSucker)
48 | if abyss.fileExists(filename .. '.dc6') then
49 | return abyss.createSpriteFont(filename, ResourceDefs.Palette.Static, true, 'blend')
50 | end
51 | SpriteFontIsActuallyTTF = true
52 | return abyss.createTtfFont('/data/hd/ui/fonts/BlizzardGlobal-v5_81.ttf', 10, 'none')
53 | --return abyss.createTtfFont('/data/hd/ui/fonts/BlizzardGlobalTCUnicode.ttf', 8, 'none')
54 | end
55 | local function loadRidiculous()
56 | local filename = Language:i18nPath(ResourceDefs.FontRidiculous)
57 | if abyss.fileExists(filename .. '.dc6') then
58 | return abyss.createSpriteFont(filename, ResourceDefs.Palette.Static, false, 'multiply')
59 | end
60 | SpriteFontIsActuallyTTF = true
61 | return abyss.createTtfFont('/data/hd/ui/fonts/ExocetBlizzardOT-Medium.otf', 10, 'none')
62 | end
63 | SystemFonts.FntFormal10 = loadFormal(10)
64 | SystemFonts.FntFormal11 = loadFormal(11)
65 | SystemFonts.FntFormal12 = loadFormal(12)
66 | SystemFonts.FntSucker = loadSucker()
67 | SystemFonts.FntRidiculous = loadRidiculous()
68 | SystemFonts.FntExocet8 = loadExocet(8)
69 | SystemFonts.FntExocet10 = loadExocet(10)
70 | SystemFonts.Fnt16 = loadFnt(16)
71 | SystemFonts.Fnt24 = loadFnt(24)
72 | SystemFonts.Fnt30 = loadFnt(30)
73 | SystemFonts.Fnt42 = loadFnt(42)
74 |
75 | CursorSprite = CreateUniqueSpriteFromFile(ResourceDefs.CursorDefault, ResourceDefs.Palette.Sky)
76 | CursorSprite.blendMode = "blend"
77 |
78 | LayoutLoader = require('common/layout'):new()
79 | LoadDatasets()
80 |
81 | InitUI()
82 | end
83 |
84 | function LoadSoundEffect(handle)
85 | if SoundEffects[handle] == nil then
86 | return nil
87 | end
88 | local attempts = {}
89 | local redirect = SoundEffects[handle].Redirect
90 | if redirect ~= nil and redirect ~= "" then
91 | table.insert(attempts, SoundEffects[redirect].FileName)
92 | -- cursor_button_click redirects to cursor_button_hd_1 but only cursor_button_3_hd.flac actually exists
93 | local _, _, start, digit = redirect:find("(.*_)(%d)$")
94 | if digit then
95 | for _, i in ipairs({1, 2, 3, 4, 5}) do
96 | table.insert(attempts, SoundEffects[start .. i].FileName)
97 | end
98 | end
99 | end
100 | table.insert(attempts, SoundEffects[handle].FileName)
101 | for _, file in ipairs(attempts) do
102 | if abyss.fileExists("/data/hd/global/sfx/" .. file) then
103 | return abyss.createSoundEffect("/data/hd/global/sfx/" .. file)
104 | end
105 | if abyss.fileExists("/data/global/sfx/" .. file) then
106 | return abyss.createSoundEffect("/data/global/sfx/" .. file)
107 | end
108 | end
109 | end
110 |
111 | function LoadDatasets()
112 | -- ----------------------------------------------------------------------------------------------------------
113 | abyss.log("info", "Loading Sound Effects")
114 | -- ----------------------------------------------------------------------------------------------------------
115 | SoundEffects = LoadTsvAsTable(ResourceDefs.SoundSettings, true)
116 |
117 |
118 | -- ----------------------------------------------------------------------------------------------------------
119 | abyss.log("info", "Loading Level Types")
120 | -- ----------------------------------------------------------------------------------------------------------
121 | LevelTypes = {}
122 | local levelTypeDefs = LoadTsvAsTable(ResourceDefs.LevelType, true)
123 | for _, levelTypeRecord in pairs(levelTypeDefs) do
124 | if levelTypeRecord.Id ~= "" then
125 | local levelType = abyss.LevelType.new()
126 | levelType.id = tonumber(levelTypeRecord.Id)
127 | levelType.name = levelTypeRecord.Name
128 | levelType.act = tonumber(levelTypeRecord.Act)
129 | levelType.beta = tonumber(levelTypeRecord.Beta) == 0
130 | levelType.expansion = levelType.act > 4
131 |
132 | for i=1,32 do
133 | local fileName = levelTypeRecord["File_" .. i]
134 | levelType.files:add("/data/global/tiles/" .. fileName)
135 | end
136 |
137 | LevelTypes[levelType.id] = levelType
138 | end
139 | end
140 |
141 | -- ----------------------------------------------------------------------------------------------------------
142 | abyss.log("info", "Loading Level Presets")
143 | -- ----------------------------------------------------------------------------------------------------------
144 | LevelPresets = {}
145 | local levelPresetDefs = LoadTsvAsTable(ResourceDefs.LevelPreset, true)
146 | for _, levelPresetRecord in pairs(levelPresetDefs) do
147 | if levelPresetRecord.Def ~= nil and levelPresetRecord.Name ~= '' and levelPresetRecord.Name ~= 'Expansion' then
148 | local levelPreset = abyss.LevelPreset.new()
149 | levelPreset.name = levelPresetRecord.Name
150 | levelPreset.definitionId = tonumber(levelPresetRecord.Def)
151 | levelPreset.levelId = tonumber(levelPresetRecord.LevelId)
152 | levelPreset.populate = tonumber(levelPresetRecord.Populate) == 1
153 | levelPreset.logicals = tonumber(levelPresetRecord.Logicals) == 1
154 | levelPreset.outdoors = tonumber(levelPresetRecord.Outdoors) == 1
155 | levelPreset.animate = tonumber(levelPresetRecord.Animate) == 1
156 | levelPreset.killEdge = tonumber(levelPresetRecord.KillEdge) == 1
157 | levelPreset.fillBlanks = tonumber(levelPresetRecord.FillBlanks) == 1
158 | levelPreset.sizeX = tonumber(levelPresetRecord.SizeX)
159 | levelPreset.sizeY = tonumber(levelPresetRecord.SizeY)
160 | levelPreset.autoMap = tonumber(levelPresetRecord.AutoMap) == 1
161 | levelPreset.scan = tonumber(levelPresetRecord.Scan) == 1
162 | levelPreset.pops = tonumber(levelPresetRecord.Pops)
163 | levelPreset.popPad = tonumber(levelPresetRecord.PopPad)
164 | levelPreset.dt1Mask = tonumber(levelPresetRecord.Dt1Mask)
165 | levelPreset.beta = tonumber(levelPresetRecord.Beta) == 1
166 |
167 | for i=1,6 do
168 | local fileName = levelPresetRecord["File" .. i]
169 | if fileName ~= "0" then
170 | levelPreset.files:add("/data/global/tiles/" .. fileName)
171 | end
172 | end
173 |
174 | table.insert(LevelPresets, levelPreset)
175 | end
176 | end
177 |
178 |
179 | abyss.log("info", "Finished loading definitions.")
180 | end
181 |
182 | function GetLevelPreset(levelId, presetId)
183 | for _, levelPreset in pairs(LevelPresets) do
184 | -- Town is special
185 | if (levelId == 1) and (levelPreset.levelId < 2) and (levelPreset.definitionId == presetId) then
186 | return levelPreset
187 | elseif levelPreset.definitionId == presetId then
188 | return levelPreset
189 | end
190 | end
191 |
192 | abyss.log("error", "Level Preset not found for level " .. levelId .. " and preset " .. presetId)
193 | end
194 |
--------------------------------------------------------------------------------
/common/interface/label.lua:
--------------------------------------------------------------------------------
1 | local Label = {}
2 | local Node = require("common/interface/node")
3 | Label.__index = Label
4 |
5 |
6 | function Label:new(data)
7 | local this = Node:new(data)
8 | function this:setAlignment(alignment)
9 | alignment = alignment or {"start", "start"}
10 | self.node:setAlignment(alignment[1],alignment[2])
11 | end
12 | local parent = data.parent
13 | local font = data.font
14 | local caption = data.caption
15 | local alignment = data.alignment
16 | local position = data.position
17 | this.node = abyss.createLabel(font)
18 | this:setPosition{position[1], position[2]}
19 | this.node.caption = caption
20 | this:setAlignment{alignment[1], alignment[2]}
21 | table.insert(parent.data, this.node)
22 | parent:appendChild(this.node)
23 | setmetatable(Label, Label)
24 | return this
25 | end
26 |
27 | return Label
--------------------------------------------------------------------------------
/common/interface/node.lua:
--------------------------------------------------------------------------------
1 | local Node = {}
2 | Node.__index = Node
3 |
4 | function Node:new(data)
5 | local this = {}
6 | function Node:setPosition(position)
7 | position = position or {0, 0}
8 | this.node:setPosition( math.floor(position[1]), math.floor(position[2]) )
9 | end
10 | if data.node ~= nil and type(data.node) == "userdata" then
11 | this.node = data.node
12 | return this
13 | end
14 | setmetatable(this, self)
15 | return this
16 | end
17 |
18 | return Node
--------------------------------------------------------------------------------
/common/json.lua:
--------------------------------------------------------------------------------
1 | -- https://github.com/rxi/json.lua
2 | -- commit dbf4b2dd2eb7c23be2773c89eb059dadd6436f94
3 | --
4 | -- json.lua
5 | --
6 | -- Copyright (c) 2020 rxi
7 | --
8 | -- Permission is hereby granted, free of charge, to any person obtaining a copy of
9 | -- this software and associated documentation files (the "Software"), to deal in
10 | -- the Software without restriction, including without limitation the rights to
11 | -- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 | -- of the Software, and to permit persons to whom the Software is furnished to do
13 | -- so, subject to the following conditions:
14 | --
15 | -- The above copyright notice and this permission notice shall be included in all
16 | -- copies or substantial portions of the Software.
17 | --
18 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | -- SOFTWARE.
25 | --
26 |
27 | local json = { _version = "0.1.2" }
28 |
29 | -------------------------------------------------------------------------------
30 | -- Encode
31 | -------------------------------------------------------------------------------
32 |
33 | local encode
34 |
35 | local escape_char_map = {
36 | [ "\\" ] = "\\",
37 | [ "\"" ] = "\"",
38 | [ "\b" ] = "b",
39 | [ "\f" ] = "f",
40 | [ "\n" ] = "n",
41 | [ "\r" ] = "r",
42 | [ "\t" ] = "t",
43 | }
44 |
45 | local escape_char_map_inv = { [ "/" ] = "/" }
46 | for k, v in pairs(escape_char_map) do
47 | escape_char_map_inv[v] = k
48 | end
49 |
50 |
51 | local function escape_char(c)
52 | return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte()))
53 | end
54 |
55 |
56 | local function encode_nil(val)
57 | return "null"
58 | end
59 |
60 |
61 | local function encode_table(val, stack)
62 | local res = {}
63 | stack = stack or {}
64 |
65 | -- Circular reference?
66 | if stack[val] then error("circular reference") end
67 |
68 | stack[val] = true
69 |
70 | if rawget(val, 1) ~= nil or next(val) == nil then
71 | -- Treat as array -- check keys are valid and it is not sparse
72 | local n = 0
73 | for k in pairs(val) do
74 | if type(k) ~= "number" then
75 | error("invalid table: mixed or invalid key types")
76 | end
77 | n = n + 1
78 | end
79 | if n ~= #val then
80 | error("invalid table: sparse array")
81 | end
82 | -- Encode
83 | for i, v in ipairs(val) do
84 | table.insert(res, encode(v, stack))
85 | end
86 | stack[val] = nil
87 | return "[" .. table.concat(res, ",") .. "]"
88 |
89 | else
90 | -- Treat as an object
91 | for k, v in pairs(val) do
92 | if type(k) ~= "string" then
93 | error("invalid table: mixed or invalid key types")
94 | end
95 | table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
96 | end
97 | stack[val] = nil
98 | return "{" .. table.concat(res, ",") .. "}"
99 | end
100 | end
101 |
102 |
103 | local function encode_string(val)
104 | return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
105 | end
106 |
107 |
108 | local function encode_number(val)
109 | -- Check for NaN, -inf and inf
110 | if val ~= val or val <= -math.huge or val >= math.huge then
111 | error("unexpected number value '" .. tostring(val) .. "'")
112 | end
113 | return string.format("%.14g", val)
114 | end
115 |
116 |
117 | local type_func_map = {
118 | [ "nil" ] = encode_nil,
119 | [ "table" ] = encode_table,
120 | [ "string" ] = encode_string,
121 | [ "number" ] = encode_number,
122 | [ "boolean" ] = tostring,
123 | }
124 |
125 |
126 | encode = function(val, stack)
127 | local t = type(val)
128 | local f = type_func_map[t]
129 | if f then
130 | return f(val, stack)
131 | end
132 | error("unexpected type '" .. t .. "'")
133 | end
134 |
135 |
136 | function json.encode(val)
137 | return ( encode(val) )
138 | end
139 |
140 |
141 | -------------------------------------------------------------------------------
142 | -- Decode
143 | -------------------------------------------------------------------------------
144 |
145 | local parse
146 |
147 | local function create_set(...)
148 | local res = {}
149 | for i = 1, select("#", ...) do
150 | res[ select(i, ...) ] = true
151 | end
152 | return res
153 | end
154 |
155 | local space_chars = create_set(" ", "\t", "\r", "\n")
156 | local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
157 | local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
158 | local literals = create_set("true", "false", "null")
159 |
160 | local literal_map = {
161 | [ "true" ] = true,
162 | [ "false" ] = false,
163 | [ "null" ] = nil,
164 | }
165 |
166 |
167 | local function next_char(str, idx, set, negate)
168 | for i = idx, #str do
169 | if set[str:sub(i, i)] ~= negate then
170 | return i
171 | end
172 | end
173 | return #str + 1
174 | end
175 |
176 |
177 | local function decode_error(str, idx, msg)
178 | local line_count = 1
179 | local col_count = 1
180 | for i = 1, idx - 1 do
181 | col_count = col_count + 1
182 | if str:sub(i, i) == "\n" then
183 | line_count = line_count + 1
184 | col_count = 1
185 | end
186 | end
187 | error( string.format("%s at line %d col %d", msg, line_count, col_count) )
188 | end
189 |
190 |
191 | local function codepoint_to_utf8(n)
192 | -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
193 | local f = math.floor
194 | if n <= 0x7f then
195 | return string.char(n)
196 | elseif n <= 0x7ff then
197 | return string.char(f(n / 64) + 192, n % 64 + 128)
198 | elseif n <= 0xffff then
199 | return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
200 | elseif n <= 0x10ffff then
201 | return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
202 | f(n % 4096 / 64) + 128, n % 64 + 128)
203 | end
204 | error( string.format("invalid unicode codepoint '%x'", n) )
205 | end
206 |
207 |
208 | local function parse_unicode_escape(s)
209 | local n1 = tonumber( s:sub(1, 4), 16 )
210 | local n2 = tonumber( s:sub(7, 10), 16 )
211 | -- Surrogate pair?
212 | if n2 then
213 | return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
214 | else
215 | return codepoint_to_utf8(n1)
216 | end
217 | end
218 |
219 |
220 | local function parse_string(str, i)
221 | local res = ""
222 | local j = i + 1
223 | local k = j
224 |
225 | while j <= #str do
226 | local x = str:byte(j)
227 |
228 | if x < 32 then
229 | decode_error(str, j, "control character in string")
230 |
231 | elseif x == 92 then -- `\`: Escape
232 | res = res .. str:sub(k, j - 1)
233 | j = j + 1
234 | local c = str:sub(j, j)
235 | if c == "u" then
236 | local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1)
237 | or str:match("^%x%x%x%x", j + 1)
238 | or decode_error(str, j - 1, "invalid unicode escape in string")
239 | res = res .. parse_unicode_escape(hex)
240 | j = j + #hex
241 | else
242 | if not escape_chars[c] then
243 | decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string")
244 | end
245 | res = res .. escape_char_map_inv[c]
246 | end
247 | k = j + 1
248 |
249 | elseif x == 34 then -- `"`: End of string
250 | res = res .. str:sub(k, j - 1)
251 | return res, j + 1
252 | end
253 |
254 | j = j + 1
255 | end
256 |
257 | decode_error(str, i, "expected closing quote for string")
258 | end
259 |
260 |
261 | local function parse_number(str, i)
262 | local x = next_char(str, i, delim_chars)
263 | local s = str:sub(i, x - 1)
264 | local n = tonumber(s)
265 | if not n then
266 | decode_error(str, i, "invalid number '" .. s .. "'")
267 | end
268 | return n, x
269 | end
270 |
271 |
272 | local function parse_literal(str, i)
273 | local x = next_char(str, i, delim_chars)
274 | local word = str:sub(i, x - 1)
275 | if not literals[word] then
276 | decode_error(str, i, "invalid literal '" .. word .. "'")
277 | end
278 | return literal_map[word], x
279 | end
280 |
281 |
282 | local function parse_array(str, i)
283 | local res = {}
284 | local n = 1
285 | i = i + 1
286 | while 1 do
287 | local x
288 | i = next_char(str, i, space_chars, true)
289 | -- Empty / end of array?
290 | if str:sub(i, i) == "]" then
291 | i = i + 1
292 | break
293 | end
294 | -- Read token
295 | x, i = parse(str, i)
296 | res[n] = x
297 | n = n + 1
298 | -- Next token
299 | i = next_char(str, i, space_chars, true)
300 | local chr = str:sub(i, i)
301 | i = i + 1
302 | if chr == "]" then break end
303 | if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
304 | end
305 | return res, i
306 | end
307 |
308 |
309 | local function parse_object(str, i)
310 | local res = {}
311 | i = i + 1
312 | while 1 do
313 | local key, val
314 | i = next_char(str, i, space_chars, true)
315 | -- Empty / end of object?
316 | if str:sub(i, i) == "}" then
317 | i = i + 1
318 | break
319 | end
320 | -- Read key
321 | if str:sub(i, i) ~= '"' then
322 | decode_error(str, i, "expected string for key")
323 | end
324 | key, i = parse(str, i)
325 | -- Read ':' delimiter
326 | i = next_char(str, i, space_chars, true)
327 | if str:sub(i, i) ~= ":" then
328 | decode_error(str, i, "expected ':' after key")
329 | end
330 | i = next_char(str, i + 1, space_chars, true)
331 | -- Read value
332 | val, i = parse(str, i)
333 | -- Set
334 | res[key] = val
335 | -- Next token
336 | i = next_char(str, i, space_chars, true)
337 | local chr = str:sub(i, i)
338 | i = i + 1
339 | if chr == "}" then break end
340 | if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
341 | end
342 | return res, i
343 | end
344 |
345 |
346 | local char_func_map = {
347 | [ '"' ] = parse_string,
348 | [ "0" ] = parse_number,
349 | [ "1" ] = parse_number,
350 | [ "2" ] = parse_number,
351 | [ "3" ] = parse_number,
352 | [ "4" ] = parse_number,
353 | [ "5" ] = parse_number,
354 | [ "6" ] = parse_number,
355 | [ "7" ] = parse_number,
356 | [ "8" ] = parse_number,
357 | [ "9" ] = parse_number,
358 | [ "-" ] = parse_number,
359 | [ "t" ] = parse_literal,
360 | [ "f" ] = parse_literal,
361 | [ "n" ] = parse_literal,
362 | [ "[" ] = parse_array,
363 | [ "{" ] = parse_object,
364 | }
365 |
366 |
367 | parse = function(str, idx)
368 | local chr = str:sub(idx, idx)
369 | local f = char_func_map[chr]
370 | if f then
371 | return f(str, idx)
372 | end
373 | decode_error(str, idx, "unexpected character '" .. chr .. "'")
374 | end
375 |
376 |
377 | function json.decode(str)
378 | if type(str) ~= "string" then
379 | error("expected argument of type string, got " .. type(str))
380 | end
381 | local res, idx = parse(str, next_char(str, 1, space_chars, true))
382 | idx = next_char(str, idx, space_chars, true)
383 | if idx <= #str then
384 | decode_error(str, idx, "trailing garbage")
385 | end
386 | return res
387 | end
388 |
389 |
390 | return json
391 |
--------------------------------------------------------------------------------
/common/language.lua:
--------------------------------------------------------------------------------
1 | --- Creates a new Language object.
2 | --- @class Language
3 | local Language = {}
4 | local _languageDefs = require('common/enum/language')
5 | local _code, _3code, _name, _strings
6 |
7 | local function loadJsonTranslations(filename)
8 | local path = '/data/local/lng/strings/' .. filename
9 | if not abyss.fileExists(path) then
10 | return
11 | end
12 | local json = ReadJsonAsTable(path)
13 | for _, data in ipairs(json) do
14 | _strings[data.Key] = data[_code]
15 | end
16 | end
17 |
18 | local function loadD2RStrings()
19 | --TODO load other json files from this directory
20 | loadJsonTranslations('ui.json')
21 | loadJsonTranslations('levels.json')
22 | end
23 |
24 | local function loadTblFile(path)
25 | local filename = Language:i18nPath(path)
26 | if not abyss.fileExists(filename) then
27 | abyss.log("warn", "Classic translation file not found: " .. filename)
28 | return
29 | end
30 | for key, value in pairs(abyss.loadTbl(filename)) do
31 | _strings[key] = value
32 | end
33 | end
34 |
35 | local function loadTblStrings()
36 | loadTblFile(ResourceDefs.StringTable)
37 | loadTblFile(ResourceDefs.ExpansionStringTable)
38 | loadTblFile(ResourceDefs.PatchStringTable)
39 | end
40 |
41 | --- Sets the language based on the name.
42 | --- @param code string # The language code, as used in D2R, e.g. "ruRU"
43 | function Language:setLanguage(code)
44 | _code = code
45 | _3code = _languageDefs.Language3Codes[code]
46 | _name = _languageDefs.LanguageNames[code]
47 | _strings = {}
48 |
49 | if _name == nil then
50 | abyss.log("warn", "Invalid language: " .. code .. ".")
51 | return
52 | end
53 |
54 | loadTblStrings()
55 | loadD2RStrings()
56 | -- just for case, because :translate() relies on this empty key not to exist for @#num to work
57 | _strings[''] = nil
58 | end
59 |
60 | --- Auto detect the langauge based on files in the path
61 | function Language:autoDetect()
62 | for langCode, _ in pairs(_languageDefs.LanguageNames) do
63 | if abyss.fileExists("/data/local/ui/" .. _languageDefs.Language3Codes[langCode] .. "/2dsound.dc6") then
64 | Language:setLanguage(langCode)
65 | return
66 | end
67 | end
68 | Language:setLanguage("enUS")
69 | end
70 |
71 | function Language:code3()
72 | return _3code
73 | end
74 |
75 | function Language:name()
76 | return _name
77 | end
78 |
79 | function Language:code()
80 | return _code
81 | end
82 |
83 | -- Takes string which contains things such as "@foo","@bar#nnn" or "@#nnn" and
84 | -- replaces it with their translation.
85 | -- nnn is the number; mostly it's for compatibility with MPQs, as not all keys there are strings.
86 | -- @text#nnn form uses text if available, and falls back to nnn
87 | -- numeric code only uses tbl files, text code tries json file first, then tbl,
88 | -- because the numeric code in json doesn't always match the numeric code in
89 | -- tbl, and some strings are only accessible in tbl via number
90 | --
91 | -- TODO consider automatically mapping the code to json too.
92 | -- So far, seems like numbers in the 5xxx range are the same, but numbers in
93 | -- 2xxx range (from LOD expansion) are prepended with another 2, turning e.g.
94 | -- 2519 into 22519 in json
95 | local _translatePattern
96 | function Language:translate(str)
97 | return _translatePattern:match(str)
98 | end
99 | local function _createTranslatePattern()
100 | local P = lpeg.P
101 | local C = lpeg.C
102 | local Cs = lpeg.Cs
103 | local R = lpeg.R
104 |
105 | local function replace(code, num)
106 | local result = _strings[code]
107 | if result ~= nil then
108 | return result
109 | end
110 | result = _strings[num]
111 | if result ~= nil then
112 | return result
113 | end
114 | return '??@' .. code .. '#' .. num .. '??'
115 | end
116 | local letter = R'az' + R'AZ' + R'09'
117 | local token = P'@' * C(letter^0) * C(P'#' * R'09'^0)^-1
118 | return Cs((token / replace + 1)^0)
119 | end
120 | _translatePattern = _createTranslatePattern()
121 |
122 | function Language:hdaudioPath(originalPath)
123 | if _code == "enUS" then
124 | return originalPath
125 | else
126 | return "/locales/audio/" .. _code .. originalPath
127 | end
128 | end
129 |
130 | --- Converts a language-specific path to the actual path based on the current language.
131 | --- @param originalPath string # The path to convert.
132 | --- @return string # The converted path.
133 | function Language:i18nPath(originalPath)
134 | local path = originalPath:gsub("{LANG_FONT}", or_else(_languageDefs.LanguageFontNames[_code], 'LATIN'))
135 | path = path:gsub("{LANG}", or_else(_3code, 'eng'))
136 | return path
137 | end
138 |
139 | return Language
140 |
--------------------------------------------------------------------------------
/common/layout.lua:
--------------------------------------------------------------------------------
1 | local RESOLUTION_X = 800
2 | local RESOLUTION_Y = 600
3 | local LOWEND_HD = true
4 |
5 | local _profileSD
6 | local _profileHD
7 | local _globalDataSD
8 | local _globalDataHD
9 |
10 | local LayoutLoader = {
11 | }
12 | LayoutLoader.__index = LayoutLoader
13 |
14 | function LayoutLoader:new()
15 | local this = {}
16 | setmetatable(this, self)
17 | this:initialize() -- Init the _new_ loader not the parent object
18 | return this
19 | end
20 |
21 | local LAYOUTS_DIR = '/data/global/ui/layouts/'
22 |
23 | local SD_FONTS = {
24 | ["10ptE"] = SystemFonts.FntExocet10,
25 | ["8ptE"] = SystemFonts.FntExocet8,
26 | ["30pt"] = SystemFonts.Fnt30,
27 | ["16pt"] = SystemFonts.Fnt16,
28 | ["6pt"] = SystemFonts.FntSucker,
29 | ["12ptF"] = SystemFonts.FntFormal12,
30 | ["11ptF"] = SystemFonts.FntFormal11,
31 | }
32 |
33 | local HD_FONT
34 |
35 | local function loadFont(fontType, hd)
36 | if hd then
37 | if HD_FONT == nil then
38 | HD_FONT = abyss.createTtfFont('/data/hd/ui/fonts/Formal436bt.ttf', 16, 'none')
39 | end
40 | return HD_FONT
41 | -- TODO use LanguageFontRemapper from GlobalData
42 | -- /data/hd/ui/fonts/Formal436bt.ttf
43 | -- /data/hd/ui/fonts/ExocetBlizzardOT-Medium.otf
44 | -- /data/hd/ui/fonts/BlizzardGlobal-v5_81.ttf
45 | -- etc
46 | end
47 | return SD_FONTS[fontType]
48 | end
49 |
50 | local function defaultFontColor(fontType)
51 | if fontType == "30pt" then
52 | return { r = 199, g = 179, b = 119 }
53 | end
54 | return { r = 0xFF, g = 0xFF, b = 0xFF }
55 | end
56 |
57 | local function imageFilename(image, hd)
58 | if image:sub(1, 1) == '\\' then
59 | image = image:sub(2)
60 | end
61 | if hd then
62 | if LOWEND_HD then
63 | return '/data/hd/global/ui/' .. image .. '.lowend.sprite'
64 | else
65 | return '/data/hd/global/ui/' .. image .. '.sprite'
66 | end
67 | else
68 | return '/data/global/ui/' .. image .. '.dc6'
69 | end
70 | end
71 |
72 | -- http://lua-users.org/wiki/CopyTable
73 | local function deepcopy(orig)
74 | local orig_type = type(orig)
75 | local copy
76 | if orig_type == 'table' then
77 | copy = {}
78 | for orig_key, orig_value in next, orig, nil do
79 | copy[deepcopy(orig_key)] = deepcopy(orig_value)
80 | end
81 | setmetatable(copy, deepcopy(getmetatable(orig)))
82 | else -- number, string, boolean, etc
83 | copy = orig
84 | end
85 | return copy
86 | end
87 |
88 | -- recursively replaces references to $variables in profile with their values
89 | local function resolveDataReferences(object, profile)
90 | local replace = {}
91 | local again = false
92 | for key, value in pairs(object) do
93 | if type(value) == 'table' then
94 | again = resolveDataReferences(value, profile) or again
95 | else
96 | if type(value) == 'string' and value:sub(1, 1) == '$' then
97 | replace[key] = profile[value:sub(2)]
98 | again = true
99 | end
100 | end
101 | end
102 | for key, value in pairs(replace) do
103 | object[key] = value
104 | end
105 | return again
106 | end
107 |
108 | -- reads profile file as lua table, following the parents link and merging them
109 | local function readProfile(name)
110 | local start = ReadJsonAsTable(LAYOUTS_DIR .. '_profile' .. name .. '.json')
111 | if start.basedOn == nil then
112 | return start
113 | end
114 | local parent = readProfile(start.basedOn)
115 | for key, value in pairs(start) do
116 | parent[key] = value
117 | end
118 | return parent
119 | end
120 |
121 | -- reads profile file as lua table and resolves all the variable names
122 | local function readResolvedProfile(name)
123 | local profile = readProfile(name)
124 | while resolveDataReferences(profile, profile) do
125 | end
126 | return profile
127 | end
128 |
129 | local function shallowMergeTables(overrides, parent)
130 | local merged = or_else(parent, {})
131 | for key, value in pairs(or_else(overrides, {})) do
132 | merged[key] = value
133 | end
134 | return merged
135 | end
136 |
137 | local function mergeFromParent(layout, parent)
138 | layout.fields = shallowMergeTables(layout.fields, parent.fields)
139 | if layout.children ~= nil and parent.children ~= nil then
140 | local otherChildren = {}
141 | for _, child in ipairs(parent.children) do
142 | if child.name ~= nil then
143 | otherChildren[child.name] = child
144 | end
145 | end
146 | for _, child in ipairs(layout.children) do
147 | if child.name ~= nil then
148 | local brother = otherChildren[child.name]
149 | if brother ~= nil then
150 | mergeFromParent(child, brother)
151 | end
152 | end
153 | end
154 | end
155 | end
156 |
157 | -- reads layout file as lua table, following the parents link and merging them
158 | local function readLayout(name)
159 | local data = ReadJsonAsTable(LAYOUTS_DIR .. name)
160 | if data.basedOn ~= nil then
161 | local parent = readLayout(data.basedOn)
162 | mergeFromParent(data, parent)
163 | end
164 | return data
165 | end
166 |
167 | local function resolveReferences(layout, profile)
168 | if layout.fields ~= nil then
169 | resolveDataReferences(layout.fields, profile)
170 | end
171 | if layout.children ~= nil then
172 | for _, child in pairs(layout.children) do
173 | resolveReferences(child, profile)
174 | end
175 | end
176 | end
177 |
178 | local function move_by(node, rect)
179 | if rect == nil then
180 | return
181 | end
182 | local x, y = node:getPosition()
183 | local dx = or_else(rect.x, 0)
184 | local dy = or_else(rect.y, 0)
185 | if hd and LOWEND_HD then
186 | -- TODO debug this
187 | dx = math.floor(dx / 2)
188 | dy = math.floor(dy / 2)
189 | end
190 | node:setPosition(x + dx, y + dy)
191 | end
192 |
193 | local ALIGN_MAPPING = {
194 | fit = "middle", -- TODO
195 | center = "middle",
196 | left = "start",
197 | right = "end",
198 | top = "start",
199 | bottom = "end",
200 | }
201 |
202 | local TYPES = {
203 | SDHeadsUpPanel = function(layout, hd, palette)
204 | local node = abyss.createNode()
205 | local bg_image = abyss.loadImage(imageFilename(layout.fields.background800, hd), palette)
206 | local bg_pieces = {}
207 | for i, off in ipairs(layout.fields.background800Offsets) do
208 | local piece = abyss.createSprite(bg_image)
209 | piece.bottomOrigin = true
210 | piece.currentFrameIndex = i - 1
211 | piece:setPosition(off, layout.fields.rect.height)
212 | table.insert(bg_pieces, piece)
213 | node:appendChild(piece)
214 | end
215 | node.data.bg_pieces = bg_pieces
216 | node.data.bg_image = bg_image
217 | if layout.fields.rect.x == nil then
218 | layout.fields.rect.x = math.floor(-RESOLUTION_X / 2)
219 | end
220 | return node, function()
221 | move_by(node.data.children.QuestAlert, layout.fields.questAlert800Offset)
222 |
223 | --TODO use anchor
224 | local _, y = node.data.children.Right:getPosition()
225 | node.data.children.Right:setPosition(RESOLUTION_X - node.data.children.Right.data.layout.fields.rect.width, y)
226 |
227 | move_by(node.data.children.Middle, { x = math.floor((RESOLUTION_X - node.data.children.Middle.data.layout.fields.rect.width) / 2) })
228 | end
229 | end,
230 |
231 | HUDPanelHD = function(layout)
232 | local node = abyss.createNode()
233 | return node, function()
234 | --TODO use anchor
235 | node:setPosition(math.floor(RESOLUTION_X / 2 - layout.fields.rect.width / 4 + (layout.fields.rect.width + layout.fields.rect.x * 2)/4), RESOLUTION_Y + math.floor(layout.fields.rect.y / 2 ))
236 | end
237 | end,
238 |
239 | Widget = function(layout)
240 | return abyss.createNode()
241 | end,
242 |
243 | ImageWidget = function(layout, hd, palette)
244 | return CreateUniqueSpriteFromFile(imageFilename(layout.fields.filename, hd), palette)
245 | end,
246 |
247 | AnimatedImageWidget = function(layout, hd, palette)
248 | local sprite = CreateUniqueSpriteFromFile(imageFilename(layout.fields.filename, hd), palette)
249 | --TODO fps
250 | sprite.playMode = "forwards"
251 | sprite.bottomOrigin = true
252 | local num = sprite.data.img:getNumberOfFrames()
253 | local maxh = 0
254 | for i = 0, num-1 do
255 | local w, h = sprite.data.img:getFrameSize(0, 1)
256 | maxh = math.max(maxh, h)
257 | end
258 | if layout.fields.blendMode == "black" then
259 | sprite.blendMode = "additive"
260 | end
261 | return sprite, function()
262 | move_by(sprite, {y=maxh})
263 | end
264 | end,
265 |
266 | LevelUpButtonWidget = function(layout, hd, palette)
267 | local image = abyss.loadImage(imageFilename(layout.fields.filename, hd), palette)
268 | local node = abyss.createButton(image)
269 | node.data.image = image
270 | node:setSegments(1, 1)
271 | node:setFrameIndex("pressed", 1)
272 | node:setFrameIndex("disabled", layout.fields.disabledFrame)
273 | local w, h = image:getFrameSize(0, 1)
274 | node:setFixedSize(w, h)
275 | return node
276 | end,
277 |
278 | RunButtonWidget = function(layout, hd, palette)
279 | local image = abyss.loadImage(imageFilename(layout.fields.filename, hd), palette)
280 | local node = abyss.createButton(image)
281 | node.data.image = image
282 | node:setSegments(1, 1)
283 | node:setFrameIndex("pressed", 1)
284 | local w, h = image:getFrameSize(0, 1)
285 | node:setFixedSize(w, h)
286 | return node
287 | end,
288 |
289 | TextBoxWidget = function(layout)
290 | local fontType = or_else(layout.fields.fontType, "16pt")
291 | local label = abyss.createLabel(loadFont(fontType))
292 | label.caption = Language:translate(or_else(layout.fields.text, 'text'))
293 | if or_else(layout.fields.style.options, {}).lineWrap then
294 | label.maxWidth = layout.fields.rect.width
295 | end
296 | local align = or_else(layout.fields.style.alignment, {})
297 | local hAlign = or_else(align.h, "left")
298 | local vAlign = or_else(align.v, "top")
299 | label:setAlignment(ALIGN_MAPPING[hAlign], ALIGN_MAPPING[vAlign])
300 | local color = layout.fields.style.fontColor
301 | if color == nil then
302 | color = defaultFontColor(fontType)
303 | end
304 | label:setColorMod(color.r, color.g, color.b)
305 | return label, function()
306 | if align.h == "center" then
307 | move_by(label, {x=math.floor(layout.fields.rect.width/2)})
308 | end
309 | if align.v == "center" then
310 | move_by(label, {y=math.floor(layout.fields.rect.height/2)})
311 | end
312 | end
313 | end,
314 |
315 | SkillSelectButtonWidget = function(layout, hd, palette)
316 | local node = abyss.createNode()
317 | -- TODO which one? maybe create all of them and control the active one via active/visible prop
318 | local fname = layout.fields.skillIconFilenames[2]
319 | local image = abyss.loadImage(imageFilename(fname, hd), palette)
320 | node.data.image = image
321 | local button = abyss.createButton(image)
322 | button:setSegments(1, 1)
323 | local w, h = image:getFrameSize(0, 1)
324 | button:setFixedSize(w, h)
325 | node.data.button = button
326 | node:appendChild(button)
327 | return node
328 | end,
329 |
330 | ButtonWidget = function(layout, hd, palette)
331 | local image = abyss.loadImage(imageFilename(layout.fields.filename, hd), palette)
332 | local button = abyss.createButton(image)
333 | button.data.image = image
334 | local normalFrame = or_else(layout.fields.normalFrame, 0)
335 | button:setFrameIndex("normal", normalFrame)
336 | button:setFrameIndex("pressed", or_else(layout.fields.pressedFrame, 1))
337 | button:setSegments(1, 1)
338 | local w, h = image:getFrameSize(normalFrame, 1)
339 | button:setFixedSize(w, h)
340 | if layout.fields.textString ~= nil then
341 | local w, h = image:getFrameSize(normalFrame, 1)
342 | local label = abyss.createLabel(loadFont(layout.fields.fontType, hd))
343 | label:setPosition(math.floor(w/2), math.floor(h/2))
344 | if SpriteFontIsActuallyTTF then
345 | label.caption = '' .. Language:translate(layout.fields.textString) .. ''
346 | else
347 | label.caption = Language:translate(layout.fields.textString)
348 | end
349 | label:setAlignment("middle", "middle")
350 | button:appendChild(label)
351 | local color = layout.fields.textColor
352 | if color ~= nil then
353 | if SpriteFontIsActuallyTTF then
354 | -- TODO figure something out
355 | label:setColorMod(0, 0, 0)
356 | else
357 | label:setColorMod(color.r, color.g, color.b)
358 | end
359 | end
360 | button.data.label = label
361 | button:setPressedOffset(-2, 2)
362 | end
363 | return button
364 | end,
365 |
366 | MiniMenuButtonWidget = function(layout, hd, palette)
367 | local button = CreateUniqueSpriteFromFile(imageFilename(layout.fields.filename, hd), palette)
368 | -- TODO hoveredFrame statusUpdateNormalFrame etc
369 | return button
370 | end,
371 |
372 | AttributeBallWidget = function(layout, hd, palette)
373 | if layout.fields.filename == nil then
374 | return abyss.createNode()
375 | end
376 | return CreateUniqueSpriteFromFile(imageFilename(layout.fields.filename, hd), palette)
377 | end,
378 |
379 | GridImageWidget = function(layout, hd, palette)
380 | local sprite = CreateUniqueSpriteFromFile(imageFilename(layout.fields.filename, hd), palette)
381 | sprite.currentFrameIndex = or_else(layout.fields.frame, 0)
382 | sprite:setCellSize(math.floor(layout.fields.frames / layout.fields.rows), layout.fields.rows)
383 | return sprite
384 | end,
385 |
386 | InventorySlotWidget = function(layout, hd, palette)
387 | local sprite = CreateUniqueSpriteFromFile(imageFilename(layout.fields.backgroundFilename, hd), palette)
388 | sprite.currentFrameIndex = or_else(layout.fields.backgroundFrame, 0)
389 | return sprite, function()
390 | move_by(sprite, layout.fields.backgroundOffset)
391 | --TODO skip this if the first set is selected
392 | move_by(sprite, layout.fields.swappedOffset)
393 | end
394 | end,
395 |
396 | CharacterCreateWidget = function(layout, hd, palette)
397 | local character = abyss.createNode()
398 | local states = {'base', 'onHover', 'onSelect', 'onUnselect', 'selected'}
399 | for _, name in ipairs(states) do
400 | local animDesc = layout.fields.stateAnimations[name]
401 | local fullImage = abyss.createNode()
402 | local base = CreateUniqueSpriteFromFile(imageFilename(animDesc.basePath, hd), palette)
403 | fullImage:appendChild(base)
404 | fullImage.data.base = base
405 | base.playMode = "forwards"
406 | base.bottomOrigin = true
407 | if name == 'onSelect' or name == 'onUnselect' then
408 | base.loopAnimation = false
409 | end
410 | if animDesc.overlayPath ~= nil then
411 | local overlay = CreateUniqueSpriteFromFile(imageFilename(animDesc.overlayPath, hd), palette)
412 | fullImage:appendChild(overlay)
413 | fullImage.data.overlay = overlay
414 | overlay.playMode = "forwards"
415 | overlay.bottomOrigin = true
416 | if animDesc.overlayBlendMode == "black" then
417 | overlay.blendMode = "additive"
418 | end
419 | if name == 'onSelect' or name == 'onUnselect' then
420 | overlay.loopAnimation = false
421 | end
422 | end
423 | -- TODO: use speedMultiplier field
424 | character.data[name] = fullImage
425 | character:appendChild(fullImage)
426 | fullImage.active = false
427 | character.data.state = 'base'
428 | end
429 | local function setState(state)
430 | character.data.state = state
431 | for _, name in ipairs(states) do
432 | if name == state then
433 | character.data[name].active = true
434 | character.data[name].data.base.currentFrameIndex = 0
435 | if character.data[name].data.overlay ~= nil then
436 | character.data[name].data.overlay.currentFrameIndex = 0
437 | end
438 | else
439 | character.data[name].active = false
440 | end
441 | end
442 | end
443 | local sfxSelect = LoadSoundEffect('cursor_' .. layout.name:lower() .. '_select')
444 | local sfxUnselect = LoadSoundEffect('cursor_' .. layout.name:lower() .. '_deselect')
445 | -- druid and assassin didn't have the sounds.txt records before d2r
446 | if sfxSelect == nil then
447 | sfxSelect = abyss.createSoundEffect("/data/global/sfx/Cursor/intro/" .. layout.name:lower() .. " select.wav")
448 | end
449 | if sfxUnselect == nil then
450 | sfxUnselect = abyss.createSoundEffect("/data/global/sfx/Cursor/intro/" .. layout.name:lower() .. " deselect.wav")
451 | end
452 | local finishAnimationCb = function() end
453 | character.data.onSelect.data.base:onAnimationFinished(function()
454 | setState('selected')
455 | finishAnimationCb()
456 | finishAnimationCb = function() end
457 | end)
458 | character.data.onUnselect.data.base:onAnimationFinished(function()
459 | setState('base')
460 | finishAnimationCb()
461 | finishAnimationCb = function() end
462 | end)
463 | character.data.base.active = true
464 | character.data.gotoSelect = function(cb)
465 | if character.data.state == 'base' then
466 | finishAnimationCb = cb
467 | sfxSelect:play()
468 | setState('onSelect')
469 | else
470 | cb()
471 | end
472 | end
473 | character.data.gotoUnselect = function(cb)
474 | if character.data.state == 'base' then
475 | cb()
476 | else
477 | finishAnimationCb = cb
478 | sfxUnselect:play()
479 | setState('onUnselect')
480 | end
481 | end
482 | return character
483 | end,
484 |
485 | CharacterCreateContainerWidget = function(layout, hd, palette)
486 | local input = abyss.createInputListener()
487 | input.data.onUpdateSelected = function() end
488 | input.data.onUpdateHover = function() end
489 | return input, function()
490 | local classes = {}
491 | for name, child in pairs(input.data.children) do
492 | table.insert(classes, name)
493 | end
494 | table.sort(classes, function(a, b)
495 | local ax = input.data.children[a].data.layout.fields.rect.x
496 | local bx = input.data.children[b].data.layout.fields.rect.x
497 | return ax < bx
498 | end)
499 | local selectedClass
500 | local overClass
501 | input:onMouseMove(function(x, y)
502 | -- FIXME inputlistener should do the X Y offset
503 | x = x - RESOLUTION_X / 2
504 | -- every stated number is somewhere in middle of character
505 | x = x + RESOLUTION_X / #classes / 2
506 | overClass = nil
507 | if y > RESOLUTION_Y / 3 and y < RESOLUTION_Y * 2 / 3 then
508 | for i = #classes, 1, -1 do
509 | -- TODO this logic makes all the right of the druid to be druid
510 | if x > input.data.children[classes[i]].data.layout.fields.rect.x then
511 | overClass = classes[i]
512 | break
513 | end
514 | end
515 | end
516 | for i = 1, #classes do
517 | local overThis = overClass == classes[i]
518 | if input.data.children[classes[i]].data.state == 'base' then
519 | input.data.children[classes[i]].data.base.active = not overThis
520 | input.data.children[classes[i]].data.onHover.active = overThis
521 | end
522 | end
523 | input.data.onUpdateHover(overClass)
524 | end)
525 | local inputBlocked = 0
526 | input:onMouseButton(function(button, isPressed)
527 | if not isPressed then return end
528 | -- only left button
529 | if button ~= 1 then return end
530 | if overClass == nil then return end
531 | if inputBlocked > 0 then return end
532 | for i = 1, #classes do
533 | if overClass == classes[i] then
534 | if selectedClass == overClass then
535 | selectedClass = nil
536 | input.data.onUpdateSelected(selectedClass)
537 | inputBlocked = inputBlocked + 1
538 | input.data.children[classes[i]].data.gotoUnselect(function()
539 | inputBlocked = inputBlocked - 1
540 | end)
541 | else
542 | selectedClass = overClass
543 | input.data.onUpdateSelected(selectedClass)
544 | inputBlocked = inputBlocked + 1
545 | input.data.children[classes[i]].data.gotoSelect(function()
546 | inputBlocked = inputBlocked - 1
547 | end)
548 | end
549 | else
550 | inputBlocked = inputBlocked + 1
551 | input.data.children[classes[i]].data.gotoUnselect(function()
552 | inputBlocked = inputBlocked - 1
553 | end)
554 | end
555 | end
556 | end)
557 | end
558 | end,
559 |
560 | CharacterCreatePanel = function(layout, hd, palette)
561 | local node = abyss.createNode()
562 | return node, function()
563 | local descriptions = {
564 | Amazon = '@strAmazonDesc#5128',
565 | Necromancer = '@strNecroDesc#5129',
566 | Barbarian = '@strBarbDesc#5130',
567 | Sorceress = '@strSorcDesc#5131',
568 | Paladin = '@strPalDesc#5132',
569 | Druid = '@strDruDesc#2518',
570 | Assassin = '@strAssDesc#2519',
571 | }
572 | local selectedClass
573 | local function onHover(class)
574 | local detailsClass = or_else(selectedClass, class)
575 | if detailsClass == nil then
576 | node.data.children.ClassTitle.caption = ''
577 | node.data.children.ClassDescription.caption = ''
578 | else
579 | node.data.children.ClassTitle.caption = Language:translate('@' .. detailsClass)
580 | node.data.children.ClassDescription.caption = Language:translate(descriptions[detailsClass])
581 | end
582 | end
583 | local function onUpdate(class)
584 | selectedClass = class
585 | onHover(class)
586 | if class ~= nil then
587 | local names = layout.fields[class:lower() .. 'Names']
588 | node.data.children.InputText.caption = names[math.random(#names)]
589 | end
590 | local showOk = selectedClass ~= nil
591 | for _, name in ipairs({'ToGame', 'HardcoreLabel', 'HardcoreCheckbox', 'ExpansionLabel', 'ExpansionCheckbox', 'LadderLabel', 'LadderToggle', 'NameLabel', 'InputBackground', 'InputText'}) do
592 | if node.data.children[name] ~= nil then
593 | node.data.children[name].active = showOk
594 | end
595 | end
596 | end
597 | onUpdate(nil)
598 | -- TODO send message the other way around, without the panel reaching into the child
599 | node.data.children.CharacterContainer.data.onUpdateSelected = onUpdate
600 | node.data.children.CharacterContainer.data.onUpdateHover = onHover
601 | node.data.children.ToMainMenu:onActivate(function()
602 | SetScreen(Screen.CHARACTER_SELECTION)
603 | end)
604 | end
605 | end,
606 |
607 | InputTextBoxWidget = function(layout, hd, palette)
608 | -- TODO make it editable, use various fields from layout
609 | local label = abyss.createLabel(loadFont(layout.fields.fontType, hd))
610 | local align = or_else(layout.fields.fontStyle.alignment, {})
611 | local hAlign = or_else(align.h, "left")
612 | local vAlign = or_else(align.v, "top")
613 | label:setAlignment(ALIGN_MAPPING[hAlign], ALIGN_MAPPING[vAlign])
614 | return label
615 | end,
616 |
617 | ToggleButtonWidget = function(layout, hd, palette)
618 | local image = abyss.loadImage(imageFilename(layout.fields.filename, hd), palette)
619 | local button = abyss.createButton(image)
620 | button.data.image = image
621 | local toggledFrame = layout.fields.toggledFrame
622 | button:setFrameIndex("checkednormal", toggledFrame)
623 | button:setFrameIndex("checkedhover", toggledFrame)
624 | button:setFrameIndex("checkedpressed", toggledFrame)
625 | button.checked = or_else(layout.fields.isToggled, false)
626 | button:onActivate(function()
627 | button.checked = not button.checked
628 | end)
629 | button:setSegments(1, 1)
630 | local w, h = image:getFrameSize(0, 1)
631 | button:setFixedSize(w, h)
632 | return button
633 | end,
634 |
635 | QuestLogButtonWidget = function(layout, hd, palette)
636 | local sprite = CreateUniqueSpriteFromFile(imageFilename(layout.fields.filename, hd), palette)
637 | return sprite, function()
638 | move_by(sprite, {
639 | -- +1 because lua arrays index from 1
640 | x = layout.gridColumnPositions[layout.fields.gridPosition.x + 1],
641 | y = layout.gridRowPositions[layout.fields.gridPosition.y + 1],
642 | })
643 | end
644 | end,
645 |
646 | QuestLogPanel = function(layout, hd, palette)
647 | local function recurse(spec)
648 | if spec.type == 'QuestLogButtonWidget' then
649 | spec.gridColumnPositions = layout.fields.gridColumnPositions
650 | spec.gridRowPositions = layout.fields.gridRowPositions
651 | end
652 | if spec.children ~= nil then
653 | for _, child in ipairs(spec.children) do
654 | recurse(child)
655 | end
656 | end
657 | end
658 | recurse(layout)
659 | panel = abyss.createNode()
660 | return panel, function()
661 | -- Let's have Quest15 be selected for now
662 | local x, y = panel.data.children.Tab2.data.children.Quest15:getPosition()
663 | move_by(panel.data.children.TemplateSocket, {x = x, y = y})
664 | end
665 | end,
666 |
667 | TabBarWidget = function(layout, hd, palette)
668 | -- TODO make only the selected tab active
669 | local image = abyss.loadImage(imageFilename(layout.fields.filename, hd), palette)
670 | local bar = abyss.createNode()
671 | local x = 0
672 | bar.data.image = image
673 | bar.data.tabs = {}
674 | local activeTab = 3 -- why not; TODO
675 | for i = 1, layout.fields.tabCount do
676 | -- TODO some of these aren't active yet
677 | local tab = abyss.createSprite(image)
678 | table.insert(bar.data.tabs, tab)
679 | bar:appendChild(tab)
680 | if i == activeTab then
681 | tab.currentFrameIndex = layout.fields.activeFrames[i]
682 | else
683 | tab.currentFrameIndex = layout.fields.inactiveFrames[i]
684 | end
685 | if layout.fields.textStrings ~= nil then
686 | -- TODO hd uses different font
687 | local label = abyss.createLabel(SystemFonts.Fnt16)
688 | label.caption = Language:translate(layout.fields.textStrings[i])
689 | label:setAlignment('middle', 'middle')
690 | label:setPosition(math.floor(layout.fields.tabSize.x/2), math.floor(layout.fields.tabSize.y/2))
691 | if i == activeTab then
692 | label:setColorMod(199, 179, 119)
693 | else
694 | label:setColorMod(255, 255, 255)
695 | end
696 | tab.data.label = label
697 | tab:appendChild(label)
698 | end
699 | tab:setPosition(x, 0)
700 | x = x + layout.fields.tabSize.x + layout.fields.tabPadding.x
701 | end
702 | return bar
703 | end,
704 |
705 | -- Not real widgets
706 | GlobalData = function() return abyss.createNode() end,
707 | LanguageFontRemapper = function() return abyss.createNode() end,
708 | SpriteColoringHelper = function() return abyss.createNode() end,
709 | ShowItemsParameters = function() return abyss.createNode() end,
710 | }
711 | TYPES.MiniMenuToggleWidget = TYPES.ImageWidget
712 |
713 | local function translate(layout, hd, palette, parent)
714 | local outer = abyss.createNode()
715 | local type = TYPES[layout.type]
716 | local node = nil
717 | local postprocess = nil
718 | if type ~= nil then
719 | node, postprocess = type(layout, hd, palette)
720 | else
721 | abyss.log("warn", "Layout type not found: " .. layout.type)
722 | node = abyss.createNode()
723 | end
724 | outer.data.node = node
725 | outer:appendChild(node)
726 | node.data.layout = layout
727 | outer.data.layout = layout
728 | if layout.fields ~= nil then
729 | if layout.fields.anchor ~= nil then
730 | local anchor = layout.fields.anchor
731 | --TODO anchors for non-root
732 | if parent == nil then
733 | outer:setPosition(
734 | math.floor(or_else(anchor.x, 0) * RESOLUTION_X),
735 | math.floor(or_else(anchor.y, 0) * RESOLUTION_Y))
736 | else
737 | abyss.log("warn", "TODO anchor on non-root layout")
738 | end
739 | end
740 | if layout.fields.rect ~= nil then
741 | local rect = layout.fields.rect
742 | local x = or_else(rect.x, 0)
743 | local y = or_else(rect.y, 0)
744 | if hd and LOWEND_HD then
745 | x = math.floor(x / 2)
746 | y = math.floor(y / 2)
747 | end
748 | node:setPosition(x, y)
749 | end
750 | end
751 | if layout.children ~= nil then
752 | node.data.children = {}
753 | node.data.anonymous_children = {}
754 | local children = {}
755 | for _, child in ipairs(layout.children) do
756 | local childNode = translate(child, hd, palette, node)
757 | if child.name ~= nil then
758 | node.data.children[child.name] = childNode
759 | else
760 | table.insert(node.data.anonymous_children, childNode)
761 | end
762 | table.insert(children, childNode)
763 | node:appendChild(childNode)
764 | end
765 | -- add references to grandchildren
766 | -- Conflicts are resolved in this way:
767 | -- 1. name of direct child overrides everything
768 | -- 2. name of first grandchild found with this name (perhaps it should be last instead?)
769 | -- Grandgrandchild of first child overrides grandchild of second child
770 | -- I don't know whether this is the right order
771 | for _, child in ipairs(children) do
772 | if child.data.children ~= nil then
773 | for name, grandchild in pairs(child.data.children) do
774 | if node.data.children[name] == nil then
775 | node.data.children[name] = grandchild
776 | end
777 | end
778 | end
779 | end
780 | end
781 | if postprocess ~= nil then
782 | postprocess()
783 | end
784 | outer.data.children = node.data.children
785 | if layout.fields ~= nil and layout.fields.anchor ~= nil then
786 | return outer
787 | end
788 | -- TODO: don't create outer node in the first place if not necessary
789 | return node
790 | end
791 |
792 | function TYPES.WaypointsPanel(layout, hd, palette)
793 | local node = abyss.createNode()
794 | local function find_child(layout, name)
795 | for i, child in ipairs(layout.children) do
796 | if child.name == name then
797 | table.remove(layout.children, i)
798 | return child
799 | end
800 | end
801 | error('child ' .. name .. ' not found')
802 | end
803 | local templates = find_child(layout, 'Templates')
804 | local Unselectable = find_child(templates, 'UnselectableButtonTemplate')
805 | local SelectableButton = find_child(templates, 'SelectableButton')
806 | local CurrentButton = find_child(templates, 'CurrentButton')
807 | SelectableButton.fields = shallowMergeTables(SelectableButton.fields, deepcopy(Unselectable.fields))
808 | CurrentButton.fields = shallowMergeTables(CurrentButton.fields, deepcopy(Unselectable.fields))
809 | Unselectable.fields = shallowMergeTables(Unselectable.fields, deepcopy(SelectableButton.fields))
810 | return node, function()
811 | local current_button = math.random(5)
812 | local buttons_enabled = 7 -- TODO
813 | local y = 0
814 | node.data.buttons = {}
815 | for i = 1, 9 do
816 | local template = Unselectable
817 | if i < buttons_enabled then
818 | template = SelectableButton
819 | end
820 | if i == current_button then
821 | template = CurrentButton
822 | end
823 | local row = translate(template, hd, palette, node)
824 | -- TODO verify font
825 | local label = abyss.createLabel(SystemFonts.FntFormal12)
826 | label.caption = 'Waypoint N ' .. i
827 | label:setAlignment('start', 'middle')
828 | row:appendChild(label)
829 | row.data.label = label
830 | local textRect = deepcopy(template.fields['text/rect'])
831 | textRect.x = textRect.x - template.fields.rect.x
832 | move_by(label, textRect)
833 | local color
834 | if i < buttons_enabled then
835 | if i == current_button then
836 | row.currentFrameIndex = 0 -- TODO
837 | color = layout.fields.currentFontColor
838 | else
839 | row.currentFrameIndex = layout.fields.selectableFrames[1]
840 | color = layout.fields.selectableFontColor
841 | end
842 | else
843 | color = template.fields.textColor
844 | end
845 | label:setColorMod(color.r, color.g, color.b)
846 | move_by(row, {y=y})
847 | y = y + layout.fields.buttonOffset
848 | node:appendChild(row)
849 | table.insert(node.data.buttons, row)
850 | end
851 | end
852 | end
853 |
854 | function LayoutLoader:getProfileSD() return _profileSD end
855 | function LayoutLoader:getProfileHD() return _profileHD end
856 |
857 | function LayoutLoader:load(name, palette)
858 | local layout = readLayout(name)
859 | local hd = name:lower():match('hd.json$')
860 | resolveReferences(layout, cond(hd, _profileHD, _profileSD))
861 | return translate(layout, hd, palette)
862 | end
863 |
864 | function LayoutLoader:initialize()
865 | _profileSD = readResolvedProfile('sd')
866 | _profileHD = readResolvedProfile('hd')
867 | --TODO 'asian', 'lv' profiles
868 | _globalDataSD = self:load('GlobalData.json')
869 | _globalDataHD = self:load('GlobalDataHD.json')
870 | end
871 |
872 | return LayoutLoader
873 |
--------------------------------------------------------------------------------
/common/ui.lua:
--------------------------------------------------------------------------------
1 | function InitUI()
2 | local imgButtonTallBlank = abyss.loadImage(ResourceDefs.TallButtonBlank, ResourceDefs.Palette.Sky)
3 | local imgButtonWideBlank = abyss.loadImage(ResourceDefs.WideButtonBlank, ResourceDefs.Palette.Sky)
4 | local imgButtonShortBlank = abyss.loadImage(ResourceDefs.ShortButtonBlank, ResourceDefs.Palette.Sky)
5 | local imgButtonMediumBlank = abyss.loadImage(ResourceDefs.MediumButtonBlank, ResourceDefs.Palette.Sky)
6 | local imgCheckbox = abyss.loadImage(ResourceDefs.Checkbox, ResourceDefs.Palette.Fechar)
7 |
8 | TextColor = {
9 | --blackHalfOpacity = 0x0000007f
10 | LightBrown = { R = 188, G = 168, B = 140 },
11 | LightGreen = { R = 24, G = 255, B = 0 },
12 | White = { R = 255, G = 255, B = 255 },
13 | Black = { R = 0, G = 0, B = 0 },
14 | Yellowish = { R = 199, G = 179, B = 119 },
15 |
16 | }
17 |
18 | -- They use different blend mode
19 | local buttonTextColor = cond(SpriteFontIsActuallyTTF, TextColor.Black, TextColor.White )
20 |
21 | ButtonTypes = {
22 | Tall = {
23 | Font = SystemFonts.FntExocet10,
24 | Image = imgButtonTallBlank,
25 | Segments = { X = 1, Y = 1 },
26 | FixedSize = { X = 168, Y = 60 },
27 | TextColor = buttonTextColor,
28 | Wrap = true,
29 | FrameIndexes = { ["normal"] = 0, ["pressed"] = 1 }
30 | },
31 | Wide = {
32 | Font = SystemFonts.FntExocet10,
33 | Image = imgButtonWideBlank,
34 | Segments = { X = 2, Y = 1 },
35 | FixedSize = { X = 272, Y = 35 },
36 | TextColor = buttonTextColor,
37 | FrameIndexes = { ["normal"] = 0, ["pressed"] = 2 }
38 | },
39 | Medium = {
40 | Font = SystemFonts.FntExocet10,
41 | Image = imgButtonMediumBlank,
42 | Segments = { X = 1, Y = 1 },
43 | FixedSize = { X = 128, Y = 35 },
44 | TextColor = buttonTextColor,
45 | FrameIndexes = { ["normal"] = 0, ["pressed"] = 1 }
46 | },
47 | Short = {
48 | Font = SystemFonts.FntRidiculous,
49 | Image = imgButtonShortBlank,
50 | Segments = { X = 1, Y = 1 },
51 | FixedSize = { X = 135, Y = 25 },
52 | TextColor = buttonTextColor,
53 | FrameIndexes = { ["normal"] = 0, ["pressed"] = 1 }
54 | },
55 | Checkbox = {
56 | Font = SystemFonts.Fnt16,
57 | Image = imgCheckbox,
58 | Segments = { X = 1, Y = 1 },
59 | FixedSize = { X = 135, Y = 25 },
60 | TextOffset = { X = 20, Y = -1 },
61 | TextColor = TextColor.Yellowish,
62 | FrameIndexes = { normal = 0, hover = 0, pressed = 0, checkednormal = 1, checkedhover = 1, checkedpressed = 1 }
63 | -- indexes for /data/hd/global/ui/lobby/creategame/creategame_advancedcheckbox.lowend.sprite
64 | --FrameIndexes = { normal = 0, hover = 3, pressed = 1, checkednormal = 4, checkedhover = 6, checkedpressed = 5, disabled = 2 }
65 | }
66 | }
67 |
68 | ButtonPressedSfx = LoadSoundEffect("cursor_button_click")
69 | end
70 |
71 | -- Creates a button
72 | -- @buttonType The type of button to create
73 | -- @param x The x position of the button
74 | -- @param y The y position of the button
75 | -- @param text The text to display on the button, prefer translateable @text instead of English value
76 | function CreateButton(buttonSpec, x, y, text, onActivate)
77 | local label = abyss.createLabel(buttonSpec.Font)
78 | label:setAlignment("middle", "middle")
79 | label:setPosition(math.floor(buttonSpec.FixedSize.X / 2), math.floor(buttonSpec.FixedSize.Y / 2))
80 | label:setColorMod(buttonSpec.TextColor.R, buttonSpec.TextColor.G, buttonSpec.TextColor.B)
81 | if buttonSpec.TextVerticalSpacing ~= nil then label.verticalSpacing = buttonSpec.TextVerticalSpacing end
82 | local result = abyss.createButton(buttonSpec.Image)
83 | result.data.label = label
84 | result:appendChild(label)
85 | result:setSegments(buttonSpec.Segments.X, buttonSpec.Segments.Y)
86 | result:setFixedSize(buttonSpec.FixedSize.X, buttonSpec.FixedSize.Y)
87 | if SpriteFontIsActuallyTTF then
88 | label.caption = '' .. Language:translate(text) .. ''
89 | else
90 | label.caption = Language:translate(text)
91 | end
92 | result:setPosition(x, y)
93 | result:setPressedOffset(-2, 2)
94 | result:onActivate(onActivate)
95 | result:onPressed(function()
96 | ButtonPressedSfx:play()
97 | end)
98 | result:onMouseEnter(function()
99 | IsOnButton=true
100 | end)
101 | result:onMouseLeave(function()
102 | IsOnButton=false
103 | end)
104 | if buttonSpec.Wrap then
105 | label.maxWidth = buttonSpec.FixedSize.X
106 | end
107 |
108 | for k, v in pairs(buttonSpec.FrameIndexes) do
109 | result:setFrameIndex(k, v)
110 | end
111 |
112 | return result
113 | end
114 |
115 | function CreateCheckbox(x, y, text)
116 | local btn
117 | btn = CreateButton(ButtonTypes.Checkbox, x, y, text, function()
118 | end)
119 | btn:onPressed(function()
120 | btn.checked = not btn.checked
121 | end)
122 | btn:setPressedOffset(0, 0)
123 | local w, h = ButtonTypes.Checkbox.Image:getFrameSize(0, ButtonTypes.Checkbox.Segments.X)
124 | btn:setFixedSize(w, h)
125 | btn.data.label:setAlignment("start", "start")
126 | btn.data.label:setPosition(ButtonTypes.Checkbox.TextOffset.X, ButtonTypes.Checkbox.TextOffset.Y)
127 |
128 | return btn
129 | end
130 |
131 | function CreateUniqueSpriteFromFile(file, palette)
132 | local img = abyss.loadImage(file, palette)
133 | local spr = abyss.createSprite(img)
134 | spr.data.img = img
135 | return spr
136 | end
137 |
--------------------------------------------------------------------------------
/common/util.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (C) 2021 Tim Sarbin
2 | -- This file is part of OpenDiablo2 .
3 | --
4 | -- OpenDiablo2 is free software: you can redistribute it and/or modify
5 | -- it under the terms of the GNU General Public License as published by
6 | -- the Free Software Foundation, either version 3 of the License, or
7 | -- (at your option) any later version.
8 | --
9 | -- OpenDiablo2 is distributed in the hope that it will be useful,
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | -- GNU General Public License for more details.
13 | --
14 | -- You should have received a copy of the GNU General Public License
15 | -- along with OpenDiablo2. If not, see .
16 | --
17 | require("string")
18 | local jsonlib = require('common/json')
19 |
20 | function Split(s, delimiter)
21 | local result = {};
22 | for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do
23 | table.insert(result, match);
24 | end
25 | return result;
26 | end
27 |
28 | --- Loads a tab seperated file into a table
29 | --- @param filePath string # The path to the file
30 | --- @param firstFieldIsHandle boolean # Whether the first field is the handle
31 | --- @return table # The table containing the file contents
32 | function LoadTsvAsTable(filePath, firstFieldIsHandle)
33 | local tsvData = abyss.loadString(filePath)
34 |
35 | local lines = {}
36 |
37 | for s in tsvData:gmatch("[^\r\n]+") do
38 | table.insert(lines, s .. "\t")
39 | end
40 |
41 | local fields = {}
42 |
43 | local fieldstart = 1
44 | repeat
45 | local nexti = lines[1]:find("\t", fieldstart)
46 | table.insert(fields, lines[1]:sub(fieldstart, nexti - 1))
47 | fieldstart = nexti + 1
48 | until fieldstart > lines[1]:len()
49 |
50 | local result = {}
51 |
52 | for i = 2, #lines do
53 | local line = lines[i]
54 | if line ~= nil and line:len() ~= 0 and line ~= '0' and line ~= 'expansion' and line ~= 'Expansion' then
55 |
56 | local fieldIdx = 0
57 | local item = {}
58 |
59 | fieldstart = 1
60 | repeat
61 | fieldIdx = fieldIdx + 1
62 | local nexti = line:find("\t", fieldstart)
63 | item[fields[fieldIdx]:gsub("%s+", "_")] = line:sub(fieldstart, nexti - 1)
64 | fieldstart = nexti + 1
65 | until fieldstart > line:len()
66 |
67 | if firstFieldIsHandle then
68 | result[item[fields[1]:gsub("%s+", "_")]] = item
69 | else
70 | table.insert(result, item)
71 | end
72 | end
73 | end
74 |
75 | return result
76 | end
77 |
78 | -- reads json file as lua table
79 | function ReadJsonAsTable(path)
80 | local jsonstr = abyss.loadString(path)
81 | -- remove utf-8 bom
82 | if jsonstr:sub(1, 3) == '\xEF\xBB\xBF' then
83 | jsonstr = jsonstr:sub(4)
84 | end
85 | -- remove comments
86 | local lines = {}
87 | for line in jsonstr:gmatch("([^\n]+)") do
88 | local quotes = false
89 | local new_line = line
90 | for i = 1, #line do
91 | if line:sub(i, i) == '"' then
92 | quotes = not quotes
93 | end
94 | if line:sub(i, i + 1) == '//' and not quotes then
95 | new_line = line:sub(1, i - 1)
96 | break
97 | end
98 | end
99 | table.insert(lines, new_line)
100 | end
101 | return jsonlib.decode(table.concat(lines, '\n'))
102 | end
103 |
104 | function cond(c, a, b)
105 | if c then
106 | return a
107 | else
108 | return b
109 | end
110 | end
111 |
112 | function or_else(x, y)
113 | if x == nil then
114 | return y
115 | end
116 | return x
117 | end
118 |
119 | function file_exists(name)
120 | local f=io.open(name,"r")
121 | if f~=nil then io.close(f) return true else return false end
122 | end
123 |
124 |
125 | function dump(o)
126 | if type(o) == 'table' then
127 | local s = '{ '
128 | for k,v in pairs(o) do
129 | if type(k) ~= 'number' then k = '"'..k..'"' end
130 | s = s .. '['..k..'] = ' .. dump(v) .. ','
131 | end
132 | return s .. '} '
133 | else
134 | return tostring(o)
135 | end
136 | end
137 |
138 | function dumplayout()
139 | local function output(node, offset)
140 | local x, y = node:getPosition()
141 | local line = node:nodeType() .. " X=" .. dump(x) .. " Y="..dump(y) .. " Active=" .. dump(node.active)
142 | if node.data.layout ~= nil then
143 | line = line .. " Layout type=" .. node.data.layout.type .. " name=" .. or_else(node.data.layout.name, "(nil)")
144 | end
145 | local label = node:castToLabel()
146 | if label ~= nil then
147 | line = line .. " text: " .. label.caption
148 | end
149 | for i = 1, offset do
150 | line = " " .. line
151 | end
152 | abyss.log("info", line)
153 | local children = node:getChildren()
154 | for _, child in ipairs(children) do
155 | output(child, offset+1)
156 | end
157 | end
158 | output(abyss.getRootNode(), 0)
159 | end
160 |
--------------------------------------------------------------------------------
/config.ini:
--------------------------------------------------------------------------------
1 | [Video]
2 | FullScreen=0
3 | VSync=1
4 | HardwareCursor=0
5 | HardwareCursorScale=1
6 | Resolution=800x600
7 | MaxFPS=60
8 |
9 | [Audio]
10 | MasterVolume=1.0
11 | VideoVolume=1.0
12 | SoundEffectsVolume=1.0
13 | BackgroundMusicVolume=0.75
14 |
15 | [System]
16 | LuaGCRateMsecs=256
17 |
18 | [OpenDiablo2]
19 | BASE_DATA_DIR=./DATA
20 | MPQs=MPQ-D2
21 | CASCs=CASC-D2R
22 | ; Language can be one of enUS, deDE, esES, esMX, frFR, itIT, jaJP, koKR, plPL, ptBR, ruRU, zhCN, zhTW, depending on which MPQs you have.
23 | ; You can set it to 'auto', and language will be detected automatically depending on the files present.
24 | Language=auto
25 | SkipStartupVideos=0
26 | MPQRoot=./mpqs
27 |
--------------------------------------------------------------------------------
/media/ss1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbyssEngine/OpenDiablo2/60455f9f81d1aa3ec5b1208032d7a7dcabebee24/media/ss1.png
--------------------------------------------------------------------------------
/media/ss2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AbyssEngine/OpenDiablo2/60455f9f81d1aa3ec5b1208032d7a7dcabebee24/media/ss2.png
--------------------------------------------------------------------------------
/screens/character-creation.lua:
--------------------------------------------------------------------------------
1 | local CharacterCreation = {}
2 |
3 | function CharacterCreation:new()
4 | local this = {}
5 | setmetatable(this, self)
6 | self:initialize()
7 | return this
8 | end
9 |
10 | function CharacterCreation:initialize()
11 | self.rootNode = abyss.getRootNode()
12 | self.layout = LayoutLoader:load('CharacterCreatePanel.json', ResourceDefs.Palette.Fechar)
13 | self.rootNode:appendChild(self.layout)
14 | end
15 |
16 |
17 | return CharacterCreation
18 |
--------------------------------------------------------------------------------
/screens/character-selection.lua:
--------------------------------------------------------------------------------
1 | local CharacterSelection = {
2 | }
3 | CharacterSelection.__index = CharacterSelection
4 |
5 | local lblHeroTitle, deleteCharacterDialog, rootNode
6 | local btnConvertCharacter, btnExit, btnNewCharacter, btnOk, btnDeleteCharacter
7 |
8 | local function createDeleteCharacterWindow()
9 | local result = {
10 | window = CreateUniqueSpriteFromFile(ResourceDefs.CinematicsBackground, ResourceDefs.Palette.Sky),
11 | buttons = {}
12 | }
13 |
14 | local deleteCancelX, deleteCancelY = 282, 308
15 | local deleteOkX, deleteOkY = 422, 308
16 | local exitBtnX, exitBtnY = 33, 537
17 |
18 | result.window:setCellSize(2, 2)
19 | result.window:setPosition(237, 80)
20 |
21 |
22 | result.lblHeader = abyss.createLabel(SystemFonts.Fnt30)
23 | result.lblHeader.caption = "Temporary"
24 | result.lblHeader:setPosition(163, 10)
25 | result.lblHeader:setAlignment("middle", "start")
26 |
27 | result.btnCancel = CreateButton(ButtonTypes.Medium, deleteCancelX, deleteCancelY, "No", function()
28 | result:hide()
29 | end)
30 |
31 | result.window:appendChild(result.lblHeader)
32 | result.window:appendChild(result.btnCancel)
33 | result.window.active = false
34 |
35 | result.show = function()
36 | result.window.active = true
37 | end
38 |
39 | result.hide = function()
40 | result.window.active = false
41 | end
42 |
43 | return result
44 | end
45 |
46 | -- Local functions must be declared before the exposed functions
47 |
48 | local function initialize()
49 | local rootLabelOffsetX = 115
50 | local rootLabelOffsetY = 100
51 | local labelHeight = 15
52 |
53 | local selectionBoxNumColumns = 2
54 | local selectionBoxNumRows = 4
55 | local selectionBoxWidth = 272
56 | local selectionBoxHeight = 92
57 | local selectionBoxOffsetX = 37
58 | local selectionBoxOffsetY = 86
59 | local selectionBoxImageOffsetX = 40
60 | local selectionBoxImageOffsetY = 50
61 |
62 | local newCharBtnX, newCharBtnY = 33, 468
63 | local convertCharBtnX, convertCharBtnY = 233, 468
64 | local deleteCharBtnX, deleteCharBtnY = 433, 468
65 | local okBtnX, okBtnY = 625, 537
66 |
67 | rootNode = abyss.getRootNode()
68 |
69 | deleteCharacterDialog = createDeleteCharacterWindow()
70 |
71 | -- create hero title and fill with sample value
72 | lblHeroTitle = abyss.createLabel(SystemFonts.Fnt42)
73 | lblHeroTitle:setAlignment("middle","")
74 | lblHeroTitle:setPosition(320, 23)
75 | lblHeroTitle:setColorMod(TextColor.LightBrown.R, TextColor.LightBrown.G, TextColor.LightBrown.B)
76 | lblHeroTitle.caption = "Selected Hero"
77 |
78 | -- new character button
79 | -- TODO @strCreateNewCharacter#5273 when we can wrap words
80 | btnNewCharacter = CreateButton(ButtonTypes.Tall, newCharBtnX, newCharBtnY, "CREATE NEW\nCHARACTER", function()
81 | SetScreen(Screen.CHARACTER_CREATION)
82 | -- Todo
83 | end)
84 |
85 | -- convert character to expanson
86 | -- TODO @strlaunchconverttoexp#2742 when we can wrap words
87 | btnConvertCharacter = CreateButton(ButtonTypes.Tall, convertCharBtnX, convertCharBtnY, "CONVERT TO\nEXPANSION", function()
88 | -- Todo
89 | end)
90 | btnConvertCharacter.disabled=true
91 |
92 | -- delete character button
93 | -- TODO @strlaunchdeletecharexp#2744 when we can wrap words
94 | btnDeleteCharacter = CreateButton(ButtonTypes.Tall, deleteCharBtnX, deleteCharBtnY, "DELETE\nCHARACTER", function()
95 | --self.deleteCharacterDialog.show()
96 | -- this is currently broken willfix laer
97 | end)
98 | btnDeleteCharacter.disabled=true
99 |
100 | -- ok button to enter game
101 | btnOk = CreateButton(ButtonTypes.Medium, okBtnX, okBtnY, "@strOk#5102", function()
102 | -- Todo
103 | end)
104 |
105 | -- exit button to return to main menu
106 | btnExit = CreateButton(ButtonTypes.Medium, 33, 543, "@strExit#5101", function()
107 | SetScreen(Screen.MAIN_MENU)
108 | end)
109 |
110 | -- Main Background
111 | mainBg = CreateUniqueSpriteFromFile(ResourceDefs.CharacterSelectionBackground, ResourceDefs.Palette.Sky)
112 | mainBg:setCellSize(4, 3)
113 |
114 | rootNode:appendChild(mainBg)
115 | mainBg:appendChild(btnExit)
116 | mainBg:appendChild(btnNewCharacter)
117 | mainBg:appendChild(btnConvertCharacter)
118 | mainBg:appendChild(btnDeleteCharacter)
119 | mainBg:appendChild(btnOk)
120 | mainBg:appendChild(lblHeroTitle)
121 | mainBg:appendChild(deleteCharacterDialog.window)
122 |
123 | end
124 |
125 | function CharacterSelection:new()
126 | local this = {}
127 | setmetatable(this, self)
128 | initialize()
129 | return this
130 | end
131 |
132 | return CharacterSelection
133 |
--------------------------------------------------------------------------------
/screens/credits.lua:
--------------------------------------------------------------------------------
1 | local Credits = {
2 | }
3 |
4 | function Credits:new()
5 | local this = {}
6 | setmetatable(this, self)
7 | self:initialize()
8 | return this
9 | end
10 |
11 | function Credits:initialize()
12 | self.creditsLines = abyss.loadString(Language:i18nPath(ResourceDefs.CreditsText))
13 |
14 | self.rootNode = abyss.getRootNode()
15 | self.rootNode:removeAllChildren()
16 | abyss.resetMouseState()
17 |
18 | self.btnExit = CreateButton(ButtonTypes.Medium, 33, 543, "@strExit#5101", function()
19 | SetScreen(Screen.MAIN_MENU)
20 | end)
21 |
22 | -- Main Background
23 | self.mainBg = CreateUniqueSpriteFromFile(ResourceDefs.CreditsBackground, ResourceDefs.Palette.Sky)
24 | self.mainBg:setCellSize(4, 3)
25 |
26 | self.rootNode:appendChild(self.mainBg)
27 | self.mainBg:appendChild(self.btnExit)
28 |
29 | end
30 |
31 |
32 | return Credits
33 |
--------------------------------------------------------------------------------
/screens/internal-error.lua:
--------------------------------------------------------------------------------
1 | local RESOLUTION_X = 800
2 | local RESOLUTION_Y = 600
3 |
4 | local Label = require("common/interface/label")
5 |
6 | local ErrorScreen = {
7 | }
8 | ErrorScreen.__index = ErrorScreen
9 | local rootNode, lblError
10 |
11 | local function initialize(data)
12 | rootNode = abyss.getRootNode()
13 | local header = data.header or "UNSPECIFIED"
14 | local message = "\n"
15 | if (data.errortype == "bootstrap") then
16 | if type(data.message) == "table" then
17 | message = message .. "\tThe following are missing:\n"
18 | for _,v in ipairs(data.message.missing) do
19 | message = message .. "\t\t" .. v .. "\r\n"
20 | end
21 | message = message .. "\tThe following have failed to load:\n"
22 | for _,v in ipairs(data.message.errored) do
23 | message = message .. "\t\t" .. v .. "\n"
24 | end
25 | end
26 | end
27 | --/abyss-embedded/Hack-Regular.ttf
28 | local f30 = abyss.createTtfFont('/abyss-embedded/Hack-Regular.ttf', math.floor(30 * 1.0), 'slight')
29 | local f15 = abyss.createTtfFont('/abyss-embedded/Hack-Regular.ttf', math.floor(15 * 1.0), 'slight')
30 |
31 | Label:new{
32 | parent = rootNode,
33 | font = f30,
34 | caption = header,
35 | alignment = {"middle","start"},
36 | position = {RESOLUTION_X/2, 15}
37 | }
38 | Label:new{
39 | parent = rootNode,
40 | font = f15,
41 | caption = message,
42 | alignment = {"start","start"},
43 | position = { 30 , 15 + 30 + 15}
44 | }
45 | end
46 |
47 | function ErrorScreen:new(data)
48 | local this = {}
49 | setmetatable(this, self)
50 | initialize(data)
51 | table.insert(rootNode.data, this)
52 | return this
53 | end
54 |
55 | return ErrorScreen
--------------------------------------------------------------------------------
/screens/main-menu.lua:
--------------------------------------------------------------------------------
1 | local MainMenu = {
2 | }
3 |
4 | function MainMenu:new()
5 | local this = {}
6 | setmetatable(this, self)
7 | self:initialize()
8 | return this
9 | end
10 |
11 | function MainMenu:initialize()
12 | if abyss.fileExists("/data/hd/global/music/introedit_hd.flac") then
13 | abyss.playBackgroundMusic("/data/hd/global/music/introedit_hd.flac")
14 | else
15 | abyss.playBackgroundMusic(ResourceDefs.BGMTitle)
16 | end
17 | self.rootNode = abyss.getRootNode()
18 |
19 | -- OpenDiablo Version Label
20 | self.lblVersion = abyss.createLabel(SystemFonts.FntFormal12)
21 | self.lblVersion:setPosition(790, 0)
22 | self.lblVersion.caption = "OpenDiablo II v0.01"
23 | self.lblVersion:setAlignment("end", "start")
24 |
25 | -- Disclaimer Labels
26 | self.lblDisclaimer1 = abyss.createLabel(SystemFonts.FntFormal12)
27 | --self.lblDisclaimer1.caption = Language:translate("@strcopyrightinfo#5104")
28 | self.lblDisclaimer1.caption = Language:translate("@strcopyrightinfoX#1882")
29 | self.lblDisclaimer1:setPosition(400, 470)
30 | self.lblDisclaimer1:setAlignment("middle", "start")
31 | self.lblDisclaimer1:setColorMod(0xE5, 0xC6, 0x9B)
32 |
33 | self.lblDisclaimer2 = abyss.createLabel(SystemFonts.FntFormal12)
34 | self.lblDisclaimer2.caption = Language:translate("@strallrightsreserved#5105")
35 | self.lblDisclaimer2.maxWidth = 500
36 | self.lblDisclaimer2:setPosition(400, 490)
37 | self.lblDisclaimer2:setAlignment("middle", "start")
38 | self.lblDisclaimer2:setColorMod(0xE5, 0xC6, 0x9B)
39 |
40 | self.lblDisclaimer3 = abyss.createLabel(SystemFonts.FntFormal12)
41 | self.lblDisclaimer3.caption = "OpenDiablo II is neither developed by,\nnor endorsed by Blizzard or its parent company Activision"
42 | self.lblDisclaimer3.maxWidth = 500
43 | self.lblDisclaimer3:setPosition(400, 540)
44 | self.lblDisclaimer3:setAlignment("middle", "start")
45 | self.lblDisclaimer3:setColorMod(0xFF, 0xFF, 0x8C)
46 |
47 | -- Trademark Screen
48 | self.trademarkBg = CreateUniqueSpriteFromFile(ResourceDefs.TrademarkScreen, ResourceDefs.Palette.Sky)
49 | self.trademarkBg:setCellSize(4, 3)
50 | self.trademarkBg:onMouseButtonDown(function(buttons)
51 | abyss.resetMouseState();
52 | self.trademarkBg.active = false
53 | self.mainBg.active = true
54 | self = nil
55 | end)
56 |
57 | -- Main Background
58 | self.mainBg = CreateUniqueSpriteFromFile(ResourceDefs.GameSelectScreen, ResourceDefs.Palette.Sky)
59 | self.mainBg:setCellSize(4, 3)
60 | self.mainBg.active = false
61 |
62 | -- D2 Logo Left Black BG
63 | self.d2LogoLeftBlackBg = CreateUniqueSpriteFromFile(ResourceDefs.Diablo2LogoBlackLeft, ResourceDefs.Palette.Sky)
64 | self.d2LogoLeftBlackBg:setPosition(400, 120)
65 | self.d2LogoLeftBlackBg.bottomOrigin = true
66 | self.d2LogoLeftBlackBg.playMode = "forwards"
67 |
68 | -- D2 Logo Right Black BG
69 | self.d2LogoRightBlackBg = CreateUniqueSpriteFromFile(ResourceDefs.Diablo2LogoBlackRight, ResourceDefs.Palette.Sky)
70 | self.d2LogoRightBlackBg:setPosition(400, 120)
71 | self.d2LogoRightBlackBg.bottomOrigin = true
72 | self.d2LogoRightBlackBg.playMode = "forwards"
73 |
74 | -- D2 Logo Left
75 | self.d2LogoLeft = CreateUniqueSpriteFromFile(ResourceDefs.Diablo2LogoFireLeft, ResourceDefs.Palette.Sky)
76 | self.d2LogoLeft:setPosition(400, 120)
77 | self.d2LogoLeft.blendMode = "additive"
78 | self.d2LogoLeft.bottomOrigin = true
79 | self.d2LogoLeft.playMode = "forwards"
80 |
81 | -- D2 Logo Right
82 | self.d2LogoRight = CreateUniqueSpriteFromFile(ResourceDefs.Diablo2LogoFireRight, ResourceDefs.Palette.Sky)
83 | self.d2LogoRight:setPosition(400, 120)
84 | self.d2LogoRight.blendMode = "additive"
85 | self.d2LogoRight.bottomOrigin = true
86 | self.d2LogoRight.playMode = "forwards"
87 |
88 | -- Cinematics Window
89 | self.cinematicsDialog = self:createCinematicsWindow(self)
90 |
91 | -- Menu Buttons
92 | self.btnSinglePlayer = CreateButton(ButtonTypes.Wide, 264, 290, "@strStartMenu1#5106", function()
93 | SetScreen(Screen.CHARACTER_SELECTION)
94 | -- TODO
95 | end)
96 |
97 | self.btnLocalNetplay = CreateButton(ButtonTypes.Wide, 264, 330, "LOCAL NETPLAY", function()
98 | dumplayout()
99 | -- TODO
100 | end)
101 |
102 | self.btnMapEngineDebug = CreateButton(ButtonTypes.Wide, 264, 400, "MAP ENGINE TEST", function()
103 | SetScreen(Screen.MAP_ENGINE_TEST)
104 | end)
105 |
106 | self.btnCredits = CreateButton(ButtonTypes.Short, 264, 472, "@strGameCredits#5110", function()
107 | SetScreen(Screen.CREDITS)
108 | end)
109 |
110 | local this = self;
111 | self.btnCinematics = CreateButton(ButtonTypes.Short, 401, 472, "@strGameCinematics#5111", function()
112 | this.cinematicsDialog.show()
113 | this.btnSinglePlayer.active = false
114 | this.btnLocalNetplay.active = false
115 | this.btnExitGame.active = false
116 | this.btnCredits.active = false
117 | this.btnCinematics.active = false
118 | this.btnMapEngineDebug.active = false
119 | end)
120 |
121 | self.btnExitGame = CreateButton(ButtonTypes.Wide, 264, 500, "@strexitentiregame#5109", function()
122 | abyss.shutdown()
123 | end)
124 |
125 | -- Append all nodes to the scene graph
126 | self.trademarkBg:appendChild(self.lblDisclaimer1)
127 | self.trademarkBg:appendChild(self.lblDisclaimer2)
128 | self.trademarkBg:appendChild(self.lblDisclaimer3)
129 | self.mainBg:appendChild(self.lblVersion)
130 | self.mainBg:appendChild(self.btnSinglePlayer)
131 | self.mainBg:appendChild(self.btnLocalNetplay)
132 | self.mainBg:appendChild(self.btnExitGame)
133 | self.mainBg:appendChild(self.btnCredits)
134 | self.mainBg:appendChild(self.btnCinematics)
135 | self.mainBg:appendChild(self.btnMapEngineDebug)
136 | self.rootNode:appendChild(self.trademarkBg)
137 | self.rootNode:appendChild(self.mainBg)
138 | self.rootNode:appendChild(self.d2LogoLeftBlackBg)
139 | self.rootNode:appendChild(self.d2LogoRightBlackBg)
140 | self.rootNode:appendChild(self.d2LogoLeft)
141 | self.rootNode:appendChild(self.d2LogoRight)
142 |
143 | self.rootNode:appendChild(self.cinematicsDialog.window)
144 |
145 | --local testLayout = LayoutLoader:load('HUDPanel.json', ResourceDefs.Palette.Sky)
146 | --local testLayout = LayoutLoader:load('PlayerInventoryExpansionLayout.json', ResourceDefs.Palette.Sky)
147 | --local testLayout = LayoutLoader:load('PlayerInventoryOriginalLayout.json', ResourceDefs.Palette.Sky)
148 | --local testLayout = LayoutLoader:load('CharacterStatsPanel.json', ResourceDefs.Palette.Sky)
149 | --local testLayout = LayoutLoader:load('CharacterCreatePanel.json', ResourceDefs.Palette.Fechar)
150 | --local testLayout = LayoutLoader:load('QuestLogPanelOriginal.json', ResourceDefs.Palette.Sky)
151 | --local testLayout = LayoutLoader:load('QuestLogPanelExpansion.json', ResourceDefs.Palette.Sky)
152 | --local testLayout = LayoutLoader:load('HirelingInventoryPanel.json', ResourceDefs.Palette.Sky)
153 | --local testLayout = LayoutLoader:load('WaypointsPanelOriginal.json', ResourceDefs.Palette.Sky)
154 | --local testLayout = LayoutLoader:load('WaypointsPanelExpansion.json', ResourceDefs.Palette.Sky)
155 | --local testLayout = LayoutLoader:load('VendorPanelLayout.json', ResourceDefs.Palette.Sky)
156 | --self.testLayout = testLayout
157 | --if testLayout then
158 | -- self.rootNode:appendChild(testLayout)
159 | --end
160 |
161 | if ShowTrademarkScreen == false then
162 | self.trademarkBg.active = false
163 | self.mainBg.active = true
164 | else
165 | ShowTrademarkScreen = false
166 | end
167 | end
168 |
169 | function MainMenu:createCinematicsWindow(main)
170 | local result = {
171 | window = CreateUniqueSpriteFromFile(ResourceDefs.CinematicsBackground, ResourceDefs.Palette.Sky),
172 | main = main,
173 | buttons = {}
174 | }
175 |
176 | result.window:setCellSize(2, 2)
177 | result.window:setPosition(237, 80)
178 |
179 | local showHD = false
180 | if abyss.fileExists("/data/hd/global/video/d2intro.webm") then
181 | showHD = true
182 | end
183 |
184 | result.lblHeader = abyss.createLabel(SystemFonts.Fnt30)
185 | result.lblHeader.caption = Language:translate("@strselectcinematics#5114")
186 | result.lblHeader:setPosition(163, cond(showHD, 10, 20))
187 | result.lblHeader:setAlignment("middle", "start")
188 |
189 | local files = {{
190 | name = "@act1X",
191 | bik = "d2intro640x292.bik",
192 | hd = "d2intro",
193 | }, {
194 | name = "@act2X",
195 | bik = "Act02start640x292.bik",
196 | hd = "act2/act02start",
197 | }, {
198 | name = "@act3X",
199 | bik = "Act03start640x292.bik",
200 | hd = "act3/act03start",
201 | }, {
202 | name = "@act4X",
203 | bik = "Act04start640x292.bik",
204 | hd = "act4/act04start",
205 | }, {
206 | name = "@strepilogueX",
207 | bik = "Act04end640x292.bik",
208 | hd = "act4/act04end",
209 | }, {
210 | name = "@act5X",
211 | bik = "D2x_Intro_640x292.bik",
212 | hd = "d2x_intro",
213 | }, {
214 | name = "@strlastcinematic",
215 | bik = "D2x_Out_640x292.bik",
216 | hd = "act5/d2x_out",
217 | }}
218 |
219 | local y = cond(showHD, 60, 70)
220 |
221 | for _, item in ipairs(files) do
222 | local btn = CreateButton(ButtonTypes.Wide, 30, y, item.name, function()
223 | if result.btnToggleHD.checked then
224 | abyss.playVideoAndAudio("/data/hd/global/video/" .. item.hd .. ".webm", Language:hdaudioPath("/data/hd/local/video/" .. item.hd .. ".flac"))
225 | else
226 | if abyss.fileExists("/data/global/video/" .. item.hd .. ".webm") then
227 | abyss.playVideoAndAudio("/data/global/video/" .. item.hd .. ".webm", Language:hdaudioPath("/data/local/video/" .. item.hd .. ".flac"))
228 | else
229 | abyss.playVideo("/data/local/video/" .. Language:code3() .. "/" .. item.bik)
230 | end
231 | end
232 | end)
233 |
234 | table.insert(result.buttons, btn)
235 | result.window:appendChild(btn)
236 |
237 | y = y + 40
238 | end
239 |
240 | result.btnToggleHD = CreateCheckbox(120, 343, "HD video")
241 | if showHD then
242 | result.btnToggleHD.checked = true
243 | result.window:appendChild(result.btnToggleHD)
244 | end
245 |
246 | result.btnCancel = CreateButton(ButtonTypes.Medium, 100, 375, "@strCancel#5103", function()
247 | result.main.btnSinglePlayer.active = true
248 | result.main.btnLocalNetplay.active = true
249 | result.main.btnExitGame.active = true
250 | result.main.btnCredits.active = true
251 | result.main.btnCinematics.active = true
252 | result.main.btnMapEngineDebug.active = true
253 | result:hide()
254 | end)
255 |
256 | result.window:appendChild(result.lblHeader)
257 | result.window:appendChild(result.btnCancel)
258 | result.window.active = false
259 |
260 | result.show = function()
261 | abyss.playBackgroundMusic("")
262 | result.window.active = true
263 | end
264 |
265 | result.hide = function()
266 | if abyss.fileExists("/data/hd/global/music/introedit_hd.flac") then
267 | abyss.playBackgroundMusic("/data/hd/global/music/introedit_hd.flac")
268 | else
269 | abyss.playBackgroundMusic(ResourceDefs.BGMTitle)
270 | end
271 | result.window.active = false
272 | end
273 |
274 | return result
275 | end
276 |
277 |
278 | return MainMenu
279 |
--------------------------------------------------------------------------------
/screens/map-engine-test.lua:
--------------------------------------------------------------------------------
1 | local MapEngineTest = {
2 | seed = math.random(1, 9223372036854775807)
3 | }
4 |
5 | function MapEngineTest:new()
6 | local this = {}
7 | setmetatable(this, self)
8 | self:initialize()
9 | return this
10 | end
11 |
12 | function MapEngineTest:initialize()
13 | self.startMouseX = 0
14 | self.startMouseY = 0
15 | self.lastMouseX = 0
16 | self.lastMouseY = 0
17 | self.curMapOffsetX = 400
18 | self.curMapOffsetY = 300
19 | self.isMouseDrag = false
20 |
21 | self.currentMap = 1
22 | self.currentPreset = 1
23 | self.selectedFile = 1
24 | self.RegionSpec = {
25 | -- Act 1
26 | { typeId = RegionDefs.Act1.Town, startPreset = 1, endPreset = 3, Palette = ResourceDefs.Palette.Act1, extra = {} },
27 | { typeId = RegionDefs.Act1.Wilderness, startPreset = 4, endPreset = 52, Palette = ResourceDefs.Palette.Act1, extra = {108,160,161,162,163,164} },
28 | { typeId = RegionDefs.Act1.Cave, startPreset = 53, endPreset = 107, Palette = ResourceDefs.Palette.Act1, extra = {} },
29 | { typeId = RegionDefs.Act1.Crypt, startPreset = 109, endPreset = 159, Palette = ResourceDefs.Palette.Act1, extra = {} },
30 | { typeId = RegionDefs.Act1.Monastary, startPreset = 165, endPreset = 165, Palette = ResourceDefs.Palette.Act1, extra = {} },
31 | { typeId = RegionDefs.Act1.Courtyard, startPreset = 166, endPreset = 166, Palette = ResourceDefs.Palette.Act1, extra = {256} },
32 | { typeId = RegionDefs.Act1.Barracks, startPreset = 167, endPreset = 205, Palette = ResourceDefs.Palette.Act1, extra = {} },
33 | { typeId = RegionDefs.Act1.Jail, startPreset = 206, endPreset = 255, Palette = ResourceDefs.Palette.Act1, extra = {} },
34 | { typeId = RegionDefs.Act1.Cathedral, startPreset = 257, endPreset = 257, Palette = ResourceDefs.Palette.Act1, extra = {} },
35 | { typeId = RegionDefs.Act1.Catacombs, startPreset = 258, endPreset = 299, Palette = ResourceDefs.Palette.Act1, extra = {} },
36 | { typeId = RegionDefs.Act1.Tristram, startPreset = 300, endPreset = 300, Palette = ResourceDefs.Palette.Act1, extra = {} },
37 |
38 | -- Act2
39 | { typeId = RegionDefs.Act2.Town, startPreset = 301, endPreset = 301, Palette = ResourceDefs.Palette.Act2, extra = {} },
40 | { typeId = RegionDefs.Act2.Sewer, startPreset = 302, endPreset = 352, Palette = ResourceDefs.Palette.Act2, extra = {} },
41 | { typeId = RegionDefs.Act2.Harem, startPreset = 353, endPreset = 357, Palette = ResourceDefs.Palette.Act2, extra = {} },
42 | { typeId = RegionDefs.Act2.Basement, startPreset = 358, endPreset = 361, Palette = ResourceDefs.Palette.Act2, extra = {} },
43 | { typeId = RegionDefs.Act2.Desert, startPreset = 362, endPreset = 413, Palette = ResourceDefs.Palette.Act2, extra = {} },
44 | { typeId = RegionDefs.Act2.Tomb, startPreset = 414, endPreset = 481, Palette = ResourceDefs.Palette.Act2, extra = {} },
45 | { typeId = RegionDefs.Act2.Lair, startPreset = 482, endPreset = 509, Palette = ResourceDefs.Palette.Act2, extra = {} },
46 | { typeId = RegionDefs.Act2.Arcane, startPreset = 510, endPreset = 528, Palette = ResourceDefs.Palette.Act2, extra = {} },
47 |
48 | -- Act III
49 | { typeId = RegionDefs.Act3.Town, startPreset = 529, endPreset = 529, Palette = ResourceDefs.Palette.Act3, extra = {}},
50 | { typeId = RegionDefs.Act3.Jungle, startPreset = 530, endPreset = 604, Palette = ResourceDefs.Palette.Act3, extra = {}},
51 | { typeId = RegionDefs.Act3.Kurast, startPreset = 605, endPreset = 658, Palette = ResourceDefs.Palette.Act3, extra = {748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769,770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791,792, 793, 794, 795, 796}},
52 | { typeId = RegionDefs.Act3.Spider, startPreset = 659, endPreset = 664, Palette = ResourceDefs.Palette.Act3, extra = {}},
53 | { typeId = RegionDefs.Act3.Dungeon, startPreset = 665, endPreset = 704, Palette = ResourceDefs.Palette.Act3, extra = {}},
54 | { typeId = RegionDefs.Act3.Sewer, startPreset = 705, endPreset = 747, Palette = ResourceDefs.Palette.Act3, extra = {}},
55 |
56 | -- Act IV
57 | { typeId = RegionDefs.Act4.Town, startPreset = 797, endPreset = 798, Palette = ResourceDefs.Palette.Act4, extra = {}},
58 | { typeId = RegionDefs.Act4.Mesa, startPreset = 799, endPreset = 835, Palette = ResourceDefs.Palette.Act4, extra = {}},
59 | { typeId = RegionDefs.Act4.Lava, startPreset = 836, endPreset = 862, Palette = ResourceDefs.Palette.Act4, extra = {}},
60 |
61 | -- Act V
62 | { typeId = RegionDefs.Act5.Town, startPreset = 863, endPreset = 864, Palette = ResourceDefs.Palette.Act5, extra = {}},
63 | { typeId = RegionDefs.Act5.Siege, startPreset = 865, endPreset = 879, Palette = ResourceDefs.Palette.Act5, extra = {}},
64 | { typeId = RegionDefs.Act5.Barricade, startPreset = 880, endPreset = 1002, Palette = ResourceDefs.Palette.Act5, extra = {}},
65 | { typeId = RegionDefs.Act5.IceCaves, startPreset = 1003, endPreset = 1041, Palette = ResourceDefs.Palette.Act5, extra = {}},
66 | { typeId = RegionDefs.Act5.Temple, startPreset = 1042, endPreset = 1052, Palette = ResourceDefs.Palette.Act5, extra = {}},
67 | { typeId = RegionDefs.Act5.Lava, startPreset = 1053, endPreset = 1058, Palette = ResourceDefs.Palette.Act4, extra = {}},
68 | { typeId = RegionDefs.Act5.Baal, startPreset = 1059, endPreset = 1089, Palette = ResourceDefs.Palette.Act5, extra = {}},
69 |
70 | }
71 |
72 | abyss.playBackgroundMusic("")
73 | self.rootNode = abyss.getRootNode()
74 |
75 | self.zone = abyss.createZone()
76 |
77 | local paletteName = ""
78 |
79 | self.mapRenderer = abyss.createMapRenderer(self.zone)
80 |
81 | self.mapRenderer:setPosition(self.curMapOffsetX, self.curMapOffsetY)
82 | self.mapRenderer.showOuterBorder = true
83 |
84 | self.btnExit = CreateButton(ButtonTypes.Short, 0, 573, "Exit", function()
85 | SetScreen(Screen.MAIN_MENU)
86 | end)
87 |
88 | self.btnPrevious = CreateButton(ButtonTypes.Medium, 0, 0, "< Preset", function()
89 | self:previousMap()
90 | end)
91 |
92 | self.btnPreviousFile = CreateButton(ButtonTypes.Medium, 0, 35, "< File", function()
93 | self:previousFile()
94 | end)
95 |
96 | self.btnNext = CreateButton(ButtonTypes.Medium, 672, 0, "Preset >", function()
97 | self:nextMap()
98 | end)
99 |
100 | self.btnNextFile = CreateButton(ButtonTypes.Medium, 672, 35, "File >", function()
101 | self:nextFile()
102 | end)
103 |
104 | self.lblMapName = abyss.createLabel(SystemFonts.Fnt16)
105 | self.lblMapName:setPosition(400, 8)
106 | self.lblMapName:setColorMod(0xFF, 0xFF, 0x00)
107 | self.lblMapName:setAlignment("middle", "middle")
108 | self.lblMapName.caption = ""
109 |
110 | self.lblPreset = abyss.createLabel(SystemFonts.Fnt16)
111 | self.lblPreset:setPosition(400, 22)
112 | self.lblPreset:setColorMod(0xFF, 0xFF, 0xFF)
113 | self.lblPreset:setAlignment("middle", "middle")
114 | self.lblPreset.caption = ""
115 |
116 | self.inputListener = abyss.createInputListener()
117 | self.mapRenderer:appendChild(self.inputListener)
118 | self.inputListener:onMouseMove(function(x, y)
119 | if IsOnButton then self.isMouseDrag = false; return end
120 | self.lastMouseX = x
121 | self.lastMouseY = y
122 |
123 | if self.isMouseDrag then
124 | self.mapRenderer:setPosition(self.curMapOffsetX + (x - self.startMouseX), self.curMapOffsetY + (y - self.startMouseY))
125 | else
126 | self.startMouseX = x
127 | self.startMouseY = y
128 | end
129 | end)
130 | self.inputListener:onMouseButton(function(button, isPressed)
131 | if IsOnButton then return end
132 | if button == 1 then -- Left mouse button
133 | if isPressed then
134 | self.isMouseDrag = true
135 | else
136 | self.isMouseDrag = false
137 | self.curMapOffsetX, self.curMapOffsetY = self.mapRenderer:getPosition()
138 | end
139 | elseif button == 2 and isPressed then -- Right mouse button
140 | local mx, my = self.mapRenderer:getPosition()
141 | local tx, ty = abyss.orthoToWorld(self.lastMouseX - mx, self.lastMouseY - my)
142 | if (tx >= 0) and (ty >= 0) and (tx < self.zone.width) and (ty < self.zone.height) then
143 | local tiles = self.zone:getTileInfo(tx, ty)
144 | abyss.log("info", "Tiles at " .. tx .. ", " .. ty .. ":")
145 | for _, tile in ipairs(tiles) do
146 | abyss.log("info", " -> " .. tile.type .. ", " .. tile.mainIndex .. ", " .. tile.subIndex)
147 | end
148 |
149 |
150 | end
151 | end
152 | end)
153 |
154 | self.rootNode:appendChild(self.mapRenderer)
155 | self.rootNode:appendChild(self.btnExit)
156 | self.rootNode:appendChild(self.btnPrevious)
157 | self.rootNode:appendChild(self.btnNext)
158 | self.rootNode:appendChild(self.lblMapName)
159 | self.rootNode:appendChild(self.lblPreset)
160 | self.rootNode:appendChild(self.btnPreviousFile)
161 | self.rootNode:appendChild(self.btnNextFile)
162 |
163 | self:updateMap()
164 | end
165 |
166 | function MapEngineTest:nextMap()
167 | local region = self.RegionSpec[self.currentMap]
168 | if self.currentPreset < region.endPreset then
169 | self.currentPreset = self.currentPreset + 1
170 | else
171 | self.currentMap = self.currentMap + 1
172 | if self.currentMap > #self.RegionSpec then
173 | self.currentMap = 1
174 | end
175 | self.currentPreset = self.RegionSpec[self.currentMap].startPreset
176 | end
177 | self.selectedFile = 1
178 |
179 | self:updateMap()
180 | end
181 |
182 | function MapEngineTest:previousMap()
183 | local region = self.RegionSpec[self.currentMap]
184 | if self.currentPreset > region.startPreset then
185 | self.currentPreset = self.currentPreset - 1
186 | else
187 | self.currentMap = self.currentMap - 1
188 | if self.currentMap < 1 then
189 | self.currentMap = #self.RegionSpec
190 | end
191 | self.currentPreset = self.RegionSpec[self.currentMap].endPreset
192 | end
193 | self.selectedFile = 1
194 |
195 | self:updateMap()
196 | end
197 |
198 | function MapEngineTest:previousFile()
199 | local region = self.RegionSpec[self.currentMap]
200 | local levelType = LevelTypes[region.typeId]
201 | local preset = GetLevelPreset(levelType.id, self.currentPreset)
202 |
203 | if self.selectedFile > 1 then
204 | self.selectedFile = self.selectedFile - 1
205 | else
206 | self.selectedFile = #preset.files
207 | end
208 |
209 | self:updateMap()
210 | end
211 |
212 | function MapEngineTest:nextFile()
213 | local region = self.RegionSpec[self.currentMap]
214 | local levelType = LevelTypes[region.typeId]
215 | local preset = GetLevelPreset(levelType.id, self.currentPreset)
216 |
217 | if self.selectedFile < #preset.files then
218 | self.selectedFile = self.selectedFile + 1
219 | else
220 | self.selectedFile = 1
221 | end
222 |
223 | self:updateMap()
224 | end
225 |
226 | function MapEngineTest:updateMap()
227 | local region = self.RegionSpec[self.currentMap]
228 | local levelType = LevelTypes[region.typeId]
229 | local preset = GetLevelPreset(levelType.id, self.currentPreset)
230 | local fileCaption = preset.files[self.selectedFile]
231 |
232 | self.btnNextFile.visible = #preset.files > 1
233 | self.btnPreviousFile.visible = #preset.files > 1
234 |
235 | if #preset.files > 1 then
236 | fileCaption = fileCaption .. " (" .. self.selectedFile .. " of " .. #preset.files .. ")"
237 | end
238 |
239 | self.lblMapName.caption = preset.name
240 | self.lblPreset.caption = fileCaption
241 |
242 | local ds1 = abyss.loadDS1(preset.files[self.selectedFile])
243 |
244 | self.zone:resetMap(levelType, preset.dt1Mask, ds1.width, ds1.height, self.seed)
245 | self.zone:stamp(ds1, 0, 0)
246 | self.mapRenderer:compile(region.Palette)
247 | local ttx = -math.floor(ds1.width / 2)
248 | local tty = -math.floor(ds1.height / 2)
249 | self.curMapOffsetX, self.curMapOffsetY = abyss.worldToOrtho(ttx, tty)
250 | self.curMapOffsetX = self.curMapOffsetX + 400
251 | self.curMapOffsetY = self.curMapOffsetY + 300
252 | self.mapRenderer:setPosition(self.curMapOffsetX, self.curMapOffsetY)
253 |
254 | end
255 |
256 | return MapEngineTest
257 |
--------------------------------------------------------------------------------
/screens/screens.lua:
--------------------------------------------------------------------------------
1 | Screen = {
2 | ERROR = -1,
3 | MAIN_MENU = 1,
4 | CREDITS = 2,
5 | MAP_ENGINE_TEST = 3,
6 | CHARACTER_SELECTION = 4,
7 | -- screens which exist in D2R should be implemented using common/layout.lua
8 | CHARACTER_CREATION = 5,
9 | }
10 |
11 | Screens = {
12 | [Screen.ERROR] = require("screens/internal-error"),
13 | [Screen.MAIN_MENU] = require("screens/main-menu"),
14 | [Screen.CREDITS] = require("screens/credits"),
15 | [Screen.MAP_ENGINE_TEST] = require("screens/map-engine-test"),
16 | [Screen.CHARACTER_SELECTION] = require("screens/character-selection"),
17 | [Screen.CHARACTER_CREATION] = require("screens/character-creation"),
18 | }
19 |
20 | local CurrentScreen
21 |
22 | function SetScreen(screenType, arg)
23 | abyss.getRootNode():removeAllChildren()
24 | abyss.resetMouseState()
25 | IsOnButton=false
26 | if arg ~= nil then
27 | CurrentScreen = Screens[screenType]:new(arg)
28 | else
29 | CurrentScreen = Screens[screenType]:new()
30 | end
31 | end
32 |
--------------------------------------------------------------------------------