diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..4da080c --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e9e794 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.class +*.jar diff --git a/.project b/.project new file mode 100644 index 0000000..bb1e4ba --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + NearInfinity + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8ce540 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# NearInfinity + +An Infinity Engine Browser and Editor + +# Enhanced Edition Warning + +This code is ancient and will likely not work properly with the more recent Enhanced Editions! diff --git a/build.xml b/build.xml index 3a40ac8..57622aa 100644 --- a/build.xml +++ b/build.xml @@ -1,25 +1,125 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + diff --git a/infinity/License.txt b/src/infinity/License.txt similarity index 98% rename from infinity/License.txt rename to src/infinity/License.txt index cbee875..ed2098a 100644 --- a/infinity/License.txt +++ b/src/infinity/License.txt @@ -1,504 +1,504 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/infinity/NearInfinity.java b/src/infinity/NearInfinity.java similarity index 99% rename from infinity/NearInfinity.java rename to src/infinity/NearInfinity.java index 3d09ed8..0ae9d7f 100644 --- a/infinity/NearInfinity.java +++ b/src/infinity/NearInfinity.java @@ -193,7 +193,7 @@ public void windowClosing(WindowEvent event) pane.add(splith, BorderLayout.CENTER); pane.add(statusBar, BorderLayout.SOUTH); - setSize(prefs.getInt(WINDOW_SIZEX, 900), prefs.getInt(WINDOW_SIZEY, 700)); + setSize(prefs.getInt(WINDOW_SIZEX, 930), prefs.getInt(WINDOW_SIZEY, 700)); // setSize(900, 700); int centerX = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getSize().width >> 1; int centerY = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getSize().height >> 1; diff --git a/infinity/bsd-license.txt b/src/infinity/bsd-license.txt similarity index 98% rename from infinity/bsd-license.txt rename to src/infinity/bsd-license.txt index 191e28d..2988562 100644 --- a/infinity/bsd-license.txt +++ b/src/infinity/bsd-license.txt @@ -1,31 +1,31 @@ - - The BSD License for the JGoodies Looks - ====================================== - -Copyright (c) 2001-2004 JGoodies Karsten Lentzsch. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - o Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - o Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - o Neither the name of JGoodies Karsten Lentzsch nor the names of - its contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + The BSD License for the JGoodies Looks + ====================================== + +Copyright (c) 2001-2004 JGoodies Karsten Lentzsch. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + o Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + o Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + o Neither the name of JGoodies Karsten Lentzsch nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/infinity/check/BCSIDSChecker.java b/src/infinity/check/BCSIDSChecker.java similarity index 100% rename from infinity/check/BCSIDSChecker.java rename to src/infinity/check/BCSIDSChecker.java diff --git a/infinity/check/CreInvChecker.java b/src/infinity/check/CreInvChecker.java similarity index 100% rename from infinity/check/CreInvChecker.java rename to src/infinity/check/CreInvChecker.java diff --git a/infinity/check/DialogCheker.java b/src/infinity/check/DialogCheker.java similarity index 100% rename from infinity/check/DialogCheker.java rename to src/infinity/check/DialogCheker.java diff --git a/infinity/check/EffectsIndexChecker.java b/src/infinity/check/EffectsIndexChecker.java similarity index 95% rename from infinity/check/EffectsIndexChecker.java rename to src/infinity/check/EffectsIndexChecker.java index f196112..d2d61a9 100644 --- a/infinity/check/EffectsIndexChecker.java +++ b/src/infinity/check/EffectsIndexChecker.java @@ -1,160 +1,160 @@ -package infinity.check; - -import infinity.NearInfinity; -import infinity.datatype.DecNumber; -import infinity.datatype.SectionCount; -import infinity.gui.Center; -import infinity.gui.ChildFrame; -import infinity.icon.Icons; -import infinity.resource.AbstractAbility; -import infinity.resource.AbstractStruct; -import infinity.resource.Resource; -import infinity.resource.ResourceFactory; -import infinity.resource.StructEntry; -import infinity.resource.key.ResourceEntry; -import infinity.search.ReferenceHitFrame; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.ProgressMonitor; - -public class EffectsIndexChecker extends ChildFrame implements ActionListener, Runnable -{ - private static final String filetypes[] = {"ITM", "SPL"}; - private final JButton bstart = new JButton("Check", Icons.getIcon("Find16.gif")); - private final JButton bcancel = new JButton("Cancel", Icons.getIcon("Delete16.gif")); - private final JButton binvert = new JButton("Invert", Icons.getIcon("Refresh16.gif")); - private final JCheckBox[] boxes; - private final ReferenceHitFrame hitFrame; - private List files; - - public EffectsIndexChecker() - { - super("Effects Index Checker"); - setIconImage(Icons.getIcon("Refresh16.gif").getImage()); - hitFrame = new ReferenceHitFrame("Mis-indexed Effects", NearInfinity.getInstance()); - - boxes = new JCheckBox[filetypes.length]; - bstart.setMnemonic('s'); - bcancel.setMnemonic('c'); - binvert.setMnemonic('i'); - bstart.addActionListener(this); - bcancel.addActionListener(this); - binvert.addActionListener(this); - getRootPane().setDefaultButton(bstart); - - JPanel boxpanel = new JPanel(new GridLayout(0, 2, 3, 3)); - for (int i = 0; i < boxes.length; i++) { - boxes[i] = new JCheckBox(filetypes[i], true); - boxpanel.add(boxes[i]); - } - boxpanel.setBorder(BorderFactory.createEmptyBorder(3, 12, 3, 0)); - - JPanel ipanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - ipanel.add(binvert); - JPanel innerpanel = new JPanel(new BorderLayout()); - innerpanel.add(boxpanel, BorderLayout.CENTER); - innerpanel.add(ipanel, BorderLayout.SOUTH); - innerpanel.setBorder(BorderFactory.createTitledBorder("Select files to check:")); - - JPanel bpanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - bpanel.add(bstart); - bpanel.add(bcancel); - - JPanel mainpanel = new JPanel(new BorderLayout()); - mainpanel.add(innerpanel, BorderLayout.CENTER); - mainpanel.add(bpanel, BorderLayout.SOUTH); - mainpanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - - JPanel pane = (JPanel)getContentPane(); - pane.setLayout(new BorderLayout()); - pane.add(mainpanel, BorderLayout.CENTER); - - pack(); - Center.center(this, NearInfinity.getInstance().getBounds()); - setVisible(true); - } -//--------------------- Begin Interface ActionListener --------------------- - - public void actionPerformed(ActionEvent event) - { - if (event.getSource() == bstart) { - setVisible(false); - files = new ArrayList(); - for (int i = 0; i < filetypes.length; i++) { - if (boxes[i].isSelected()) - files.addAll(ResourceFactory.getInstance().getResources(filetypes[i])); - } - if (files.size() > 0) - new Thread(this).start(); - } - else if (event.getSource() == binvert) { - for (final JCheckBox box : boxes) - box.setSelected(!box.isSelected()); - } - else if (event.getSource() == bcancel) - setVisible(false); - } - -// --------------------- End Interface ActionListener --------------------- - - -// --------------------- Begin Interface Runnable --------------------- - - public void run() - { - ProgressMonitor progress = new ProgressMonitor(NearInfinity.getInstance(), "Checking...", null, 0, - files.size()); - progress.setMillisToDecideToPopup(100); - String type = null; - long startTime = System.currentTimeMillis(); - for (int i = 0; i < files.size(); i++) { - ResourceEntry entry = files.get(i); - Resource resource = ResourceFactory.getResource(entry); - if (resource != null) { - if (!entry.getExtension().equalsIgnoreCase(type)) { - type = entry.getExtension(); - progress.setNote(type + 's'); - } - search(entry, (AbstractStruct)resource); - } - progress.setProgress(i + 1); - if (progress.isCanceled()) { - JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Check canceled", "Info", - JOptionPane.INFORMATION_MESSAGE); - return; - } - } - System.out.println("Check completed: " + (System.currentTimeMillis() - startTime) + "ms."); - hitFrame.setVisible(true); - } - - private void search(ResourceEntry entry, AbstractStruct struct) - { - int numGlobalEffects = ((SectionCount) struct.getAttribute("# global effects")).getValue(); - int expectedEffectsIndex = numGlobalEffects; - List structList = struct.getList(); - for (int i = 0; i < structList.size(); i++) { - Object o = structList.get(i); - if (o instanceof AbstractAbility) { - AbstractAbility abil = (AbstractAbility) o; - int effectsIndex = ((DecNumber) abil.getAttribute("Effects index")).getValue(); - if (effectsIndex != expectedEffectsIndex) { - hitFrame.addHit(entry, entry.getSearchString(), abil); - } - expectedEffectsIndex += abil.getEffectsCount(); - } - } - } -} +package infinity.check; + +import infinity.NearInfinity; +import infinity.datatype.DecNumber; +import infinity.datatype.SectionCount; +import infinity.gui.Center; +import infinity.gui.ChildFrame; +import infinity.icon.Icons; +import infinity.resource.AbstractAbility; +import infinity.resource.AbstractStruct; +import infinity.resource.Resource; +import infinity.resource.ResourceFactory; +import infinity.resource.StructEntry; +import infinity.resource.key.ResourceEntry; +import infinity.search.ReferenceHitFrame; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.ProgressMonitor; + +public class EffectsIndexChecker extends ChildFrame implements ActionListener, Runnable +{ + private static final String filetypes[] = {"ITM", "SPL"}; + private final JButton bstart = new JButton("Check", Icons.getIcon("Find16.gif")); + private final JButton bcancel = new JButton("Cancel", Icons.getIcon("Delete16.gif")); + private final JButton binvert = new JButton("Invert", Icons.getIcon("Refresh16.gif")); + private final JCheckBox[] boxes; + private final ReferenceHitFrame hitFrame; + private List files; + + public EffectsIndexChecker() + { + super("Effects Index Checker"); + setIconImage(Icons.getIcon("Refresh16.gif").getImage()); + hitFrame = new ReferenceHitFrame("Mis-indexed Effects", NearInfinity.getInstance()); + + boxes = new JCheckBox[filetypes.length]; + bstart.setMnemonic('s'); + bcancel.setMnemonic('c'); + binvert.setMnemonic('i'); + bstart.addActionListener(this); + bcancel.addActionListener(this); + binvert.addActionListener(this); + getRootPane().setDefaultButton(bstart); + + JPanel boxpanel = new JPanel(new GridLayout(0, 2, 3, 3)); + for (int i = 0; i < boxes.length; i++) { + boxes[i] = new JCheckBox(filetypes[i], true); + boxpanel.add(boxes[i]); + } + boxpanel.setBorder(BorderFactory.createEmptyBorder(3, 12, 3, 0)); + + JPanel ipanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + ipanel.add(binvert); + JPanel innerpanel = new JPanel(new BorderLayout()); + innerpanel.add(boxpanel, BorderLayout.CENTER); + innerpanel.add(ipanel, BorderLayout.SOUTH); + innerpanel.setBorder(BorderFactory.createTitledBorder("Select files to check:")); + + JPanel bpanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + bpanel.add(bstart); + bpanel.add(bcancel); + + JPanel mainpanel = new JPanel(new BorderLayout()); + mainpanel.add(innerpanel, BorderLayout.CENTER); + mainpanel.add(bpanel, BorderLayout.SOUTH); + mainpanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + + JPanel pane = (JPanel)getContentPane(); + pane.setLayout(new BorderLayout()); + pane.add(mainpanel, BorderLayout.CENTER); + + pack(); + Center.center(this, NearInfinity.getInstance().getBounds()); + setVisible(true); + } +//--------------------- Begin Interface ActionListener --------------------- + + public void actionPerformed(ActionEvent event) + { + if (event.getSource() == bstart) { + setVisible(false); + files = new ArrayList(); + for (int i = 0; i < filetypes.length; i++) { + if (boxes[i].isSelected()) + files.addAll(ResourceFactory.getInstance().getResources(filetypes[i])); + } + if (files.size() > 0) + new Thread(this).start(); + } + else if (event.getSource() == binvert) { + for (final JCheckBox box : boxes) + box.setSelected(!box.isSelected()); + } + else if (event.getSource() == bcancel) + setVisible(false); + } + +// --------------------- End Interface ActionListener --------------------- + + +// --------------------- Begin Interface Runnable --------------------- + + public void run() + { + ProgressMonitor progress = new ProgressMonitor(NearInfinity.getInstance(), "Checking...", null, 0, + files.size()); + progress.setMillisToDecideToPopup(100); + String type = null; + long startTime = System.currentTimeMillis(); + for (int i = 0; i < files.size(); i++) { + ResourceEntry entry = files.get(i); + Resource resource = ResourceFactory.getResource(entry); + if (resource != null) { + if (!entry.getExtension().equalsIgnoreCase(type)) { + type = entry.getExtension(); + progress.setNote(type + 's'); + } + search(entry, (AbstractStruct)resource); + } + progress.setProgress(i + 1); + if (progress.isCanceled()) { + JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Check canceled", "Info", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + System.out.println("Check completed: " + (System.currentTimeMillis() - startTime) + "ms."); + hitFrame.setVisible(true); + } + + private void search(ResourceEntry entry, AbstractStruct struct) + { + int numGlobalEffects = ((SectionCount) struct.getAttribute("# global effects")).getValue(); + int expectedEffectsIndex = numGlobalEffects; + List structList = struct.getList(); + for (int i = 0; i < structList.size(); i++) { + Object o = structList.get(i); + if (o instanceof AbstractAbility) { + AbstractAbility abil = (AbstractAbility) o; + int effectsIndex = ((DecNumber) abil.getAttribute("First effect index")).getValue(); + if (effectsIndex != expectedEffectsIndex) { + hitFrame.addHit(entry, entry.getSearchString(), abil); + } + expectedEffectsIndex += abil.getEffectsCount(); + } + } + } +} diff --git a/infinity/check/IDSRefChecker.java b/src/infinity/check/IDSRefChecker.java similarity index 100% rename from infinity/check/IDSRefChecker.java rename to src/infinity/check/IDSRefChecker.java diff --git a/infinity/check/ResRefChecker.java b/src/infinity/check/ResRefChecker.java similarity index 100% rename from infinity/check/ResRefChecker.java rename to src/infinity/check/ResRefChecker.java diff --git a/infinity/check/ResourceUseChecker.java b/src/infinity/check/ResourceUseChecker.java similarity index 100% rename from infinity/check/ResourceUseChecker.java rename to src/infinity/check/ResourceUseChecker.java diff --git a/infinity/check/ScriptChecker.java b/src/infinity/check/ScriptChecker.java similarity index 100% rename from infinity/check/ScriptChecker.java rename to src/infinity/check/ScriptChecker.java diff --git a/infinity/check/StringUseChecker.java b/src/infinity/check/StringUseChecker.java similarity index 78% rename from infinity/check/StringUseChecker.java rename to src/infinity/check/StringUseChecker.java index 14b1250..6e38ec3 100644 --- a/infinity/check/StringUseChecker.java +++ b/src/infinity/check/StringUseChecker.java @@ -21,12 +21,19 @@ import javax.swing.*; import javax.swing.event.*; import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.PrintWriter; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; import java.util.*; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -public final class StringUseChecker implements Runnable, ListSelectionListener, SearchClient +public final class StringUseChecker implements Runnable, ListSelectionListener, SearchClient, ActionListener { private static final Pattern NUMBERPATTERN = Pattern.compile("\\d+", Pattern.DOTALL); private static final String FILETYPES[] = {"2DA", "ARE", "BCS", "BS", "CHR", "CHU", "CRE", "DLG", "EFF", @@ -35,6 +42,7 @@ public final class StringUseChecker implements Runnable, ListSelectionListener, private JTextArea textArea; private SortableTable table; private boolean strUsed[]; + private JMenuItem save; public StringUseChecker() { @@ -106,6 +114,13 @@ else if (resource != null) textArea.setLineWrap(true); JScrollPane scrollText = new JScrollPane(textArea); resultFrame = new ChildFrame("Result", true); + save = new JMenuItem("Save"); + save.addActionListener(this); + JMenu fileMenu = new JMenu("File"); + fileMenu.add(save); + JMenuBar menuBar = new JMenuBar(); + menuBar.add(fileMenu); + resultFrame.setJMenuBar(menuBar); resultFrame.setIconImage(Icons.getIcon("Find16.gif").getImage()); JLabel count = new JLabel(table.getRowCount() + " unused string(s) found", JLabel.CENTER); count.setFont(count.getFont().deriveFont((float)count.getFont().getSize() + 2.0f)); @@ -132,6 +147,45 @@ else if (resource != null) // --------------------- End Interface Runnable --------------------- +// --------------------- Begin Interface ActionListener --------------------- + + public void actionPerformed(ActionEvent e) + { + if (e.getSource() == save) { + JFileChooser c = new JFileChooser(ResourceFactory.getRootDir()); + c.setDialogTitle("Save result"); + if (c.showSaveDialog(resultFrame) == JFileChooser.APPROVE_OPTION) { + File output = c.getSelectedFile(); + if (output.exists()) { + String[] options = {"Overwrite", "Cancel"}; + if (JOptionPane.showOptionDialog(resultFrame, output + "exists. Overwrite?", + "Save result",JOptionPane.YES_NO_OPTION, + JOptionPane.WARNING_MESSAGE, null, options, options[0]) == 1) + return; + } + try { + PrintWriter w = new PrintWriter(new BufferedWriter(new FileWriter(output))); + w.println("Searched for unused strings"); + w.println("Number of hits: " + table.getRowCount()); + w.println(""); + for (int i = 0; i < table.getRowCount(); i++) { + w.println("StringRef: " + table.getTableItemAt(i).getObjectAt(1) + " /* " + + table.getTableItemAt(i).toString().replaceAll("\r\n", System.getProperty("line.separator")) + + " */"); + } + w.close(); + JOptionPane.showMessageDialog(resultFrame, "Result saved to " + output, "Save complete", + JOptionPane.INFORMATION_MESSAGE); + } catch (IOException ex) { + JOptionPane.showMessageDialog(resultFrame, "Error while saving " + output, + "Error", JOptionPane.ERROR_MESSAGE); + ex.printStackTrace(); + } + } + } + } + +// --------------------- End Interface ActionListener --------------------- // --------------------- Begin Interface SearchClient --------------------- diff --git a/infinity/check/StructChecker.java b/src/infinity/check/StructChecker.java similarity index 100% rename from infinity/check/StructChecker.java rename to src/infinity/check/StructChecker.java diff --git a/infinity/datatype/AreResourceRef.java b/src/infinity/datatype/AreResourceRef.java similarity index 100% rename from infinity/datatype/AreResourceRef.java rename to src/infinity/datatype/AreResourceRef.java diff --git a/infinity/datatype/Bitmap.java b/src/infinity/datatype/Bitmap.java similarity index 100% rename from infinity/datatype/Bitmap.java rename to src/infinity/datatype/Bitmap.java diff --git a/infinity/datatype/ColorValue.java b/src/infinity/datatype/ColorValue.java similarity index 100% rename from infinity/datatype/ColorValue.java rename to src/infinity/datatype/ColorValue.java diff --git a/infinity/datatype/Datatype.java b/src/infinity/datatype/Datatype.java similarity index 100% rename from infinity/datatype/Datatype.java rename to src/infinity/datatype/Datatype.java diff --git a/infinity/datatype/DecNumber.java b/src/infinity/datatype/DecNumber.java similarity index 100% rename from infinity/datatype/DecNumber.java rename to src/infinity/datatype/DecNumber.java diff --git a/infinity/datatype/Editable.java b/src/infinity/datatype/Editable.java similarity index 100% rename from infinity/datatype/Editable.java rename to src/infinity/datatype/Editable.java diff --git a/infinity/datatype/EffectType.java b/src/infinity/datatype/EffectType.java similarity index 100% rename from infinity/datatype/EffectType.java rename to src/infinity/datatype/EffectType.java diff --git a/infinity/datatype/Flag.java b/src/infinity/datatype/Flag.java similarity index 100% rename from infinity/datatype/Flag.java rename to src/infinity/datatype/Flag.java diff --git a/infinity/datatype/HashBitmap.java b/src/infinity/datatype/HashBitmap.java similarity index 100% rename from infinity/datatype/HashBitmap.java rename to src/infinity/datatype/HashBitmap.java diff --git a/infinity/datatype/HexNumber.java b/src/infinity/datatype/HexNumber.java similarity index 100% rename from infinity/datatype/HexNumber.java rename to src/infinity/datatype/HexNumber.java diff --git a/infinity/datatype/IDSTargetEffect.java b/src/infinity/datatype/IDSTargetEffect.java similarity index 100% rename from infinity/datatype/IDSTargetEffect.java rename to src/infinity/datatype/IDSTargetEffect.java diff --git a/infinity/datatype/IdsBitmap.java b/src/infinity/datatype/IdsBitmap.java similarity index 100% rename from infinity/datatype/IdsBitmap.java rename to src/infinity/datatype/IdsBitmap.java diff --git a/infinity/datatype/IdsFlag.java b/src/infinity/datatype/IdsFlag.java similarity index 100% rename from infinity/datatype/IdsFlag.java rename to src/infinity/datatype/IdsFlag.java diff --git a/infinity/datatype/InlineEditable.java b/src/infinity/datatype/InlineEditable.java similarity index 100% rename from infinity/datatype/InlineEditable.java rename to src/infinity/datatype/InlineEditable.java diff --git a/infinity/datatype/IwdRef.java b/src/infinity/datatype/IwdRef.java similarity index 100% rename from infinity/datatype/IwdRef.java rename to src/infinity/datatype/IwdRef.java diff --git a/infinity/datatype/Kit2daBitmap.java b/src/infinity/datatype/Kit2daBitmap.java similarity index 100% rename from infinity/datatype/Kit2daBitmap.java rename to src/infinity/datatype/Kit2daBitmap.java diff --git a/infinity/datatype/ProRef.java b/src/infinity/datatype/ProRef.java similarity index 100% rename from infinity/datatype/ProRef.java rename to src/infinity/datatype/ProRef.java diff --git a/infinity/datatype/RemovableDecNumber.java b/src/infinity/datatype/RemovableDecNumber.java similarity index 100% rename from infinity/datatype/RemovableDecNumber.java rename to src/infinity/datatype/RemovableDecNumber.java diff --git a/infinity/datatype/ResourceRef.java b/src/infinity/datatype/ResourceRef.java similarity index 98% rename from infinity/datatype/ResourceRef.java rename to src/infinity/datatype/ResourceRef.java index 632d5e0..20aecb0 100644 --- a/infinity/datatype/ResourceRef.java +++ b/src/infinity/datatype/ResourceRef.java @@ -132,7 +132,8 @@ public void mouseClicked(MouseEvent event) bUpdate.setActionCommand(StructViewer.UPDATE_VALUE); bView = new JButton("View/Edit", Icons.getIcon("Zoom16.gif")); bView.addActionListener(this); - bView.setEnabled(list.getSelectedValue() != null && list.getSelectedValue() != NONE); + bView.setEnabled(list.getSelectedValue() != null && list.getSelectedValue() != NONE && + ((ResourceRefEntry)list.getSelectedValue()).entry != null); list.addListSelectionListener(this); GridBagLayout gbl = new GridBagLayout(); diff --git a/infinity/datatype/SectionCount.java b/src/infinity/datatype/SectionCount.java similarity index 100% rename from infinity/datatype/SectionCount.java rename to src/infinity/datatype/SectionCount.java diff --git a/infinity/datatype/SectionOffset.java b/src/infinity/datatype/SectionOffset.java similarity index 100% rename from infinity/datatype/SectionOffset.java rename to src/infinity/datatype/SectionOffset.java diff --git a/infinity/datatype/Song2daBitmap.java b/src/infinity/datatype/Song2daBitmap.java similarity index 100% rename from infinity/datatype/Song2daBitmap.java rename to src/infinity/datatype/Song2daBitmap.java diff --git a/infinity/datatype/SpawnResourceRef.java b/src/infinity/datatype/SpawnResourceRef.java similarity index 100% rename from infinity/datatype/SpawnResourceRef.java rename to src/infinity/datatype/SpawnResourceRef.java diff --git a/infinity/datatype/StringRef.java b/src/infinity/datatype/StringRef.java similarity index 100% rename from infinity/datatype/StringRef.java rename to src/infinity/datatype/StringRef.java diff --git a/infinity/datatype/TextBitmap.java b/src/infinity/datatype/TextBitmap.java similarity index 100% rename from infinity/datatype/TextBitmap.java rename to src/infinity/datatype/TextBitmap.java diff --git a/infinity/datatype/TextString.java b/src/infinity/datatype/TextString.java similarity index 100% rename from infinity/datatype/TextString.java rename to src/infinity/datatype/TextString.java diff --git a/infinity/datatype/Unknown.java b/src/infinity/datatype/Unknown.java similarity index 100% rename from infinity/datatype/Unknown.java rename to src/infinity/datatype/Unknown.java diff --git a/infinity/datatype/UnknownBinary.java b/src/infinity/datatype/UnknownBinary.java similarity index 100% rename from infinity/datatype/UnknownBinary.java rename to src/infinity/datatype/UnknownBinary.java diff --git a/infinity/datatype/UnknownDecimal.java b/src/infinity/datatype/UnknownDecimal.java similarity index 100% rename from infinity/datatype/UnknownDecimal.java rename to src/infinity/datatype/UnknownDecimal.java diff --git a/infinity/datatype/UnsignDecNumber.java b/src/infinity/datatype/UnsignDecNumber.java similarity index 100% rename from infinity/datatype/UnsignDecNumber.java rename to src/infinity/datatype/UnsignDecNumber.java diff --git a/infinity/gui/BIFFEditor.java b/src/infinity/gui/BIFFEditor.java similarity index 100% rename from infinity/gui/BIFFEditor.java rename to src/infinity/gui/BIFFEditor.java diff --git a/infinity/gui/BIFFEditorTable.java b/src/infinity/gui/BIFFEditorTable.java similarity index 100% rename from infinity/gui/BIFFEditorTable.java rename to src/infinity/gui/BIFFEditorTable.java diff --git a/infinity/gui/BcsDropFrame.java b/src/infinity/gui/BcsDropFrame.java similarity index 100% rename from infinity/gui/BcsDropFrame.java rename to src/infinity/gui/BcsDropFrame.java diff --git a/infinity/gui/BrowserMenuBar.java b/src/infinity/gui/BrowserMenuBar.java similarity index 96% rename from infinity/gui/BrowserMenuBar.java rename to src/infinity/gui/BrowserMenuBar.java index def1181..f236837 100644 --- a/infinity/gui/BrowserMenuBar.java +++ b/src/infinity/gui/BrowserMenuBar.java @@ -30,7 +30,7 @@ public final class BrowserMenuBar extends JMenuBar { - public static final String VERSION = "v1.33 beta 20"; + public static final String VERSION = "v1.33 w1.1.0"; public static final int OVERRIDE_IN_THREE = 0, OVERRIDE_IN_OVERRIDE = 1, OVERRIDE_SPLIT = 2; public static final int LOOKFEEL_JAVA = 0, LOOKFEEL_WINDOWS = 1, LOOKFEEL_MOTIF = 2, LOOKFEEL_PLASTICXP = 3; public static final int RESREF_ONLY = 0, RESREF_REF_NAME = 1, RESREF_NAME_REF = 2; @@ -41,6 +41,7 @@ public final class BrowserMenuBar extends JMenuBar new Font("SansSerif", Font.PLAIN, 12), new Font("Lucida", Font.PLAIN, 12)}; private static final String BCSINDENT[] = {" ", " ", "\t"}; + private static final String AUDIODECODERS[] = {"acm2wav.exe", "acmtool"}; private static final String OPTION_SHOWOFFSETS = "ShowOffsets"; private static final String OPTION_IGNOREOVERRIDE = "IgnoreOverride"; private static final String OPTION_IGNOREREADERRORS = "IgnoreReadErrors"; @@ -48,6 +49,7 @@ public final class BrowserMenuBar extends JMenuBar private static final String OPTION_AUTOCONVERT_WAV = "AutoconvertWAV"; private static final String OPTION_AUTOCHECK_BCS = "AutocheckBCS"; private static final String OPTION_CACHEOVERRIDE = "CacheOverride"; + private static final String OPTION_CHECKSCRIPTNAMES = "CheckScriptNames"; private static final String OPTION_SHOWOVERRIDES = "ShowOverridesIn"; private static final String OPTION_SHOWRESREF = "ShowResRef"; private static final String OPTION_LOOKANDFEEL = "LookAndFeel"; @@ -55,6 +57,7 @@ public final class BrowserMenuBar extends JMenuBar private static final String OPTION_FONT = "Font"; private static final String OPTION_BCSINDENT = "BcsIndent"; private static final String OPTION_TLKCHARSET = "TLKCharset"; + private static final String OPTION_AUDIODECODER = "AudioDecoder"; private final EditMenu editMenu; private final FileMenu fileMenu; private final GameMenu gameMenu; @@ -64,6 +67,7 @@ public final class BrowserMenuBar extends JMenuBar private final JRadioButtonMenuItem viewOrEditShown[] = new JRadioButtonMenuItem[3]; private final JRadioButtonMenuItem selectFont[] = new JRadioButtonMenuItem[FONTS.length]; private final JRadioButtonMenuItem selectBcsIndent[] = new JRadioButtonMenuItem[BCSINDENT.length]; + private final JRadioButtonMenuItem selectAudioDecoder[] = new JRadioButtonMenuItem[AUDIODECODERS.length]; private JCheckBoxMenuItem optionShowOffset, optionIgnoreOverride, optionIgnoreReadErrors, optionAutoConvMUS; private JCheckBoxMenuItem optionAutoConvWAV, optionAutocheckBCS, optionCacheOverride, optionCheckScriptNames; @@ -142,6 +146,17 @@ public String getBcsIndent() return BCSINDENT[2]; } + /** + * @since 2012-08-20 + */ + public String getAudioDecoder() + { + for (int i = 0; i < AUDIODECODERS.length; i++) + if (selectAudioDecoder[i].isSelected()) + return AUDIODECODERS[i]; + return AUDIODECODERS[0]; + } + public int getDefaultStructView() { if (viewOrEditShown[DEFAULT_VIEW].isSelected()) @@ -219,6 +234,7 @@ public void storePreferences() prefs.putBoolean(OPTION_AUTOCONVERT_WAV, optionAutoConvWAV.isSelected()); prefs.putBoolean(OPTION_AUTOCHECK_BCS, optionAutocheckBCS.isSelected()); prefs.putBoolean(OPTION_CACHEOVERRIDE, optionCacheOverride.isSelected()); + prefs.putBoolean(OPTION_CHECKSCRIPTNAMES, optionCheckScriptNames.isSelected()); prefs.putInt(OPTION_SHOWRESREF, getResRefMode()); prefs.putInt(OPTION_SHOWOVERRIDES, getOverrideMode()); prefs.putInt(OPTION_LOOKANDFEEL, getLookAndFeel()); @@ -232,8 +248,13 @@ public void storePreferences() for (int i = 0; i < selectBcsIndent.length; i++) if (selectBcsIndent[i].isSelected()) selectedIndent = i; + int audioDecoder = 0; + for (int i = 0; i < selectAudioDecoder.length; i++) + if (selectAudioDecoder[i].isSelected()) + audioDecoder = i; prefs.putInt(OPTION_BCSINDENT, selectedIndent); prefs.put(OPTION_TLKCHARSET, StringResource.getCharset().name()); + prefs.putInt(OPTION_AUDIODECODER, audioDecoder); gameMenu.storePreferences(prefs); } @@ -269,6 +290,11 @@ private JMenu makeOptionsMenu(Preferences prefs, NearInfinity browser) optionCacheOverride.setToolTipText("Without this option selected, Refresh Tree is required " + "to discover new override files added while NI is open"); menu.add(optionCacheOverride); + optionCheckScriptNames = + new JCheckBoxMenuItem("Interactive script names", prefs.getBoolean(OPTION_CHECKSCRIPTNAMES, true)); + optionCheckScriptNames.setToolTipText("With this option disabled, performance may be boosted " + + "but many features involving script names will be disabled."); + menu.add(optionCheckScriptNames); menu.addSeparator(); @@ -400,6 +426,17 @@ public void actionPerformed(ActionEvent event) { } } }); + + final JMenu audioDecoderMenu = new JMenu("Sound Converter"); + menu.add(audioDecoderMenu); + bg = new ButtonGroup(); + int audioDecoder = prefs.getInt(OPTION_AUDIODECODER, 0); + for (int i = 0; i < AUDIODECODERS.length; i++) { + selectAudioDecoder[i] = new JRadioButtonMenuItem(AUDIODECODERS[i], i == audioDecoder); + audioDecoderMenu.add(selectAudioDecoder[i]); + bg.add(selectAudioDecoder[i]); + } + tf.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent event) { // only trigger when states differ diff --git a/infinity/gui/ButtonPopupMenu.java b/src/infinity/gui/ButtonPopupMenu.java similarity index 100% rename from infinity/gui/ButtonPopupMenu.java rename to src/infinity/gui/ButtonPopupMenu.java diff --git a/infinity/gui/Center.java b/src/infinity/gui/Center.java similarity index 100% rename from infinity/gui/Center.java rename to src/infinity/gui/Center.java diff --git a/infinity/gui/ChildFrame.java b/src/infinity/gui/ChildFrame.java similarity index 100% rename from infinity/gui/ChildFrame.java rename to src/infinity/gui/ChildFrame.java diff --git a/infinity/gui/ChooseBIFFrame.java b/src/infinity/gui/ChooseBIFFrame.java similarity index 100% rename from infinity/gui/ChooseBIFFrame.java rename to src/infinity/gui/ChooseBIFFrame.java diff --git a/infinity/gui/ClipboardViewer.java b/src/infinity/gui/ClipboardViewer.java similarity index 100% rename from infinity/gui/ClipboardViewer.java rename to src/infinity/gui/ClipboardViewer.java diff --git a/infinity/gui/DebugConsole.java b/src/infinity/gui/DebugConsole.java similarity index 100% rename from infinity/gui/DebugConsole.java rename to src/infinity/gui/DebugConsole.java diff --git a/infinity/gui/IdsBrowser.java b/src/infinity/gui/IdsBrowser.java similarity index 100% rename from infinity/gui/IdsBrowser.java rename to src/infinity/gui/IdsBrowser.java diff --git a/infinity/gui/InfinityAmp.java b/src/infinity/gui/InfinityAmp.java similarity index 100% rename from infinity/gui/InfinityAmp.java rename to src/infinity/gui/InfinityAmp.java diff --git a/infinity/gui/LinkButton.java b/src/infinity/gui/LinkButton.java similarity index 100% rename from infinity/gui/LinkButton.java rename to src/infinity/gui/LinkButton.java diff --git a/infinity/gui/OpenFileFrame.java b/src/infinity/gui/OpenFileFrame.java similarity index 99% rename from infinity/gui/OpenFileFrame.java rename to src/infinity/gui/OpenFileFrame.java index 1f7b43f..ea07dee 100644 --- a/infinity/gui/OpenFileFrame.java +++ b/src/infinity/gui/OpenFileFrame.java @@ -153,7 +153,7 @@ public void mouseClicked(MouseEvent event) gbl.setConstraints(cbStayOpen, gbc); pane.add(cbStayOpen); - setSize(300, 400); + setSize(330, 400); Center.center(this, NearInfinity.getInstance().getBounds()); } diff --git a/infinity/gui/ResourceTree.java b/src/infinity/gui/ResourceTree.java similarity index 100% rename from infinity/gui/ResourceTree.java rename to src/infinity/gui/ResourceTree.java diff --git a/infinity/gui/ScriptTextArea.java b/src/infinity/gui/ScriptTextArea.java similarity index 94% rename from infinity/gui/ScriptTextArea.java rename to src/infinity/gui/ScriptTextArea.java index 6ade527..7fdc361 100644 --- a/infinity/gui/ScriptTextArea.java +++ b/src/infinity/gui/ScriptTextArea.java @@ -1,388 +1,388 @@ -package infinity.gui; - -import infinity.NearInfinity; -import infinity.resource.Resource; -import infinity.resource.ResourceFactory; -import infinity.resource.bcs.Compiler; -import infinity.resource.key.ResourceEntry; -import infinity.util.IdsMapCache; -import infinity.util.IdsMapEntry; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Stroke; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Set; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JTextArea; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; - -public class ScriptTextArea extends JTextArea { - ScriptPopupMenu menu = new ScriptPopupMenu(); - - public ScriptTextArea() { - super(); - addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent ev) { - handlePopup(ev); - } - - public void mouseReleased(MouseEvent ev) { - handlePopup(ev); - } - }); - } - - // try to paint an indicator below "crosslinks" - protected void paintComponent(Graphics g) { - super.paintComponent(g); - Rectangle rect = g.getClipBounds(); - - // try to get the "lines" which need to be painted - int upperLine = 0; - int lowerLine = 0; - try { - upperLine = getLineOfOffset(viewToModel(new Point(rect.x, rect.y))); - lowerLine = getLineOfOffset(viewToModel(new Point(rect.x + rect.width, - rect.y + rect.height))); - } catch (BadLocationException e) { } - //System.err.println("would consider drawing from lines " + upperLine + " to " + lowerLine); - for (int line = upperLine; line <= lowerLine; line++) { - try { - int start = getLineStartOffset(line); - int end = getLineEndOffset(line) - 1; // newline - - int[][] linkOffsets = findLinksInSection(start, end); - if (linkOffsets.length == 0) { - continue; - } - - Graphics2D g2d = (Graphics2D) g; - // clear that line before doing anything - Color oldColor = g2d.getColor(); - g2d.setColor(getBackground()); - Rectangle rectStart = modelToView(start); - Rectangle rectEnd = modelToView(end); - g2d.drawLine(rectStart.x, rectStart.y + rectStart.height, - rectEnd.x, rectEnd.y + rectEnd.height); - g2d.setColor(oldColor); - - Stroke oldStroke = g2d.getStroke(); - g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, - 1, new float[] { 1, 2 }, 0)); - // now underline the crosslinks - for (int[] pair : linkOffsets) { - // convert into view coordinates - rectStart = modelToView(pair[0]); - rectEnd = modelToView(pair[1]); - g2d.drawLine(rectStart.x, rectStart.y + rectStart.height, - rectEnd.x, rectEnd.y + rectEnd.height); - } - g2d.setStroke(oldStroke); - } catch (BadLocationException e) { } - } - } - - // looks for "crosslinks" in script lines - private int[][] findLinksInSection(int start, int end) throws BadLocationException { - ArrayList links = new ArrayList(); - String linetext = getText(start, end - start); - - int posStartToken = -1; - for (int i = 0; i < linetext.length(); i++) { - if (linetext.charAt(i) == '"') { - if (posStartToken != -1) { - // found a "word", so check for possible crosslink - String token = linetext.substring(posStartToken + 1, i); - - if (findResEntry(linetext, posStartToken + 1, token) != null) { - // add it to our list of crosslinks - links.add(new int[] { start + posStartToken + 1, start + i }); - } - posStartToken = -1; - } - else { - posStartToken = i; - } - } - } - return links.toArray(new int[0][0]); - } - - private void handlePopup(MouseEvent ev) { - if (ev.isPopupTrigger()) { - try { - // get "word" under click - Document doc = getDocument(); - int offset = viewToModel(ev.getPoint()); - final int lineNr = getLineOfOffset(offset); - final int lineStart = getLineStartOffset(lineNr); - String line = doc.getText(lineStart, getLineEndOffset(lineNr) - lineStart); - offset = offset - lineStart; - - String token = getToken(line, offset, "\"", "(), "); // quoted - if (token == null) { - // fall back to ids token parsing - token = getToken(line, offset, ",()", "[].\" "); // IDS - if (token == null) { - return; - } - } - - ResourceEntry resEntry = findResEntry(line, offset, token); - menu.setResEntry(resEntry); - - if (resEntry != null) { - menu.show(this, ev.getX(), ev.getY()); - } - } - catch (BadLocationException ble) {} - } - } - - private String getToken(String line, int offset, String delims, String invalidChars) { - int tokenStart, tokenEnd; - for (tokenStart = offset; tokenStart > 0; tokenStart--) { - char current = line.charAt(tokenStart); - if (delims.indexOf(current) != -1) { - tokenStart++; - break; - } - else if (invalidChars.indexOf(current) != -1) { - return null; - } - } - for (tokenEnd = offset + 1; tokenEnd < line.length(); tokenEnd++) { - char current = line.charAt(tokenEnd); - if (delims.indexOf(current) != -1) { - break; - } - else if (invalidChars.indexOf(current) != -1) { - return null; - } - } - return line.substring(tokenStart, tokenEnd); - } - - private ResourceEntry findResEntry(String line, int offset, String token) { - // determine function name and param position - int parenLevel = 0; - int paramPos = 0; - int idx; - for (idx = offset; idx > 0; idx--) { - char current = line.charAt(idx); - if (current == ')') { - parenLevel++; - } - else if ((current == ',') && (parenLevel == 0)) { - paramPos++; - } - else if (current == '(') { - if (parenLevel == 0) { - // found end of corresponding function name - break; - } - parenLevel--; - } - } - - int endPos = idx; - while ((idx > 0) && (Character.isLetter(line.charAt(idx - 1)))) { - idx--; - } - String function = line.substring(idx, endPos); - - // lookup function name in trigger.ids / action.ids - String[] idsFiles = new String[] { "trigger.ids", "action.ids" }; - for (final String idsFile : idsFiles) { - IdsMapEntry idsEntry = IdsMapCache.get(idsFile).lookup(function + "("); - if (idsEntry != null) { - String[] paramDefs = idsEntry.getParameters().split(","); - String definition = paramDefs[paramPos]; - - // check script names (death var) - if (definition.equalsIgnoreCase("O:Object*") - || definition.equalsIgnoreCase("O:Target*") - || definition.equalsIgnoreCase("O:Actor*") - || (definition.equalsIgnoreCase("S:Name*") - && (function.equalsIgnoreCase("Dead") - || function.equalsIgnoreCase("Name") - || function.equalsIgnoreCase("NumDead(") - || function.equalsIgnoreCase("NumDeadGT(") - || function.equalsIgnoreCase("NumDeadLT(")))) { - Compiler bcscomp = Compiler.getInstance(); - if (bcscomp.hasScriptName(token)) { - Set entries = bcscomp.getResForScriptName(token); - for (ResourceEntry entry : entries) { - // for now, just return the first entry - return entry; - } - } - else { - return null; - } - } - - // spell.ids - if (definition.equalsIgnoreCase("I:Spell*Spell")) { - IdsMapEntry idsSpell = IdsMapCache.get("spell.ids").lookup(token); - if (idsSpell != null) { - String spellID = String.valueOf(idsSpell.getID()); - int type = Character.digit(spellID.charAt(0), 10); - String splfile; - switch (type) { - case 1: - splfile = "SPPR"; - break; - - case 2: - splfile = "SPWI"; - break; - - case 3: - splfile = "SPIN"; - break; - - case 4: - splfile = "SPCL"; - break; - - default: - return null; - } - splfile += spellID.substring(1) + ".SPL"; - if (ResourceFactory.getInstance().resourceExists(splfile)) { - return ResourceFactory.getInstance().getResourceEntry(splfile); - } - - } - - // found nothing, if this line is reached - return null; - } - - // guessing - String[] possibleExtensions = guessExtension(function, definition); - for (final String ext : possibleExtensions) { - if (ResourceFactory.getInstance().resourceExists(token + ext)) { - return ResourceFactory.getInstance().getResourceEntry(token + ext); - } - } - - break; - } - } - return null; - } - - // most parts stolen from Compiler.java - private String[] guessExtension(String function, String definition) { - definition = definition.trim(); - // first the unique values - if (definition.equalsIgnoreCase("S:Area*") - || definition.equalsIgnoreCase("S:Area1*") - || definition.equalsIgnoreCase("S:Area2*") - || definition.equalsIgnoreCase("S:ToArea*") - || definition.equalsIgnoreCase("S:Areaname*") - || definition.equalsIgnoreCase("S:FromArea*")) { - return new String[] { ".ARE" }; - } - else if (definition.equalsIgnoreCase("S:BamResRef*")) { - return new String[] { ".BAM" }; - } - else if (definition.equals("S:CutScene*") - || definition.equalsIgnoreCase("S:ScriptFile*") - || definition.equalsIgnoreCase("S:Script*")) { - return new String[] { ".BCS" }; - } - else if (definition.equalsIgnoreCase("S:Palette*")) { - return new String[] { ".BMP" }; - } - else if (definition.equalsIgnoreCase("S:Item*") - || definition.equalsIgnoreCase("S:Take*") - || definition.equalsIgnoreCase("S:Give*") - || definition.equalsIgnoreCase("S:Item") - || definition.equalsIgnoreCase("S:OldObject*")) { - return new String[] { ".ITM" }; - } - else if (definition.equalsIgnoreCase("S:Parchment*")) { - return new String[] { ".MOS" }; - } - else if (definition.equalsIgnoreCase("S:Spell*") - || definition.equalsIgnoreCase("S:Res*")) { - return new String[] { ".SPL" }; - } - else if (definition.equalsIgnoreCase("S:Pool*")) { - return new String[] { ".SRC" }; - } - else if (definition.startsWith("S:Store*")) { - return new String[] { ".STO" }; - } - else if (definition.equalsIgnoreCase("S:Sound*") - || definition.equalsIgnoreCase("S:Voice*")) { - return new String[] { ".WAV" }; - } - else if (definition.equalsIgnoreCase("S:TextList*")) { - return new String[] { ".2DA" }; - } - // and now the ambiguous - else if (definition.equalsIgnoreCase("S:Effect*")) { - return new String[] { ".BAM", ".VVC" }; - } - else if (definition.equalsIgnoreCase("S:DialogFile*")) { - return new String[] { ".DLG", ".VVC" }; - } - else if (definition.equalsIgnoreCase("S:Object*")) { - return new String[] { ".ITM", ".VVC", ".BAM" }; - } - else if (definition.equalsIgnoreCase("S:NewObject*")) { - return new String[] { ".CRE", ".DLG", ".BCS", ".ITM" }; - } - else if (definition.equalsIgnoreCase("S:ResRef*")) { - return new String[]{".CRE", ".ITM", ".ARE", ".2DA", ".BCS", - ".MVE", ".SPL", ".DLG", ".VVC", ".BAM"}; - } - - return new String[] {}; - } - - private class ScriptPopupMenu extends JPopupMenu implements ActionListener { - private ResourceEntry resourceEntry = null; - private final JMenuItem mi_open = new JMenuItem("Open"); - private final JMenuItem mi_opennew = new JMenuItem("Open in new window"); - - ScriptPopupMenu() { - add(mi_open); - add(mi_opennew); - - mi_open.addActionListener(this); - mi_opennew.addActionListener(this); - } - - public void setResEntry(ResourceEntry resEntry) { - this.resourceEntry = resEntry; - } - public void actionPerformed(ActionEvent ev) { - if (ev.getSource() == mi_open) { - NearInfinity.getInstance().showResourceEntry(resourceEntry); - } - else if (ev.getSource() == mi_opennew) { - Resource res = ResourceFactory.getResource(resourceEntry); - new ViewFrame(NearInfinity.getInstance(), res); - } - } - } -} +package infinity.gui; + +import infinity.NearInfinity; +import infinity.resource.Resource; +import infinity.resource.ResourceFactory; +import infinity.resource.bcs.Compiler; +import infinity.resource.bcs.Decompiler; +import infinity.resource.key.ResourceEntry; +import infinity.util.IdsMapCache; +import infinity.util.IdsMapEntry; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Stroke; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Set; + +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.JTextArea; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; + +public class ScriptTextArea extends JTextArea { + ScriptPopupMenu menu = new ScriptPopupMenu(); + + public ScriptTextArea() { + super(); + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent ev) { + handlePopup(ev); + } + + public void mouseReleased(MouseEvent ev) { + handlePopup(ev); + } + }); + } + + // try to paint an indicator below "crosslinks" + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Rectangle rect = g.getClipBounds(); + + // try to get the "lines" which need to be painted + int upperLine = 0; + int lowerLine = 0; + try { + upperLine = getLineOfOffset(viewToModel(new Point(rect.x, rect.y))); + lowerLine = getLineOfOffset(viewToModel(new Point(rect.x + rect.width, + rect.y + rect.height))); + } catch (BadLocationException e) { } + //System.err.println("would consider drawing from lines " + upperLine + " to " + lowerLine); + for (int line = upperLine; line <= lowerLine; line++) { + try { + int start = getLineStartOffset(line); + int end = getLineEndOffset(line) - 1; // newline + + int[][] linkOffsets = findLinksInSection(start, end); + if (linkOffsets.length == 0) { + continue; + } + + Graphics2D g2d = (Graphics2D) g; + // clear that line before doing anything + Color oldColor = g2d.getColor(); + g2d.setColor(getBackground()); + Rectangle rectStart = modelToView(start); + Rectangle rectEnd = modelToView(end); + g2d.drawLine(rectStart.x, rectStart.y + rectStart.height, + rectEnd.x, rectEnd.y + rectEnd.height); + g2d.setColor(oldColor); + + Stroke oldStroke = g2d.getStroke(); + g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, + 1, new float[] { 1, 2 }, 0)); + // now underline the crosslinks + for (int[] pair : linkOffsets) { + // convert into view coordinates + rectStart = modelToView(pair[0]); + rectEnd = modelToView(pair[1]); + g2d.drawLine(rectStart.x, rectStart.y + rectStart.height, + rectEnd.x, rectEnd.y + rectEnd.height); + } + g2d.setStroke(oldStroke); + } catch (BadLocationException e) { } + } + } + + // looks for "crosslinks" in script lines + private int[][] findLinksInSection(int start, int end) throws BadLocationException { + ArrayList links = new ArrayList(); + String linetext = getText(start, end - start); + + int posStartToken = -1; + for (int i = 0; i < linetext.length(); i++) { + if (linetext.charAt(i) == '"') { + if (posStartToken != -1) { + // found a "word", so check for possible crosslink + String token = linetext.substring(posStartToken + 1, i); + + if (findResEntry(linetext, posStartToken + 1, token) != null) { + // add it to our list of crosslinks + links.add(new int[] { start + posStartToken + 1, start + i }); + } + posStartToken = -1; + } + else { + posStartToken = i; + } + } + } + return links.toArray(new int[0][0]); + } + + private void handlePopup(MouseEvent ev) { + if (ev.isPopupTrigger()) { + try { + // get "word" under click + Document doc = getDocument(); + int offset = viewToModel(ev.getPoint()); + final int lineNr = getLineOfOffset(offset); + final int lineStart = getLineStartOffset(lineNr); + String line = doc.getText(lineStart, getLineEndOffset(lineNr) - lineStart); + offset = offset - lineStart; + + String token = getToken(line, offset, "\"", "(), "); // quoted + if (token == null) { + // fall back to ids token parsing + token = getToken(line, offset, ",()", "[].\" "); // IDS + if (token == null) { + return; + } + } + + ResourceEntry resEntry = findResEntry(line, offset, token); + menu.setResEntry(resEntry); + + if (resEntry != null) { + menu.show(this, ev.getX(), ev.getY()); + } + } + catch (BadLocationException ble) {} + } + } + + private String getToken(String line, int offset, String delims, String invalidChars) { + int tokenStart, tokenEnd; + for (tokenStart = offset; tokenStart > 0; tokenStart--) { + char current = line.charAt(tokenStart); + if (delims.indexOf(current) != -1) { + tokenStart++; + break; + } + else if (invalidChars.indexOf(current) != -1) { + return null; + } + } + for (tokenEnd = offset + 1; tokenEnd < line.length(); tokenEnd++) { + char current = line.charAt(tokenEnd); + if (delims.indexOf(current) != -1) { + break; + } + else if (invalidChars.indexOf(current) != -1) { + return null; + } + } + return line.substring(tokenStart, tokenEnd); + } + + private ResourceEntry findResEntry(String line, int offset, String token) { + // determine function name and param position + int parenLevel = 0; + int paramPos = 0; + int idx; + for (idx = offset; idx > 0; idx--) { + char current = line.charAt(idx); + if (current == ')') { + parenLevel++; + } + else if ((current == ',') && (parenLevel == 0)) { + paramPos++; + } + else if (current == '(') { + if (parenLevel == 0) { + // found end of corresponding function name + break; + } + parenLevel--; + } + } + + int endPos = idx; + while ((idx > 0) && (Character.isLetter(line.charAt(idx - 1)))) { + idx--; + } + String function = line.substring(idx, endPos); + + // lookup function name in trigger.ids / action.ids + String[] idsFiles = new String[] { "trigger.ids", "action.ids" }; + for (final String idsFile : idsFiles) { + IdsMapEntry idsEntry = IdsMapCache.get(idsFile).lookup(function + "("); + if (idsEntry != null) { + String[] paramDefs = idsEntry.getParameters().split(","); + String definition = paramDefs[paramPos]; + + // check script names (death var) + if (definition.equalsIgnoreCase("O:Object*") + || definition.equalsIgnoreCase("O:Target*") + || definition.equalsIgnoreCase("O:Actor*") + || (definition.equalsIgnoreCase("S:Name*") + && (function.equalsIgnoreCase("Dead") + || function.equalsIgnoreCase("Name") + || function.equalsIgnoreCase("NumDead") + || function.equalsIgnoreCase("NumDeadGT") + || function.equalsIgnoreCase("NumDeadLT")))) { + Compiler bcscomp = Compiler.getInstance(); + if (bcscomp.hasScriptName(token)) { + Set entries = bcscomp.getResForScriptName(token); + for (ResourceEntry entry : entries) { + // for now, just return the first entry + return entry; + } + } + else { + return null; + } + } + + // spell.ids + if (definition.equalsIgnoreCase("I:Spell*Spell")) { + IdsMapEntry idsSpell = IdsMapCache.get("spell.ids").lookup(token); + if (idsSpell != null) { + String spellID = String.valueOf(idsSpell.getID()); + int type = Character.digit(spellID.charAt(0), 10); + String splfile; + switch (type) { + case 1: + splfile = "SPPR"; + break; + + case 2: + splfile = "SPWI"; + break; + + case 3: + splfile = "SPIN"; + break; + + case 4: + splfile = "SPCL"; + break; + + default: + return null; + } + splfile += spellID.substring(1) + ".SPL"; + if (ResourceFactory.getInstance().resourceExists(splfile)) { + return ResourceFactory.getInstance().getResourceEntry(splfile); + } + + } + + // found nothing, if this line is reached + return null; + } + + // guessing + String[] possibleExtensions = guessExtension(function, definition); + for (final String ext : possibleExtensions) { + if (ResourceFactory.getInstance().resourceExists(token + ext)) { + return ResourceFactory.getInstance().getResourceEntry(token + ext); + } + } + + break; + } + } + return null; + } + + // most parts stolen from Compiler.java + private String[] guessExtension(String function, String definition) { + definition = definition.trim(); + // first the unique values + if (definition.equalsIgnoreCase("S:Area*") + || definition.equalsIgnoreCase("S:Area1*") + || definition.equalsIgnoreCase("S:Area2*") + || definition.equalsIgnoreCase("S:ToArea*") + || definition.equalsIgnoreCase("S:Areaname*") + || definition.equalsIgnoreCase("S:FromArea*")) { + return new String[] { ".ARE" }; + } + else if (definition.equalsIgnoreCase("S:BamResRef*")) { + return new String[] { ".BAM" }; + } + else if (definition.equals("S:CutScene*") + || definition.equalsIgnoreCase("S:ScriptFile*") + || definition.equalsIgnoreCase("S:Script*")) { + return new String[] { ".BCS" }; + } + else if (definition.equalsIgnoreCase("S:Palette*")) { + return new String[] { ".BMP" }; + } + else if (definition.equalsIgnoreCase("S:Item*") + || definition.equalsIgnoreCase("S:Take*") + || definition.equalsIgnoreCase("S:Give*") + || definition.equalsIgnoreCase("S:Item") + || definition.equalsIgnoreCase("S:OldObject*")) { + return new String[] { ".ITM" }; + } + else if (definition.equalsIgnoreCase("S:Parchment*")) { + return new String[] { ".MOS" }; + } + else if (definition.equalsIgnoreCase("S:Spell*") + || definition.equalsIgnoreCase("S:Res*")) { + return new String[] { ".SPL" }; + } + else if (definition.equalsIgnoreCase("S:Pool*")) { + return new String[] { ".SRC" }; + } + else if (definition.startsWith("S:Store*")) { + return new String[] { ".STO" }; + } + else if (definition.equalsIgnoreCase("S:Sound*") + || definition.equalsIgnoreCase("S:Voice*")) { + return new String[] { ".WAV" }; + } + else if (definition.equalsIgnoreCase("S:TextList*")) { + return new String[] { ".2DA" }; + } + // and now the ambiguous + else if (definition.equalsIgnoreCase("S:Effect*")) { + return new String[] { ".BAM", ".VVC" }; + } + else if (definition.equalsIgnoreCase("S:DialogFile*")) { + return new String[] { ".DLG", ".VVC" }; + } + else if (definition.equalsIgnoreCase("S:Object*")) { + return new String[] { ".ITM", ".VVC", ".BAM" }; + } + else if (definition.equalsIgnoreCase("S:NewObject*")) { + return new String[] { ".CRE", ".DLG", ".BCS", ".ITM" }; + } + else if (definition.equalsIgnoreCase("S:ResRef*")) { + return Decompiler.getResRefType(function); + } + + return new String[] {}; + } + + private class ScriptPopupMenu extends JPopupMenu implements ActionListener { + private ResourceEntry resourceEntry = null; + private final JMenuItem mi_open = new JMenuItem("Open"); + private final JMenuItem mi_opennew = new JMenuItem("Open in new window"); + + ScriptPopupMenu() { + add(mi_open); + add(mi_opennew); + + mi_open.addActionListener(this); + mi_opennew.addActionListener(this); + } + + public void setResEntry(ResourceEntry resEntry) { + this.resourceEntry = resEntry; + } + public void actionPerformed(ActionEvent ev) { + if (ev.getSource() == mi_open) { + NearInfinity.getInstance().showResourceEntry(resourceEntry); + } + else if (ev.getSource() == mi_opennew) { + Resource res = ResourceFactory.getResource(resourceEntry); + new ViewFrame(NearInfinity.getInstance(), res); + } + } + } +} diff --git a/infinity/gui/SortableTable.java b/src/infinity/gui/SortableTable.java similarity index 100% rename from infinity/gui/SortableTable.java rename to src/infinity/gui/SortableTable.java diff --git a/infinity/gui/StatusBar.java b/src/infinity/gui/StatusBar.java similarity index 100% rename from infinity/gui/StatusBar.java rename to src/infinity/gui/StatusBar.java diff --git a/infinity/gui/StringEditor.java b/src/infinity/gui/StringEditor.java similarity index 100% rename from infinity/gui/StringEditor.java rename to src/infinity/gui/StringEditor.java diff --git a/infinity/gui/StringLookup.java b/src/infinity/gui/StringLookup.java similarity index 98% rename from infinity/gui/StringLookup.java rename to src/infinity/gui/StringLookup.java index 20fe547..e62f8ba 100644 --- a/infinity/gui/StringLookup.java +++ b/src/infinity/gui/StringLookup.java @@ -46,7 +46,7 @@ final class StringLookup extends ChildFrame implements SearchClient gbl.setConstraints(findpanel, gbc); pane.add(findpanel); - setSize(500, 350); + setSize(540, 350); Center.center(this, NearInfinity.getInstance().getBounds()); } diff --git a/infinity/gui/StructViewer.java b/src/infinity/gui/StructViewer.java similarity index 99% rename from infinity/gui/StructViewer.java rename to src/infinity/gui/StructViewer.java index d2d68e1..371ad45 100644 --- a/infinity/gui/StructViewer.java +++ b/src/infinity/gui/StructViewer.java @@ -91,7 +91,7 @@ public final class StructViewer extends JPanel implements ListSelectionListener, private final CardLayout cards = new CardLayout(); private final JButton bview = new JButton("View/Edit", Icons.getIcon("Zoom16.gif")); private final JButton bexport = new JButton("Export...", Icons.getIcon("Export16.gif")); - private final JButton bprint = new JButton(Icons.getIcon("Print16.gif")); + private final JButton bprint = new JButton("Print", Icons.getIcon("Print16.gif")); private final JButton bremove = new JButton("Remove", Icons.getIcon("Remove16.gif")); private final JMenuItem ifindattribute = new JMenuItem("selected attribute"); private final JMenuItem ifindreferences = new JMenuItem("references to this file"); @@ -554,8 +554,8 @@ public void tableChanged(TableModelEvent event) { if (event.getType() == TableModelEvent.UPDATE) { StructEntry structEntry = struct.getStructEntryAt(event.getFirstRow()); - if (structEntry instanceof Editable && structEntry.getOffset() == editable.getOffset() && - structEntry != editable) { + if (structEntry instanceof Editable && (editable == null || (structEntry.getOffset() == editable.getOffset() && + structEntry != editable))) { editable = (Editable)structEntry; editpanel.removeAll(); diff --git a/infinity/gui/TableItem.java b/src/infinity/gui/TableItem.java similarity index 100% rename from infinity/gui/TableItem.java rename to src/infinity/gui/TableItem.java diff --git a/infinity/gui/TextListPanel.java b/src/infinity/gui/TextListPanel.java similarity index 100% rename from infinity/gui/TextListPanel.java rename to src/infinity/gui/TextListPanel.java diff --git a/infinity/gui/ToolTipTableCellRenderer.java b/src/infinity/gui/ToolTipTableCellRenderer.java similarity index 100% rename from infinity/gui/ToolTipTableCellRenderer.java rename to src/infinity/gui/ToolTipTableCellRenderer.java diff --git a/infinity/gui/ViewFrame.java b/src/infinity/gui/ViewFrame.java similarity index 100% rename from infinity/gui/ViewFrame.java rename to src/infinity/gui/ViewFrame.java diff --git a/infinity/gui/ViewerUtil.java b/src/infinity/gui/ViewerUtil.java similarity index 100% rename from infinity/gui/ViewerUtil.java rename to src/infinity/gui/ViewerUtil.java diff --git a/infinity/gui/WindowBlocker.java b/src/infinity/gui/WindowBlocker.java similarity index 100% rename from infinity/gui/WindowBlocker.java rename to src/infinity/gui/WindowBlocker.java diff --git a/infinity/gui/treetable/AbstractCellEditor.java b/src/infinity/gui/treetable/AbstractCellEditor.java similarity index 100% rename from infinity/gui/treetable/AbstractCellEditor.java rename to src/infinity/gui/treetable/AbstractCellEditor.java diff --git a/infinity/gui/treetable/AbstractTreeTableModel.java b/src/infinity/gui/treetable/AbstractTreeTableModel.java similarity index 100% rename from infinity/gui/treetable/AbstractTreeTableModel.java rename to src/infinity/gui/treetable/AbstractTreeTableModel.java diff --git a/infinity/gui/treetable/JTreeTable.java b/src/infinity/gui/treetable/JTreeTable.java similarity index 100% rename from infinity/gui/treetable/JTreeTable.java rename to src/infinity/gui/treetable/JTreeTable.java diff --git a/infinity/gui/treetable/TreeTableModel.java b/src/infinity/gui/treetable/TreeTableModel.java similarity index 100% rename from infinity/gui/treetable/TreeTableModel.java rename to src/infinity/gui/treetable/TreeTableModel.java diff --git a/infinity/gui/treetable/TreeTableModelAdapter.java b/src/infinity/gui/treetable/TreeTableModelAdapter.java similarity index 100% rename from infinity/gui/treetable/TreeTableModelAdapter.java rename to src/infinity/gui/treetable/TreeTableModelAdapter.java diff --git a/infinity/icon/About16.gif b/src/infinity/icon/About16.gif similarity index 100% rename from infinity/icon/About16.gif rename to src/infinity/icon/About16.gif diff --git a/infinity/icon/Add16.gif b/src/infinity/icon/Add16.gif similarity index 100% rename from infinity/icon/Add16.gif rename to src/infinity/icon/Add16.gif diff --git a/infinity/icon/Application16.gif b/src/infinity/icon/Application16.gif similarity index 100% rename from infinity/icon/Application16.gif rename to src/infinity/icon/Application16.gif diff --git a/infinity/icon/Back16.gif b/src/infinity/icon/Back16.gif similarity index 100% rename from infinity/icon/Back16.gif rename to src/infinity/icon/Back16.gif diff --git a/infinity/icon/BlueCircle16.gif b/src/infinity/icon/BlueCircle16.gif similarity index 100% rename from infinity/icon/BlueCircle16.gif rename to src/infinity/icon/BlueCircle16.gif diff --git a/infinity/icon/BlueCircle20.gif b/src/infinity/icon/BlueCircle20.gif similarity index 100% rename from infinity/icon/BlueCircle20.gif rename to src/infinity/icon/BlueCircle20.gif diff --git a/infinity/icon/Bundle16.gif b/src/infinity/icon/Bundle16.gif similarity index 100% rename from infinity/icon/Bundle16.gif rename to src/infinity/icon/Bundle16.gif diff --git a/infinity/icon/Check16.gif b/src/infinity/icon/Check16.gif similarity index 100% rename from infinity/icon/Check16.gif rename to src/infinity/icon/Check16.gif diff --git a/infinity/icon/Check_Not16.gif b/src/infinity/icon/Check_Not16.gif similarity index 100% rename from infinity/icon/Check_Not16.gif rename to src/infinity/icon/Check_Not16.gif diff --git a/infinity/icon/Circle20.gif b/src/infinity/icon/Circle20.gif similarity index 100% rename from infinity/icon/Circle20.gif rename to src/infinity/icon/Circle20.gif diff --git a/infinity/icon/Color16.gif b/src/infinity/icon/Color16.gif similarity index 100% rename from infinity/icon/Color16.gif rename to src/infinity/icon/Color16.gif diff --git a/infinity/icon/Copy16.gif b/src/infinity/icon/Copy16.gif similarity index 100% rename from infinity/icon/Copy16.gif rename to src/infinity/icon/Copy16.gif diff --git a/infinity/icon/Cut16.gif b/src/infinity/icon/Cut16.gif similarity index 100% rename from infinity/icon/Cut16.gif rename to src/infinity/icon/Cut16.gif diff --git a/infinity/icon/Delete16.gif b/src/infinity/icon/Delete16.gif similarity index 100% rename from infinity/icon/Delete16.gif rename to src/infinity/icon/Delete16.gif diff --git a/infinity/icon/Down16.gif b/src/infinity/icon/Down16.gif similarity index 100% rename from infinity/icon/Down16.gif rename to src/infinity/icon/Down16.gif diff --git a/infinity/icon/Edit16.gif b/src/infinity/icon/Edit16.gif similarity index 100% rename from infinity/icon/Edit16.gif rename to src/infinity/icon/Edit16.gif diff --git a/infinity/icon/End16.gif b/src/infinity/icon/End16.gif similarity index 100% rename from infinity/icon/End16.gif rename to src/infinity/icon/End16.gif diff --git a/infinity/icon/Exit16.gif b/src/infinity/icon/Exit16.gif similarity index 100% rename from infinity/icon/Exit16.gif rename to src/infinity/icon/Exit16.gif diff --git a/infinity/icon/Export16.gif b/src/infinity/icon/Export16.gif similarity index 100% rename from infinity/icon/Export16.gif rename to src/infinity/icon/Export16.gif diff --git a/infinity/icon/Find16.gif b/src/infinity/icon/Find16.gif similarity index 100% rename from infinity/icon/Find16.gif rename to src/infinity/icon/Find16.gif diff --git a/infinity/icon/FindAgain16.gif b/src/infinity/icon/FindAgain16.gif similarity index 100% rename from infinity/icon/FindAgain16.gif rename to src/infinity/icon/FindAgain16.gif diff --git a/infinity/icon/Forward16.gif b/src/infinity/icon/Forward16.gif similarity index 100% rename from infinity/icon/Forward16.gif rename to src/infinity/icon/Forward16.gif diff --git a/infinity/icon/GreenCircle16.gif b/src/infinity/icon/GreenCircle16.gif similarity index 100% rename from infinity/icon/GreenCircle16.gif rename to src/infinity/icon/GreenCircle16.gif diff --git a/infinity/icon/Help16.gif b/src/infinity/icon/Help16.gif similarity index 100% rename from infinity/icon/Help16.gif rename to src/infinity/icon/Help16.gif diff --git a/infinity/icon/History16.gif b/src/infinity/icon/History16.gif similarity index 100% rename from infinity/icon/History16.gif rename to src/infinity/icon/History16.gif diff --git a/infinity/icon/Icons.java b/src/infinity/icon/Icons.java similarity index 68% rename from infinity/icon/Icons.java rename to src/infinity/icon/Icons.java index eebee15..fa6e377 100644 --- a/infinity/icon/Icons.java +++ b/src/infinity/icon/Icons.java @@ -16,7 +16,14 @@ public static ImageIcon getIcon(String name) { ImageIcon icon = ICONMAP.get(name); if (icon == null) { - icon = new ImageIcon(Icons.class.getResource(name)); + java.net.URL resource = Icons.class.getResource(name); + if (resource == null) { + icon = new ImageIcon(); + System.err.println("Icon file not found: " + name); + } + else { + icon = new ImageIcon(resource); + } ICONMAP.put(name, icon); } return icon; diff --git a/infinity/icon/Import16.gif b/src/infinity/icon/Import16.gif similarity index 100% rename from infinity/icon/Import16.gif rename to src/infinity/icon/Import16.gif diff --git a/infinity/icon/Movie16.gif b/src/infinity/icon/Movie16.gif similarity index 100% rename from infinity/icon/Movie16.gif rename to src/infinity/icon/Movie16.gif diff --git a/infinity/icon/New16.gif b/src/infinity/icon/New16.gif similarity index 100% rename from infinity/icon/New16.gif rename to src/infinity/icon/New16.gif diff --git a/infinity/icon/Open16.gif b/src/infinity/icon/Open16.gif similarity index 100% rename from infinity/icon/Open16.gif rename to src/infinity/icon/Open16.gif diff --git a/infinity/icon/Paste16.gif b/src/infinity/icon/Paste16.gif similarity index 100% rename from infinity/icon/Paste16.gif rename to src/infinity/icon/Paste16.gif diff --git a/infinity/icon/Play16.gif b/src/infinity/icon/Play16.gif similarity index 100% rename from infinity/icon/Play16.gif rename to src/infinity/icon/Play16.gif diff --git a/infinity/icon/Print16.gif b/src/infinity/icon/Print16.gif similarity index 100% rename from infinity/icon/Print16.gif rename to src/infinity/icon/Print16.gif diff --git a/infinity/icon/Properties16.gif b/src/infinity/icon/Properties16.gif similarity index 100% rename from infinity/icon/Properties16.gif rename to src/infinity/icon/Properties16.gif diff --git a/infinity/icon/Redo16.gif b/src/infinity/icon/Redo16.gif similarity index 100% rename from infinity/icon/Redo16.gif rename to src/infinity/icon/Redo16.gif diff --git a/infinity/icon/Refresh16.gif b/src/infinity/icon/Refresh16.gif similarity index 100% rename from infinity/icon/Refresh16.gif rename to src/infinity/icon/Refresh16.gif diff --git a/infinity/icon/Release16.gif b/src/infinity/icon/Release16.gif similarity index 100% rename from infinity/icon/Release16.gif rename to src/infinity/icon/Release16.gif diff --git a/infinity/icon/Remove16.gif b/src/infinity/icon/Remove16.gif similarity index 100% rename from infinity/icon/Remove16.gif rename to src/infinity/icon/Remove16.gif diff --git a/infinity/icon/RowInsertAfter16.gif b/src/infinity/icon/RowInsertAfter16.gif similarity index 100% rename from infinity/icon/RowInsertAfter16.gif rename to src/infinity/icon/RowInsertAfter16.gif diff --git a/infinity/icon/Save16.gif b/src/infinity/icon/Save16.gif similarity index 100% rename from infinity/icon/Save16.gif rename to src/infinity/icon/Save16.gif diff --git a/infinity/icon/StepBack16.gif b/src/infinity/icon/StepBack16.gif similarity index 100% rename from infinity/icon/StepBack16.gif rename to src/infinity/icon/StepBack16.gif diff --git a/infinity/icon/StepForward16.gif b/src/infinity/icon/StepForward16.gif similarity index 100% rename from infinity/icon/StepForward16.gif rename to src/infinity/icon/StepForward16.gif diff --git a/infinity/icon/Stop16.gif b/src/infinity/icon/Stop16.gif similarity index 100% rename from infinity/icon/Stop16.gif rename to src/infinity/icon/Stop16.gif diff --git a/infinity/icon/Stop24.gif b/src/infinity/icon/Stop24.gif similarity index 100% rename from infinity/icon/Stop24.gif rename to src/infinity/icon/Stop24.gif diff --git a/infinity/icon/Undo16.gif b/src/infinity/icon/Undo16.gif similarity index 100% rename from infinity/icon/Undo16.gif rename to src/infinity/icon/Undo16.gif diff --git a/infinity/icon/Up16.gif b/src/infinity/icon/Up16.gif similarity index 100% rename from infinity/icon/Up16.gif rename to src/infinity/icon/Up16.gif diff --git a/infinity/icon/Volume16.gif b/src/infinity/icon/Volume16.gif similarity index 100% rename from infinity/icon/Volume16.gif rename to src/infinity/icon/Volume16.gif diff --git a/infinity/icon/YellowCircle16.gif b/src/infinity/icon/YellowCircle16.gif similarity index 100% rename from infinity/icon/YellowCircle16.gif rename to src/infinity/icon/YellowCircle16.gif diff --git a/infinity/icon/YellowCircle20.gif b/src/infinity/icon/YellowCircle20.gif similarity index 100% rename from infinity/icon/YellowCircle20.gif rename to src/infinity/icon/YellowCircle20.gif diff --git a/infinity/icon/Zoom16.gif b/src/infinity/icon/Zoom16.gif similarity index 100% rename from infinity/icon/Zoom16.gif rename to src/infinity/icon/Zoom16.gif diff --git a/infinity/resource/AbstractAbility.java b/src/infinity/resource/AbstractAbility.java similarity index 100% rename from infinity/resource/AbstractAbility.java rename to src/infinity/resource/AbstractAbility.java diff --git a/infinity/resource/AbstractStruct.java b/src/infinity/resource/AbstractStruct.java similarity index 100% rename from infinity/resource/AbstractStruct.java rename to src/infinity/resource/AbstractStruct.java diff --git a/infinity/resource/AddRemovable.java b/src/infinity/resource/AddRemovable.java similarity index 100% rename from infinity/resource/AddRemovable.java rename to src/infinity/resource/AddRemovable.java diff --git a/infinity/resource/Closeable.java b/src/infinity/resource/Closeable.java similarity index 100% rename from infinity/resource/Closeable.java rename to src/infinity/resource/Closeable.java diff --git a/infinity/resource/Effect.java b/src/infinity/resource/Effect.java similarity index 85% rename from infinity/resource/Effect.java rename to src/infinity/resource/Effect.java index 64ad117..3a73f01 100644 --- a/infinity/resource/Effect.java +++ b/src/infinity/resource/Effect.java @@ -10,7 +10,10 @@ public final class Effect extends AbstractStruct implements AddRemovable { static final String s_savetype[] = {"No save", "Spell", "Breath weapon", "Paralyze/Poison/Death", "Rod/Staff/Wand", - "Petrify/Polymorph"}; + "Petrify/Polymorph", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + "Ex: bypass mirror image"}; static final String s_savetype2[] = {"No save", "", "", "Fortitude", "Reflex", "Will"}; diff --git a/infinity/resource/Effect2.java b/src/infinity/resource/Effect2.java similarity index 97% rename from infinity/resource/Effect2.java rename to src/infinity/resource/Effect2.java index 43822cf..8a5a122 100644 --- a/infinity/resource/Effect2.java +++ b/src/infinity/resource/Effect2.java @@ -16,8 +16,8 @@ public final class Effect2 extends AbstractStruct implements AddRemovable "Recharge after resting", "", "", "", "", "Bypass armor", "Keen edge"}; private static final String s_splflag[] = {"No flags set", "", "", "", "", "", "", "", "", "", - "", "Hostile", "No LOS required", "", "Outdoors only", - "Non-magical ability", "Trigger/Contingency"}; + "", "Hostile", "No LOS required", "Allow spotting", "Outdoors only", + "Non-magical ability", "Trigger/Contingency", "Non-combat ability"}; public static void readCommon(List list, byte[] buffer, int offset) { diff --git a/infinity/resource/EffectFactory.java b/src/infinity/resource/EffectFactory.java similarity index 99% rename from infinity/resource/EffectFactory.java rename to src/infinity/resource/EffectFactory.java index 51589cd..9334a39 100644 --- a/infinity/resource/EffectFactory.java +++ b/src/infinity/resource/EffectFactory.java @@ -2211,7 +2211,7 @@ else if (gameid == ResourceFactory.ID_BG2 || break; case 0xEB: // Wing buffet (CGameEffectPushPull) - s.add(new DecNumber(buffer, offset, 4, "Distance")); + s.add(new DecNumber(buffer, offset, 4, "Strength")); s.add(new Bitmap(buffer, offset + 4, 4, "Direction", new String[]{"", "Away from target point", "Away from source", "Toward target point", "Toward source"})); @@ -2935,6 +2935,11 @@ else if (gameid == ResourceFactory.ID_ICEWIND2) { s.add(new DecNumber(buffer, offset + 4, 4, "Enchantment to overcome")); break; + case 0x1B5: // Disguise + s.add(new IdsBitmap(buffer, offset, 4, "Animation", "ANIMATE.IDS")); + s.add(new Unknown(buffer, offset + 4, 4)); + break; + case 0x1BB: // Protection from arrows s.add(new Unknown(buffer, offset, 4)); s.add(new Bitmap(buffer, offset + 4, 4, "Damage reduction", @@ -2947,6 +2952,11 @@ else if (gameid == ResourceFactory.ID_ICEWIND2) { new String[]{"Minor globe of invulnerability", "Globe of invulnerability"})); break; + + case 0x1C4: // Bane + s.add(new DecNumber(buffer, offset, 4, "Amount")); + s.add(new Unknown(buffer, offset + 4, 4)); + break; } } diff --git a/infinity/resource/HasAddRemovable.java b/src/infinity/resource/HasAddRemovable.java similarity index 100% rename from infinity/resource/HasAddRemovable.java rename to src/infinity/resource/HasAddRemovable.java diff --git a/infinity/resource/HasDetailViewer.java b/src/infinity/resource/HasDetailViewer.java similarity index 100% rename from infinity/resource/HasDetailViewer.java rename to src/infinity/resource/HasDetailViewer.java diff --git a/infinity/resource/Resource.java b/src/infinity/resource/Resource.java similarity index 100% rename from infinity/resource/Resource.java rename to src/infinity/resource/Resource.java diff --git a/infinity/resource/ResourceFactory.java b/src/infinity/resource/ResourceFactory.java similarity index 98% rename from infinity/resource/ResourceFactory.java rename to src/infinity/resource/ResourceFactory.java index f7970ed..2b9bc99 100644 --- a/infinity/resource/ResourceFactory.java +++ b/src/infinity/resource/ResourceFactory.java @@ -305,6 +305,8 @@ else if (new File(rootDir, "bg1tutu.exe").exists()) currentGame = ID_TUTU; else if (new File(rootDir, "baldur.exe").exists() && new File(rootDir, "chitin.ini").exists()) currentGame = ID_DEMO; + else if (new File(rootDir, "Baldur.exe").exists() && new File(rootDir, "movies/TSRLOGO.wbm").exists()) + currentGame = ID_BG2TOB; // Placeholder for BGEE - so far we can get by with ToB configuration keyfile = new Keyfile(file, currentGame); factory = this; @@ -493,7 +495,12 @@ public void loadResources() throws Exception // Get resources from keyfile keyfile.addBIFFResourceEntries(treeModel); - StringResource.init(new File(rootDir, DIALOGFILENAME)); + // dialog.tlk has moved in BGEE: + File dlg_file = new File(rootDir, DIALOGFILENAME); + if (! dlg_file.exists()) { + dlg_file = new File(rootDir + "/lang/en_US", DIALOGFILENAME); + } + StringResource.init(dlg_file); // Add other resources for (final String extraDir : games[currentGame].extraDirs) { diff --git a/infinity/resource/StructEntry.java b/src/infinity/resource/StructEntry.java similarity index 100% rename from infinity/resource/StructEntry.java rename to src/infinity/resource/StructEntry.java diff --git a/infinity/resource/TextResource.java b/src/infinity/resource/TextResource.java similarity index 100% rename from infinity/resource/TextResource.java rename to src/infinity/resource/TextResource.java diff --git a/infinity/resource/Viewable.java b/src/infinity/resource/Viewable.java similarity index 100% rename from infinity/resource/Viewable.java rename to src/infinity/resource/Viewable.java diff --git a/infinity/resource/ViewableContainer.java b/src/infinity/resource/ViewableContainer.java similarity index 100% rename from infinity/resource/ViewableContainer.java rename to src/infinity/resource/ViewableContainer.java diff --git a/infinity/resource/Writeable.java b/src/infinity/resource/Writeable.java similarity index 100% rename from infinity/resource/Writeable.java rename to src/infinity/resource/Writeable.java diff --git a/infinity/resource/are/Actor.java b/src/infinity/resource/are/Actor.java similarity index 97% rename from infinity/resource/are/Actor.java rename to src/infinity/resource/are/Actor.java index 0d387d1..adebe22 100644 --- a/infinity/resource/are/Actor.java +++ b/src/infinity/resource/are/Actor.java @@ -15,7 +15,8 @@ public final class Actor extends AbstractStruct implements AddRemovable, HasDeta public static final String[] s_orientation = { "South", "SSW", "SW", "WSW", "West", "WNW", "NW", "NNW", "North", "NNE", "NE", "ENE", "East", "ESE", "SE", "SSE" }; private static final String[] s_noyes = {"No", "Yes"}; - private static final String[] s_yesno = {"CRE attached", "CRE not attached", "", "", "Override script name"}; + private static final String[] s_yesno = {"CRE attached", "CRE not attached", "Has seen party", + "Toggle invulnerability", "Override script name"}; static final String[] s_schedule = {"Not active", "00:30-01:29", "01:30-02:29", "02:30-03:29", "03:30-04:29", "04:30-05:29", "05:30-06:29", "06:30-07:29", "07:30-08:29", "08:30-09:29", "09:30-10:29", "10:30-11:29", @@ -107,7 +108,7 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new Unknown(buffer, offset + 54, 2)); list.add(new DecNumber(buffer, offset + 56, 4, "Expiry time")); list.add(new DecNumber(buffer, offset + 60, 2, "Wander distance")); - list.add(new DecNumber(buffer, offset + 62, 2, "Movement distance")); + list.add(new DecNumber(buffer, offset + 62, 2, "Follow distance")); list.add(new Flag(buffer, offset + 64, 4, "Present at", s_schedule)); list.add(new DecNumber(buffer, offset + 68, 4, "# times talked to")); list.add(new ResourceRef(buffer, offset + 72, "Dialogue", "DLG")); diff --git a/infinity/resource/are/Ambient.java b/src/infinity/resource/are/Ambient.java similarity index 91% rename from infinity/resource/are/Ambient.java rename to src/infinity/resource/are/Ambient.java index 99aaf8e..8cf9bb3 100644 --- a/infinity/resource/are/Ambient.java +++ b/src/infinity/resource/are/Ambient.java @@ -10,7 +10,7 @@ final class Ambient extends AbstractStruct implements AddRemovable { - private static final String[] s_flag = {"Disabled", "Enabled", "Disable environmental effects", + private static final String[] s_flag = {"Disabled", "Enabled", "Looping", "Ignore radius", "Play in random order", "High memory ambient"}; Ambient() throws Exception @@ -30,7 +30,9 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset + 34, 2, "Origin: Y")); list.add(new DecNumber(buffer, offset + 36, 2, "Radius")); // list.add(new DecNumber(buffer, offset + 38, 2, "Height (3D)?")); - list.add(new Unknown(buffer, offset + 38, 8)); + list.add(new Unknown(buffer, offset + 38, 2)); + list.add(new DecNumber(buffer, offset + 40, 4, "Pitch variation")); + list.add(new DecNumber(buffer, offset + 44, 2, "Volume variation")); list.add(new DecNumber(buffer, offset + 46, 2, "Volume")); if (getSuperStruct() != null) for (int i = 0; i < 10; i++) diff --git a/infinity/resource/are/Animation.java b/src/infinity/resource/are/Animation.java similarity index 95% rename from infinity/resource/are/Animation.java rename to src/infinity/resource/are/Animation.java index 472ba60..eb8daee 100644 --- a/infinity/resource/are/Animation.java +++ b/src/infinity/resource/are/Animation.java @@ -10,7 +10,7 @@ final class Animation extends AbstractStruct implements AddRemovable { private static final String[] s_flag = {"Not shown", "Is shown", "No shadow", "Not light source", - "Partial animation", "Synchronized draw", "", + "Partial animation", "Synchronized draw", "Random start", "Not covered by wall", "Static animation", "Draw as background", "Play all frames", "Recolored by palette", "Mirror Y axis", "Don't remove in combat"}; @@ -37,7 +37,7 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new Flag(buffer, offset + 52, 4, "Appearance", s_flag)); list.add(new DecNumber(buffer, offset + 56, 2, "Location: Z")); list.add(new DecNumber(buffer, offset + 58, 2, "Translucency")); - list.add(new Unknown(buffer, offset + 60, 2)); + list.add(new DecNumber(buffer, offset + 60, 2, "Start range")); list.add(new DecNumber(buffer, offset + 62, 1, "Loop probability")); list.add(new DecNumber(buffer, offset + 63, 1, "Start delay (frames)")); if (ResourceFactory.getGameID() == ResourceFactory.ID_BG2 || diff --git a/infinity/resource/are/AreResource.java b/src/infinity/resource/are/AreResource.java similarity index 97% rename from infinity/resource/are/AreResource.java rename to src/infinity/resource/are/AreResource.java index c42fc70..58dc770 100644 --- a/infinity/resource/are/AreResource.java +++ b/src/infinity/resource/are/AreResource.java @@ -30,6 +30,7 @@ public final class AreResource extends AbstractStruct implements Resource, HasAd "Cannot rest", "Cannot save", "Too dangerous to rest", "Cannot save", "Can rest with permission"}; private static final String s_atype_iwd2[] = {"Normal", "Can't save game", "Cannot rest", "Lock battle music"}; + private static final String s_edge[] = {"No flags set", "Party required", "Party enabled"}; public static void addScriptNames(Set scriptNames, byte buffer[]) { @@ -245,13 +246,13 @@ else if (ResourceFactory.getGameID() == ResourceFactory.ID_TORMENT) else list.add(new Flag(buffer, offset + 20, 4, "Area type", s_atype)); list.add(new ResourceRef(buffer, offset + 24, "Area north", "ARE")); - list.add(new Unknown(buffer, offset + 32, 4)); + list.add(new Flag(buffer, offset + 32, 4, "Edge flags north", s_edge)); list.add(new ResourceRef(buffer, offset + 36, "Area east", "ARE")); - list.add(new Unknown(buffer, offset + 44, 4)); + list.add(new Flag(buffer, offset + 44, 4, "Edge flags east", s_edge)); list.add(new ResourceRef(buffer, offset + 48, "Area south", "ARE")); - list.add(new Unknown(buffer, offset + 56, 4)); + list.add(new Flag(buffer, offset + 56, 4, "Edge flags south", s_edge)); list.add(new ResourceRef(buffer, offset + 60, "Area west", "ARE")); - list.add(new Unknown(buffer, offset + 68, 4)); + list.add(new Flag(buffer, offset + 68, 4, "Edge flags west", s_edge)); if (ResourceFactory.getGameID() == ResourceFactory.ID_TORMENT) list.add(new Flag(buffer, offset + 72, 2, "Location", s_flag_torment)); else @@ -260,7 +261,7 @@ else if (ResourceFactory.getGameID() == ResourceFactory.ID_TORMENT) list.add(new DecNumber(buffer, offset + 76, 2, "Snow probability")); list.add(new DecNumber(buffer, offset + 78, 2, "Fog probability")); list.add(new DecNumber(buffer, offset + 80, 2, "Lightning probability")); - list.add(new Unknown(buffer, offset + 82, 2)); + list.add(new DecNumber(buffer, offset + 82, 2, "Wind speed")); if (version.toString().equalsIgnoreCase("V9.1")) { list.add(new DecNumber(buffer, offset + 84, 1, "Area difficulty 2")); list.add(new DecNumber(buffer, offset + 85, 1, "Area difficulty 3")); @@ -315,10 +316,11 @@ else if (ResourceFactory.getGameID() == ResourceFactory.ID_TORMENT) SectionOffset offset_variables = new SectionOffset(buffer, offset + 136, "Variables offset", Variable.class); list.add(offset_variables); - SectionCount count_variables = new SectionCount(buffer, offset + 140, 4, "# variables", + SectionCount count_variables = new SectionCount(buffer, offset + 140, 2, "# variables", Variable.class); list.add(count_variables); - list.add(new Unknown(buffer, offset + 144, 4)); + list.add(new HexNumber(buffer, offset + 142, 2, "# object flags")); + list.add(new HexNumber(buffer, offset + 144, 4, "Object flags offset")); list.add(new ResourceRef(buffer, offset + 148, "Area script", "BCS")); SectionCount size_exploredbitmap = new SectionCount(buffer, offset + 156, 4, "Explored bitmap size", Unknown.class); diff --git a/infinity/resource/are/AutomapNote.java b/src/infinity/resource/are/AutomapNote.java similarity index 100% rename from infinity/resource/are/AutomapNote.java rename to src/infinity/resource/are/AutomapNote.java diff --git a/infinity/resource/are/AutomapNotePST.java b/src/infinity/resource/are/AutomapNotePST.java similarity index 100% rename from infinity/resource/are/AutomapNotePST.java rename to src/infinity/resource/are/AutomapNotePST.java diff --git a/infinity/resource/are/Container.java b/src/infinity/resource/are/Container.java similarity index 97% rename from infinity/resource/are/Container.java rename to src/infinity/resource/are/Container.java index e17849d..a59323b 100644 --- a/infinity/resource/are/Container.java +++ b/src/infinity/resource/are/Container.java @@ -17,7 +17,7 @@ public final class Container extends AbstractStruct implements AddRemovable, Has "", "Bag", "Chest", "Drawer", "Pile", "Table", "Shelf", "Altar", "Non-visible", "Spellbook", "Body", "Barrel", "Crate"}; private static final String s_yesno[] = {"No", "Yes"}; - private static final String s_flag[] = { "No flags set", "Locked", "", "", "Trap resets", + private static final String s_flag[] = { "No flags set", "Locked", "", "Magical lock", "Trap resets", "", "Disabled" }; public Container() throws Exception @@ -148,7 +148,8 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new ResourceRef(buffer, offset + 72, "Trap script", "BCS")); list.add(new DecNumber(buffer, offset + 80, 4, "First vertex index")); list.add(new DecNumber(buffer, offset + 84, 2, "# vertices")); - list.add(new Unknown(buffer, offset + 86, 34)); + list.add(new DecNumber(buffer, offset + 86, 2, "Activation range")); + list.add(new TextString(buffer, offset + 88, 32, "Owner name")); // list.add(new ResourceRef(buffer, offset + 88, "Creature?", "CRE")); // list.add(new Unknown(buffer, offset + 96, 24)); list.add(new ResourceRef(buffer, offset + 120, "Key", "ITM")); diff --git a/infinity/resource/are/Door.java b/src/infinity/resource/are/Door.java similarity index 98% rename from infinity/resource/are/Door.java rename to src/infinity/resource/are/Door.java index 25c6c20..a0e986a 100644 --- a/infinity/resource/are/Door.java +++ b/src/infinity/resource/are/Door.java @@ -143,8 +143,8 @@ protected int read(byte buffer[], int offset) throws Exception OpenVertexImpeded.class)); list.add(new SectionCount(buffer, offset + 78, 2, "# vertices (impeded, closed)", ClosedVertexImpeded.class)); list.add(new DecNumber(buffer, offset + 80, 4, "First vertex index (impeded, closed)")); - list.add(new Unknown(buffer, offset + 84, 4)); -// list.add(new Unknown(buffer, offset + 86, 2)); + list.add(new DecNumber(buffer, offset + 84, 2, "Current HP")); + list.add(new DecNumber(buffer, offset + 86, 2, "Effective AC")); list.add(new ResourceRef(buffer, offset + 88, "Opening sound", "WAV")); list.add(new ResourceRef(buffer, offset + 96, "Closing sound", "WAV")); list.add(new DecNumber(buffer, offset + 104, 4, "Cursor number")); diff --git a/infinity/resource/are/Entrance.java b/src/infinity/resource/are/Entrance.java similarity index 100% rename from infinity/resource/are/Entrance.java rename to src/infinity/resource/are/Entrance.java diff --git a/infinity/resource/are/HasVertices.java b/src/infinity/resource/are/HasVertices.java similarity index 100% rename from infinity/resource/are/HasVertices.java rename to src/infinity/resource/are/HasVertices.java diff --git a/infinity/resource/are/ITEPoint.java b/src/infinity/resource/are/ITEPoint.java similarity index 95% rename from infinity/resource/are/ITEPoint.java rename to src/infinity/resource/are/ITEPoint.java index 6cdc0f4..ad0ed14 100644 --- a/infinity/resource/are/ITEPoint.java +++ b/src/infinity/resource/are/ITEPoint.java @@ -12,8 +12,9 @@ public final class ITEPoint extends AbstractStruct implements AddRemovable, HasV { private static final String[] s_type = {"Proximity trigger", "Info trigger", "Travel trigger"}; private static final String[] s_flag = {"No flags set", "Locked", "Trap resets", "Party required", "Trap detectable", - "", "", "Trap set off by NPC", "", "Trigger deactivated", "Cannot be passed by NPC", - "Use activation point", "Connected to door"}; + "Trap set off by enemy", "Tutorial trigger", "Trap set off by NPC", "Trigger silent", + "Trigger deactivated", "Cannot be passed by NPC", "Use activation point", + "Connected to door"}; private static final String[] s_yesno = {"No", "Yes"}; public ITEPoint() throws Exception diff --git a/infinity/resource/are/Item.java b/src/infinity/resource/are/Item.java similarity index 100% rename from infinity/resource/are/Item.java rename to src/infinity/resource/are/Item.java diff --git a/infinity/resource/are/ProTrap.java b/src/infinity/resource/are/ProTrap.java similarity index 87% rename from infinity/resource/are/ProTrap.java rename to src/infinity/resource/are/ProTrap.java index e970c68..ba29eb9 100644 --- a/infinity/resource/are/ProTrap.java +++ b/src/infinity/resource/are/ProTrap.java @@ -26,13 +26,14 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new SectionOffset(buffer, offset + 8, "Effects list offset", null)); // Mac ToB doesn't save these right, so EFFs not handled list.add(new DecNumber(buffer, offset + 12, 2, "Effects list size")); - list.add(new Unknown(buffer, offset + 14, 2, "Projectile")); + list.add(new DecNumber(buffer, offset + 14, 2, "Projectile")); list.add(new DecNumber(buffer, offset + 16, 2, "Explosion frequency (frames)")); list.add(new DecNumber(buffer, offset + 18, 2, "Duration")); list.add(new DecNumber(buffer, offset + 20, 2, "Location: X")); list.add(new DecNumber(buffer, offset + 22, 2, "Location: Y")); list.add(new DecNumber(buffer, offset + 24, 2, "Location: Z")); - list.add(new DecNumber(buffer, offset + 26, 2, "Target")); + list.add(new DecNumber(buffer, offset + 26, 1, "Target")); + list.add(new DecNumber(buffer, offset + 27, 1, "Portrait")); return offset + 28; } } diff --git a/infinity/resource/are/RestSpawn.java b/src/infinity/resource/are/RestSpawn.java similarity index 94% rename from infinity/resource/are/RestSpawn.java rename to src/infinity/resource/are/RestSpawn.java index ee5d910..94893f7 100644 --- a/infinity/resource/are/RestSpawn.java +++ b/src/infinity/resource/are/RestSpawn.java @@ -25,7 +25,7 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset + 154, 2, "Encounter difficulty")); list.add(new DecNumber(buffer, offset + 156, 4, "Creature duration")); list.add(new DecNumber(buffer, offset + 160, 2, "Creature wander distance")); - list.add(new DecNumber(buffer, offset + 162, 2, "Creature movement distance")); + list.add(new DecNumber(buffer, offset + 162, 2, "Creature follow distance")); list.add(new DecNumber(buffer, offset + 164, 2, "Maximum spawned creatures")); list.add(new Bitmap(buffer, offset + 166, 2, "Is active?", new String[]{"No", "Yes"})); list.add(new DecNumber(buffer, offset + 168, 2, "Probability (day)")); diff --git a/infinity/resource/are/Song.java b/src/infinity/resource/are/Song.java similarity index 100% rename from infinity/resource/are/Song.java rename to src/infinity/resource/are/Song.java diff --git a/infinity/resource/are/SpawnPoint.java b/src/infinity/resource/are/SpawnPoint.java similarity index 93% rename from infinity/resource/are/SpawnPoint.java rename to src/infinity/resource/are/SpawnPoint.java index bbe1cc8..3994bda 100644 --- a/infinity/resource/are/SpawnPoint.java +++ b/src/infinity/resource/are/SpawnPoint.java @@ -31,13 +31,13 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new SpawnResourceRef(buffer, offset + 36 + (i << 3), "Creature " + (i + 1))); list.add(new DecNumber(buffer, offset + 116, 2, "# creatures")); list.add(new DecNumber(buffer, offset + 118, 2, "Encounter difficulty")); - list.add(new DecNumber(buffer, offset + 120, 2, "Spawn delay")); + list.add(new DecNumber(buffer, offset + 120, 2, "Spawn rate")); list.add(new Flag(buffer, offset + 122, 2, "Spawn method", new String[]{"No flags set", "Spawn until paused", "Disable after spawn", "Spawn paused"})); list.add(new DecNumber(buffer, offset + 124, 4, "Creature duration")); list.add(new DecNumber(buffer, offset + 128, 2, "Creature wander distance")); - list.add(new DecNumber(buffer, offset + 130, 2, "Creature movement distance")); + list.add(new DecNumber(buffer, offset + 130, 2, "Creature follow distance")); list.add(new DecNumber(buffer, offset + 132, 2, "Maximum spawned creatures")); list.add(new Bitmap(buffer, offset + 134, 2, "Is active?", s_active)); list.add(new Flag(buffer, offset + 136, 4, "Active at", Actor.s_schedule)); diff --git a/infinity/resource/are/TiledObject.java b/src/infinity/resource/are/TiledObject.java similarity index 58% rename from infinity/resource/are/TiledObject.java rename to src/infinity/resource/are/TiledObject.java index af001f1..16ff762 100644 --- a/infinity/resource/are/TiledObject.java +++ b/src/infinity/resource/are/TiledObject.java @@ -10,6 +10,8 @@ final class TiledObject extends AbstractStruct implements AddRemovable { + private static final String s_flag[] = { "No flags set", "Secondary tile", "Can be looked through" }; + TiledObject() throws Exception { super(null, "Tiled object", new byte[108], 0); @@ -23,12 +25,12 @@ final class TiledObject extends AbstractStruct implements AddRemovable protected int read(byte buffer[], int offset) throws Exception { list.add(new TextString(buffer, offset, 32, "Name")); - list.add(new TextString(buffer, offset + 32, 8, "Resource?")); - list.add(new Unknown(buffer, offset + 40, 4)); - list.add(new DecNumber(buffer, offset + 44, 4, "Primary search squares offset")); - list.add(new DecNumber(buffer, offset + 48, 4, "# primary search squares")); - list.add(new DecNumber(buffer, offset + 52, 4, "Secondary search squares offset")); - list.add(new DecNumber(buffer, offset + 56, 4, "# secondary search squares")); + list.add(new TextString(buffer, offset + 32, 8, "Tile ID")); + list.add(new Flag(buffer, offset + 40, 4, "Tile flags", s_flag)); + list.add(new DecNumber(buffer, offset + 44, 4, "First vertex index (primary)")); + list.add(new DecNumber(buffer, offset + 48, 2, "# vertices (primary)")); + list.add(new DecNumber(buffer, offset + 50, 2, "# vertices (secondary)")); + list.add(new DecNumber(buffer, offset + 52, 4, "First vertex index (secondary)")); list.add(new Unknown(buffer, offset + 60, 48)); return offset + 108; } diff --git a/infinity/resource/are/Variable.java b/src/infinity/resource/are/Variable.java similarity index 74% rename from infinity/resource/are/Variable.java rename to src/infinity/resource/are/Variable.java index 1f7305f..e7b4ee9 100644 --- a/infinity/resource/are/Variable.java +++ b/src/infinity/resource/are/Variable.java @@ -10,6 +10,9 @@ final class Variable extends AbstractStruct implements AddRemovable { + private static final String s_type[] = {"Integer", "Float", "Script name", "Resource reference", + "String reference", "Double word"}; + Variable() throws Exception { super(null, "Variable", new byte[84], 0); @@ -23,7 +26,8 @@ final class Variable extends AbstractStruct implements AddRemovable protected int read(byte buffer[], int offset) throws Exception { list.add(new TextString(buffer, offset, 32, "Name")); - list.add(new Unknown(buffer, offset + 32, 8)); + list.add(new Bitmap(buffer, offset + 32, 2, "Type", s_type)); + list.add(new Unknown(buffer, offset + 34, 6)); list.add(new DecNumber(buffer, offset + 40, 4, "Value")); list.add(new Unknown(buffer, offset + 44, 40)); return offset + 84; diff --git a/infinity/resource/are/Viewer.java b/src/infinity/resource/are/Viewer.java similarity index 100% rename from infinity/resource/are/Viewer.java rename to src/infinity/resource/are/Viewer.java diff --git a/infinity/resource/are/ViewerActor.java b/src/infinity/resource/are/ViewerActor.java similarity index 100% rename from infinity/resource/are/ViewerActor.java rename to src/infinity/resource/are/ViewerActor.java diff --git a/infinity/resource/are/ViewerContainer.java b/src/infinity/resource/are/ViewerContainer.java similarity index 100% rename from infinity/resource/are/ViewerContainer.java rename to src/infinity/resource/are/ViewerContainer.java diff --git a/infinity/resource/are/ViewerGraphics.java b/src/infinity/resource/are/ViewerGraphics.java similarity index 100% rename from infinity/resource/are/ViewerGraphics.java rename to src/infinity/resource/are/ViewerGraphics.java diff --git a/infinity/resource/bcs/BafResource.java b/src/infinity/resource/bcs/BafResource.java similarity index 100% rename from infinity/resource/bcs/BafResource.java rename to src/infinity/resource/bcs/BafResource.java diff --git a/infinity/resource/bcs/BcsResource.java b/src/infinity/resource/bcs/BcsResource.java similarity index 100% rename from infinity/resource/bcs/BcsResource.java rename to src/infinity/resource/bcs/BcsResource.java diff --git a/infinity/resource/bcs/Compiler.java b/src/infinity/resource/bcs/Compiler.java similarity index 99% rename from infinity/resource/bcs/Compiler.java rename to src/infinity/resource/bcs/Compiler.java index 9c43ce4..b886018 100644 --- a/infinity/resource/bcs/Compiler.java +++ b/src/infinity/resource/bcs/Compiler.java @@ -6,8 +6,10 @@ import infinity.NearInfinity; import infinity.gui.StatusBar; +import infinity.gui.BrowserMenuBar; import infinity.resource.ResourceFactory; import infinity.resource.are.AreResource; +import infinity.resource.bcs.Decompiler; import infinity.resource.cre.CreResource; import infinity.resource.key.ResourceEntry; import infinity.util.IdsMap; @@ -105,7 +107,8 @@ else if (ResourceFactory.getGameID() == ResourceFactory.ID_ICEWIND2) }; emptyObject = compileObject(null, ""); - setupScriptNames(); + if (BrowserMenuBar.getInstance().checkScriptNames()) + setupScriptNames(); } private void setupScriptNames() @@ -356,9 +359,8 @@ else if (definition.equalsIgnoreCase("S:Pool*")) resourceTypes = new String[]{".SRC"}; else if (definition.equalsIgnoreCase("S:Palette*")) resourceTypes = new String[]{".BMP"}; - else if (definition.equalsIgnoreCase("S:ResRef*")) // ToDo: Better check possible? - resourceTypes = new String[]{".CRE", ".ITM", ".ARE", ".2DA", ".BCS", ".MVE", ".SPL", ".DLG", ".VVC", - ".BAM"}; + else if (definition.equalsIgnoreCase("S:ResRef*")) + resourceTypes = Decompiler.getResRefType(function.substring(0, function.length() - 1)); else if (definition.equalsIgnoreCase("S:Object*")) // ToDo: Better check possible? resourceTypes = new String[]{".ITM", ".VVC", ".BAM"}; else if (definition.equalsIgnoreCase("S:NewObject*")) // ToDo: Better check possible? diff --git a/infinity/resource/bcs/Decompiler.java b/src/infinity/resource/bcs/Decompiler.java similarity index 86% rename from infinity/resource/bcs/Decompiler.java rename to src/infinity/resource/bcs/Decompiler.java index 270c939..8f6057d 100644 --- a/infinity/resource/bcs/Decompiler.java +++ b/src/infinity/resource/bcs/Decompiler.java @@ -146,8 +146,10 @@ private static void decompileAC(StringBuilder code, StringTokenizer st) index += 4; } } - else if (newp != null) // ToDo: IWD2 bug? - comment = getResourceName(p, newp.substring(1, newp.length() - 1)); + else if (newp != null) { // ToDo: IWD2 bug? + String function = action.getString().substring(0, action.getString().length() - 1); + comment = getResourceName(function, p, newp.substring(1, newp.length() - 1)); + } } else if (p.substring(0, 2).equals("O:")) { while (objects[index_o++].equals("[ANYONE]") && index_o < 2) @@ -532,7 +534,8 @@ private static String decompileTR(StringTokenizer st) String p = defParam.nextToken(); if (p.substring(0, 2).equals("S:")) { String newp = strings[index_s++]; - comment = getResourceName(p, newp.substring(1, newp.length() - 1)); + String function = trigger.getString().substring(0, trigger.getString().length() - 1); + comment = getResourceName(function, p, newp.substring(1, newp.length() - 1)); code.append(newp); } else if (p.substring(0, 2).equals("O:")) @@ -557,7 +560,71 @@ public static SortedMap getIdsErrors() return idsErrors; } - private static String getResourceName(String definition, String value) + public static String[] getResRefType(String function) + { + if (function.equalsIgnoreCase("HasItem") || + function.equalsIgnoreCase("Contains") || + function.equalsIgnoreCase("NumItems") || + function.equalsIgnoreCase("NumItemsGT") || + function.equalsIgnoreCase("NumItemsLT") || + function.equalsIgnoreCase("NumItemsParty") || + function.equalsIgnoreCase("NumItemsPartyGT") || + function.equalsIgnoreCase("NumItemsPartyLT") || + function.equalsIgnoreCase("HasItemEquiped") || + function.equalsIgnoreCase("PartyHasItemIdentified") || + function.equalsIgnoreCase("HasItemEquipedReal") || + function.equalsIgnoreCase("Acquired") || + function.equalsIgnoreCase("Unusable") || + function.equalsIgnoreCase("CreateItem") || + function.equalsIgnoreCase("GiveItemCreate") || + function.equalsIgnoreCase("DestroyItem") || + function.equalsIgnoreCase("TakePartyItemNum") || + function.equalsIgnoreCase("CreateItemNumGlobal") || + function.equalsIgnoreCase("CreateItemGlobal") || + function.equalsIgnoreCase("PickUpItem")) { + return new String[] {".ITM"}; + } + else if (function.equalsIgnoreCase("ChangeAnimation") || + function.equalsIgnoreCase("ChangeAnimationNoEffect") || + function.equalsIgnoreCase("CreateCreatureObject") || + function.equalsIgnoreCase("CreateCreatureObjectDoor") || + function.equalsIgnoreCase("CreateCreatureObjectOffScreen") || + function.equalsIgnoreCase("CreateCreatureOffScreen") || + function.equalsIgnoreCase("CreateCreatureAtLocation") || + function.equalsIgnoreCase("CreateCreatureObjectCopy") || + function.equalsIgnoreCase("CreateCreatureObjectOffset") || + function.equalsIgnoreCase("CreateCreatureCopyPoint")) { + return new String[] {".CRE"}; + } + else if (function.equalsIgnoreCase("AreaCheck") || + function.equalsIgnoreCase("AreaCheckObject") || + function.equalsIgnoreCase("RevealAreaOnMap") || + function.equalsIgnoreCase("HideAreaOnMap") || + function.equalsIgnoreCase("CopyGroundPilesTo") || + function.equalsIgnoreCase("EscapeAreaObjectMove")) { + return new String[] {".ARE"}; + } + else if (function.equalsIgnoreCase("G") || + function.equalsIgnoreCase("GGT") || + function.equalsIgnoreCase("GLT")) { + return new String[] {}; + } + else if (function.equalsIgnoreCase("IncrementChapter") || + function.equalsIgnoreCase("TakeItemListParty") || + function.equalsIgnoreCase("TakeItemListPartyNum")) { + return new String[] {".2DA"}; + } + else if (function.equalsIgnoreCase("StartMovie")) { + return new String[] {".MVE"}; + } + else if (function.equalsIgnoreCase("AddSpecialAbility")) { + return new String[] {".SPL"}; + } + return new String[] {".CRE", ".ITM", ".ARE", ".2DA", ".BCS", + ".MVE", ".SPL", ".DLG", ".VVC", ".BAM"}; + } + + private static String getResourceName(String function, String definition, String value) { if (value.length() > 8) return null; @@ -592,9 +659,9 @@ else if (definition.equalsIgnoreCase("S:Pool*")) entry = decompileStringCheck(value, new String[]{".SRC"}); else if (definition.equalsIgnoreCase("S:Palette*")) entry = decompileStringCheck(value, new String[]{".BMP"}); - else if (definition.equalsIgnoreCase("S:ResRef*")) // ToDo: Better check possible? - entry = decompileStringCheck(value, new String[]{".CRE", ".ITM", ".ARE", ".2DA", ".BCS", ".MVE", - ".SPL", ".DLG"}); + else if (definition.equalsIgnoreCase("S:ResRef*")) { + entry = decompileStringCheck(value, getResRefType(function)); + } else if (definition.equalsIgnoreCase("S:Object*")) // ToDo: Better check possible? entry = decompileStringCheck(value, new String[]{".ITM", ".VVC", ".BAM"}); else if (definition.equalsIgnoreCase("S:NewObject*")) // ToDo: Better check possible? diff --git a/infinity/resource/chu/ChuResource.java b/src/infinity/resource/chu/ChuResource.java similarity index 100% rename from infinity/resource/chu/ChuResource.java rename to src/infinity/resource/chu/ChuResource.java diff --git a/infinity/resource/chu/Control.java b/src/infinity/resource/chu/Control.java similarity index 91% rename from infinity/resource/chu/Control.java rename to src/infinity/resource/chu/Control.java index fb054d0..4f6b57e 100644 --- a/infinity/resource/chu/Control.java +++ b/src/infinity/resource/chu/Control.java @@ -71,10 +71,14 @@ public int readControl(byte buffer[]) list.add(new ResourceRef(buffer, offset + 14, "Button", "BAM")); list.add(new UnsignDecNumber(buffer, offset + 22, 1, "Animation number")); list.add(new Flag(buffer, offset + 23, 1, "Text flags", s_button)); - list.add(new DecNumber(buffer, offset + 24, 2, "Frame number: Unpressed")); - list.add(new DecNumber(buffer, offset + 26, 2, "Frame number: Pressed")); - list.add(new DecNumber(buffer, offset + 28, 2, "Frame number: Selected")); - list.add(new DecNumber(buffer, offset + 30, 2, "Frame number: Disabled")); + list.add(new DecNumber(buffer, offset + 24, 1, "Frame number: Unpressed")); + list.add(new DecNumber(buffer, offset + 25, 1, "Text anchor: Left")); + list.add(new DecNumber(buffer, offset + 26, 1, "Frame number: Pressed")); + list.add(new DecNumber(buffer, offset + 27, 1, "Text anchor: Right")); + list.add(new DecNumber(buffer, offset + 28, 1, "Frame number: Selected")); + list.add(new DecNumber(buffer, offset + 29, 1, "Text anchor: Top")); + list.add(new DecNumber(buffer, offset + 30, 1, "Frame number: Disabled")); + list.add(new DecNumber(buffer, offset + 31, 1, "Text anchor: Bottom")); offset += 32; break; case 2: @@ -102,7 +106,7 @@ public int readControl(byte buffer[]) list.add(new DecNumber(buffer, offset + 48, 2, "Frame number")); list.add(new DecNumber(buffer, offset + 50, 2, "Caret position: X")); list.add(new DecNumber(buffer, offset + 52, 2, "Caret position: Y")); - list.add(new Unknown(buffer, offset + 54, 4)); + list.add(new DecNumber(buffer, offset + 54, 4, "Text field ID")); list.add(new ResourceRef(buffer, offset + 58, "Font", "BAM")); list.add(new Unknown(buffer, offset + 66, 2)); list.add(new TextString(buffer, offset + 68, 32, "Initial text")); diff --git a/infinity/resource/chu/Window.java b/src/infinity/resource/chu/Window.java similarity index 100% rename from infinity/resource/chu/Window.java rename to src/infinity/resource/chu/Window.java diff --git a/infinity/resource/cre/CreResource.java b/src/infinity/resource/cre/CreResource.java similarity index 96% rename from infinity/resource/cre/CreResource.java rename to src/infinity/resource/cre/CreResource.java index 00885b6..781cc31 100644 --- a/infinity/resource/cre/CreResource.java +++ b/src/infinity/resource/cre/CreResource.java @@ -18,15 +18,14 @@ public final class CreResource extends AbstractStruct implements Resource, HasAd HasDetailViewer { private static final LongIntegerHashMap m_magetype = new LongIntegerHashMap(); - private static final LongIntegerHashMap m_slotmask = new LongIntegerHashMap(); private static final LongIntegerHashMap m_colorPlacement = new LongIntegerHashMap(); - private static final String s_flag[] = {"No flags set", "", "No corpse", "Permanent corpse", + private static final String s_flag[] = {"No flags set", "Identified", "No corpse", "Permanent corpse", "Original class: Fighter", "Original class: Mage", "Original class: Cleric", "Original class: Thief", "Original class: Druid", "Original class: Ranger", "Fallen paladin", "Fallen ranger", - "Export allowed", "Hide status", "", "Moving between areas", "Been in party", - "", "", "", "", "", "", "", "", "Allegiance tracking", + "Export allowed", "Hide status", "Large creature", "Moving between areas", "Been in party", + "Holding item", "Clear all flags", "", "", "", "", "", "", "Allegiance tracking", "General tracking", "Race tracking", "Class tracking", "Specifics tracking", "Gender tracking", "Alignment tracking", "Uninterruptible"}; @@ -67,9 +66,6 @@ public final class CreResource extends AbstractStruct implements Resource, HasAd m_magetype.put((long)0x2000, "Transmuter"); m_magetype.put((long)0x4000, "Generalist"); - m_slotmask.put(0L, "Yes"); - m_slotmask.put(65535L, "No"); - m_colorPlacement.put((long)0x80, "Metal"); m_colorPlacement.put((long)0x81, "Metal (hologram)"); m_colorPlacement.put((long)0x82, "Metal (pulsate)"); @@ -377,14 +373,14 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new IdsBitmap(buffer, offset + 58, 2, "Quick shield slot 3", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 60, 2, "Quick weapon slot 4", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 62, 2, "Quick shield slot 4", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 64, 2, "Show quick weapon 1?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 66, 2, "Show quick shield 1?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 68, 2, "Show quick weapon 2?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 70, 2, "Show quick shield 2?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 72, 2, "Show quick weapon 3?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 74, 2, "Show quick shield 3?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 76, 2, "Show quick weapon 4?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 78, 2, "Show quick shield 4?", m_slotmask)); + list.add(new DecNumber(buffer, offset + 64, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 66, 2, "Quick shield 1 ability")); + list.add(new DecNumber(buffer, offset + 68, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 70, 2, "Quick shield 2 ability")); + list.add(new DecNumber(buffer, offset + 72, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 74, 2, "Quick shield 3 ability")); + list.add(new DecNumber(buffer, offset + 76, 2, "Quick weapon 4 ability")); + list.add(new DecNumber(buffer, offset + 78, 2, "Quick shield 4 ability")); list.add(new ResourceRef(buffer, offset + 80, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 88, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 96, "Quick spell 3", "SPL")); @@ -407,9 +403,9 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new IdsBitmap(buffer, offset + 162, 2, "Quick item slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 164, 2, "Quick item slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 166, 2, "Quick item slot 3", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 168, 2, "Show quick item 1?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 170, 2, "Show quick item 2?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 172, 2, "Show quick item 3?", m_slotmask)); + list.add(new DecNumber(buffer, offset + 168, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 170, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 172, 2, "Quick item 3 ability")); list.add(new ResourceRef(buffer, offset + 174, "Quick ability 1", "SPL")); list.add(new ResourceRef(buffer, offset + 182, "Quick ability 2", "SPL")); list.add(new ResourceRef(buffer, offset + 190, "Quick ability 3", "SPL")); @@ -442,24 +438,24 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new TextString(buffer, offset + 388, 32, "Voice set")); list.add(new Unknown(buffer, offset + 420, 128)); } - else if (version.toString().equalsIgnoreCase("V1.0")) { + else if (version.toString().equalsIgnoreCase("V1.0") || version.toString().equalsIgnoreCase("V2.0")) { list.add(new IdsBitmap(buffer, offset + 48, 2, "Quick weapon slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 50, 2, "Quick weapon slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 52, 2, "Quick weapon slot 3", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 54, 2, "Quick weapon slot 4", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 56, 2, "Show quick weapon 1?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 58, 2, "Show quick weapon 2?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 60, 2, "Show quick weapon 3?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 62, 2, "Show quick weapon 4?", m_slotmask)); + list.add(new DecNumber(buffer, offset + 56, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 58, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 60, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 62, 2, "Quick weapon 4 ability")); list.add(new ResourceRef(buffer, offset + 64, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 72, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 80, "Quick spell 3", "SPL")); list.add(new IdsBitmap(buffer, offset + 88, 2, "Quick item slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 90, 2, "Quick item slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 92, 2, "Quick item slot 3", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 94, 2, "Show quick item 1?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 96, 2, "Show quick item 2?", m_slotmask)); - list.add(new HashBitmap(buffer, offset + 98, 2, "Show quick item 3?", m_slotmask)); + list.add(new DecNumber(buffer, offset + 94, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 96, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 98, 2, "Quick item 3 ability")); } else list.add(new Unknown(buffer, offset + 48, structOffset.getValue() - 48)); @@ -490,8 +486,8 @@ private int readIWD2(byte buffer[], int offset) throws Exception list.add(new IdsFlag(buffer, offset + 24, 4, "Status", "STATE.IDS")); list.add(new DecNumber(buffer, offset + 28, 2, "Current HP")); list.add(new DecNumber(buffer, offset + 30, 2, "Maximum HP")); - list.add(new IdsBitmap(buffer, offset + 32, 2, "Animation", "ANIMATE.IDS")); - list.add(new Unknown(buffer, offset + 34, 2)); + list.add(new IdsBitmap(buffer, offset + 32, 4, "Animation", "ANIMATE.IDS")); +// list.add(new Unknown(buffer, offset + 34, 2)); list.add(new ColorValue(buffer, offset + 36, 1, "Metal color")); list.add(new ColorValue(buffer, offset + 37, 1, "Minor color")); list.add(new ColorValue(buffer, offset + 38, 1, "Major color")); @@ -661,7 +657,17 @@ private int readIWD2(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset + 740, 2, "Saved location: X")); list.add(new DecNumber(buffer, offset + 742, 2, "Saved location: Y")); list.add(new DecNumber(buffer, offset + 744, 2, "Saved orientation")); - list.add(new Unknown(buffer, offset + 746, 146)); + list.add(new Unknown(buffer, offset + 746, 15)); + list.add(new DecNumber(buffer, offset + 761, 1, "Fade amount")); + list.add(new DecNumber(buffer, offset + 762, 1, "Fade speed")); + list.add(new Flag(buffer, offset + 763, 1, "Attributes", + new String[]{"No flags set", "Mental fortitude", + "Critical hit immunity", "Cannot be paladin", + "Cannot be monk"})); + list.add(new DecNumber(buffer, offset + 764, 1, "Visibility")); + list.add(new Unknown(buffer, offset + 765, 2)); + list.add(new DecNumber(buffer, offset + 767, 1, "Unused skill points")); + list.add(new Unknown(buffer, offset + 768, 124)); list.add(new IdsBitmap(buffer, offset + 892, 1, "Allegiance", "EA.IDS")); list.add(new IdsBitmap(buffer, offset + 893, 1, "General", "GENERAL.IDS")); list.add(new IdsBitmap(buffer, offset + 894, 1, "Race", "RACE.IDS")); @@ -947,8 +953,8 @@ private int readOther(String version, byte buffer[], int offset) throws Exceptio list.add(new IdsFlag(buffer, offset + 24, 4, "Status", "STATE.IDS")); list.add(new DecNumber(buffer, offset + 28, 2, "Current HP")); list.add(new DecNumber(buffer, offset + 30, 2, "Maximum HP")); - list.add(new IdsBitmap(buffer, offset + 32, 2, "Animation", "ANIMATE.IDS")); - list.add(new Unknown(buffer, offset + 34, 2)); + list.add(new IdsBitmap(buffer, offset + 32, 4, "Animation", "ANIMATE.IDS")); +// list.add(new Unknown(buffer, offset + 34, 2)); // if (version.equalsIgnoreCase("V1.2") || version.equalsIgnoreCase("V1.1")) // list.add(new Unknown(buffer, offset + 36, 7)); // else { @@ -1021,7 +1027,7 @@ private int readOther(String version, byte buffer[], int offset) throws Exceptio list.add(new DecNumber(buffer, offset + 107, 1, "Spiked proficiency")); list.add(new DecNumber(buffer, offset + 108, 1, "Axe proficiency")); list.add(new DecNumber(buffer, offset + 109, 1, "Missile proficiency")); - list.add(new Unknown(buffer, offset + 110, 13)); + list.add(new Unknown(buffer, offset + 110, 12)); } else if (version.equalsIgnoreCase("V1.2") || version.equalsIgnoreCase("V1.1")) { list.add(new DecNumber(buffer, offset + 102, 1, "Fist proficiency")); @@ -1039,7 +1045,7 @@ else if (version.equalsIgnoreCase("V1.2") || version.equalsIgnoreCase("V1.1")) { // list.add(new DecNumber(buffer, offset + 114, 1, "Extra proficiency 7")); // list.add(new DecNumber(buffer, offset + 115, 1, "Extra proficiency 8")); // list.add(new DecNumber(buffer, offset + 116, 1, "Extra proficiency 9")); - list.add(new Unknown(buffer, offset + 108, 15)); + list.add(new Unknown(buffer, offset + 108, 14)); } else if (version.equalsIgnoreCase("V9.0")) { list.add(new DecNumber(buffer, offset + 102, 1, "Large sword proficiency")); @@ -1057,14 +1063,15 @@ else if (version.equalsIgnoreCase("V9.0")) { list.add(new DecNumber(buffer, offset + 114, 1, "Club proficiency")); list.add(new DecNumber(buffer, offset + 115, 1, "Quarterstaff proficiency")); list.add(new DecNumber(buffer, offset + 116, 1, "Crossbow proficiency")); - list.add(new Unknown(buffer, offset + 117, 6)); + list.add(new Unknown(buffer, offset + 117, 5)); } else { list.clear(); throw new Exception("Unsupported version: " + version); } + list.add(new DecNumber(buffer, offset + 122, 1, "Undead level")); list.add(new DecNumber(buffer, offset + 123, 1, "Tracking")); - list.add(new Unknown(buffer, offset + 124, 32)); + list.add(new TextString(buffer, offset + 124, 32, "Target")); LongIntegerHashMap sndmap = null; if (ResourceFactory.getInstance().resourceExists("SNDSLOT.IDS")) sndmap = IdsMapCache.get("SNDSLOT.IDS").getMap(); diff --git a/infinity/resource/cre/Item.java b/src/infinity/resource/cre/Item.java similarity index 100% rename from infinity/resource/cre/Item.java rename to src/infinity/resource/cre/Item.java diff --git a/infinity/resource/cre/Iwd2Ability.java b/src/infinity/resource/cre/Iwd2Ability.java similarity index 100% rename from infinity/resource/cre/Iwd2Ability.java rename to src/infinity/resource/cre/Iwd2Ability.java diff --git a/infinity/resource/cre/Iwd2Shape.java b/src/infinity/resource/cre/Iwd2Shape.java similarity index 100% rename from infinity/resource/cre/Iwd2Shape.java rename to src/infinity/resource/cre/Iwd2Shape.java diff --git a/infinity/resource/cre/Iwd2Song.java b/src/infinity/resource/cre/Iwd2Song.java similarity index 100% rename from infinity/resource/cre/Iwd2Song.java rename to src/infinity/resource/cre/Iwd2Song.java diff --git a/infinity/resource/cre/Iwd2Spell.java b/src/infinity/resource/cre/Iwd2Spell.java similarity index 100% rename from infinity/resource/cre/Iwd2Spell.java rename to src/infinity/resource/cre/Iwd2Spell.java diff --git a/infinity/resource/cre/Iwd2Struct.java b/src/infinity/resource/cre/Iwd2Struct.java similarity index 100% rename from infinity/resource/cre/Iwd2Struct.java rename to src/infinity/resource/cre/Iwd2Struct.java diff --git a/infinity/resource/cre/KnownSpells.java b/src/infinity/resource/cre/KnownSpells.java similarity index 100% rename from infinity/resource/cre/KnownSpells.java rename to src/infinity/resource/cre/KnownSpells.java diff --git a/infinity/resource/cre/MemorizedSpells.java b/src/infinity/resource/cre/MemorizedSpells.java similarity index 96% rename from infinity/resource/cre/MemorizedSpells.java rename to src/infinity/resource/cre/MemorizedSpells.java index 08c5904..4c5e287 100644 --- a/infinity/resource/cre/MemorizedSpells.java +++ b/src/infinity/resource/cre/MemorizedSpells.java @@ -10,7 +10,7 @@ final class MemorizedSpells extends AbstractStruct implements AddRemovable { - private static final String[] s_mem = {"Spell already cast", "Spell memorized"}; + private static final String[] s_mem = {"Spell already cast", "Spell memorized", "Spell disabled"}; MemorizedSpells() throws Exception { diff --git a/infinity/resource/cre/SpellMemorization.java b/src/infinity/resource/cre/SpellMemorization.java similarity index 100% rename from infinity/resource/cre/SpellMemorization.java rename to src/infinity/resource/cre/SpellMemorization.java diff --git a/infinity/resource/cre/Viewer.java b/src/infinity/resource/cre/Viewer.java similarity index 100% rename from infinity/resource/cre/Viewer.java rename to src/infinity/resource/cre/Viewer.java diff --git a/infinity/resource/cre/ViewerItems.java b/src/infinity/resource/cre/ViewerItems.java similarity index 100% rename from infinity/resource/cre/ViewerItems.java rename to src/infinity/resource/cre/ViewerItems.java diff --git a/infinity/resource/cre/ViewerSpells.java b/src/infinity/resource/cre/ViewerSpells.java similarity index 100% rename from infinity/resource/cre/ViewerSpells.java rename to src/infinity/resource/cre/ViewerSpells.java diff --git a/infinity/resource/dlg/AbstractCode.java b/src/infinity/resource/dlg/AbstractCode.java similarity index 100% rename from infinity/resource/dlg/AbstractCode.java rename to src/infinity/resource/dlg/AbstractCode.java diff --git a/infinity/resource/dlg/Action.java b/src/infinity/resource/dlg/Action.java similarity index 100% rename from infinity/resource/dlg/Action.java rename to src/infinity/resource/dlg/Action.java diff --git a/infinity/resource/dlg/DialogItemRefSearcher.java b/src/infinity/resource/dlg/DialogItemRefSearcher.java similarity index 96% rename from infinity/resource/dlg/DialogItemRefSearcher.java rename to src/infinity/resource/dlg/DialogItemRefSearcher.java index 0df9c6c..6afd942 100644 --- a/infinity/resource/dlg/DialogItemRefSearcher.java +++ b/src/infinity/resource/dlg/DialogItemRefSearcher.java @@ -1,128 +1,128 @@ -package infinity.resource.dlg; - -import infinity.resource.StructEntry; -import infinity.search.ReferenceHitFrame; - -import java.awt.Component; -import java.util.List; - -import javax.swing.JOptionPane; -import javax.swing.ProgressMonitor; - - -public class DialogItemRefSearcher implements Runnable { - - private final DlgResource dlg; - private final Object item; - private final Component parent; - private final ReferenceHitFrame hitFrame; - - public DialogItemRefSearcher(DlgResource dlg, Object item, Component parent) { - this.dlg = dlg; - this.parent = parent; - this.item = item; - hitFrame = new ReferenceHitFrame(item, parent); - new Thread(this).start(); - } - - public void run() { - List searchItems = dlg.getList(); - ProgressMonitor progress = new ProgressMonitor(parent, "Searching...", null, 0, searchItems.size()); - progress.setMillisToDecideToPopup(100); - long startTime = System.currentTimeMillis(); - for (int i = 0; i < searchItems.size(); i++) { - StructEntry entry = searchItems.get(i); - if (entry instanceof State || entry instanceof Transition || entry instanceof AbstractCode) { - search(entry); - } - progress.setProgress(i + 1); - if (progress.isCanceled()) { - JOptionPane.showMessageDialog(parent, "Search canceled", "Info", JOptionPane.INFORMATION_MESSAGE); - return; - } - } - System.out.println("Search completed: " + (System.currentTimeMillis() - startTime) + "ms."); - hitFrame.setVisible(true); - } - - void search(StructEntry entry) { - boolean found = false; - - // ugly dispatching, depending on what we have and what we look for - if (item instanceof State) { - // check transitions - if (entry instanceof Transition) { - State state = (State) item; - int stateNumber = state.getNumber(); - Transition trans = (Transition) entry; - String nextDialog = trans.getNextDialog().getResourceName(); - if ((trans.getNextDialogState() == stateNumber) - && (nextDialog.equalsIgnoreCase(dlg.getName()))) { - found = true; - } - } - } - else if (item instanceof Transition) { - // check states - if (entry instanceof State) { - Transition trans = (Transition) item; - State state = (State) entry; - int transNumber = trans.getNumber(); - int firstTrans = state.getFirstTrans(); - int transCount = state.getTransCount(); - if ((transNumber >= firstTrans) - && (transNumber < (firstTrans + transCount))) { - found = true; - } - } - } - else if (item instanceof StateTrigger) { - // check states - if (entry instanceof State) { - StateTrigger trigger = (StateTrigger) item; - State state = (State) entry; - int triggerNumber = getIndexFromName(trigger.getName()); - if (triggerNumber == state.getTriggerIndex()) { - found = true; - } - } - } - else if (item instanceof ResponseTrigger) { - // check transitions - if (entry instanceof Transition) { - ResponseTrigger trigger = (ResponseTrigger) item; - Transition trans = (Transition) entry; - int triggerNumber = getIndexFromName(trigger.getName()); - if (triggerNumber == trans.getTriggerIndex()) { - found = true; - } - } - } - else if (item instanceof Action) { - // check transitions - if (entry instanceof Transition) { - Action action = (Action) item; - Transition trans = (Transition) entry; - int actionNumber = getIndexFromName(action.getName()); - if (actionNumber == trans.getActionIndex()) { - found = true; - } - } - } - - if (found) { - hitFrame.addHit(dlg.getResourceEntry(), entry.getName(), entry); - } - } - - // tries to return the last number in the name - private int getIndexFromName(String name) { - int posSpace = name.lastIndexOf(' '); - if (posSpace != -1) { - try { - return Integer.parseInt(name.substring(posSpace + 1)); - } catch (NumberFormatException nfe) {} - } - return -1; - } +package infinity.resource.dlg; + +import infinity.resource.StructEntry; +import infinity.search.ReferenceHitFrame; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JOptionPane; +import javax.swing.ProgressMonitor; + + +public class DialogItemRefSearcher implements Runnable { + + private final DlgResource dlg; + private final Object item; + private final Component parent; + private final ReferenceHitFrame hitFrame; + + public DialogItemRefSearcher(DlgResource dlg, Object item, Component parent) { + this.dlg = dlg; + this.parent = parent; + this.item = item; + hitFrame = new ReferenceHitFrame(item, parent); + new Thread(this).start(); + } + + public void run() { + List searchItems = dlg.getList(); + ProgressMonitor progress = new ProgressMonitor(parent, "Searching...", null, 0, searchItems.size()); + progress.setMillisToDecideToPopup(100); + long startTime = System.currentTimeMillis(); + for (int i = 0; i < searchItems.size(); i++) { + StructEntry entry = searchItems.get(i); + if (entry instanceof State || entry instanceof Transition || entry instanceof AbstractCode) { + search(entry); + } + progress.setProgress(i + 1); + if (progress.isCanceled()) { + JOptionPane.showMessageDialog(parent, "Search canceled", "Info", JOptionPane.INFORMATION_MESSAGE); + return; + } + } + System.out.println("Search completed: " + (System.currentTimeMillis() - startTime) + "ms."); + hitFrame.setVisible(true); + } + + void search(StructEntry entry) { + boolean found = false; + + // ugly dispatching, depending on what we have and what we look for + if (item instanceof State) { + // check transitions + if (entry instanceof Transition) { + State state = (State) item; + int stateNumber = state.getNumber(); + Transition trans = (Transition) entry; + String nextDialog = trans.getNextDialog().getResourceName(); + if ((trans.getNextDialogState() == stateNumber) + && (nextDialog.equalsIgnoreCase(dlg.getName()))) { + found = true; + } + } + } + else if (item instanceof Transition) { + // check states + if (entry instanceof State) { + Transition trans = (Transition) item; + State state = (State) entry; + int transNumber = trans.getNumber(); + int firstTrans = state.getFirstTrans(); + int transCount = state.getTransCount(); + if ((transNumber >= firstTrans) + && (transNumber < (firstTrans + transCount))) { + found = true; + } + } + } + else if (item instanceof StateTrigger) { + // check states + if (entry instanceof State) { + StateTrigger trigger = (StateTrigger) item; + State state = (State) entry; + int triggerNumber = getIndexFromName(trigger.getName()); + if (triggerNumber == state.getTriggerIndex()) { + found = true; + } + } + } + else if (item instanceof ResponseTrigger) { + // check transitions + if (entry instanceof Transition) { + ResponseTrigger trigger = (ResponseTrigger) item; + Transition trans = (Transition) entry; + int triggerNumber = getIndexFromName(trigger.getName()); + if (triggerNumber == trans.getTriggerIndex()) { + found = true; + } + } + } + else if (item instanceof Action) { + // check transitions + if (entry instanceof Transition) { + Action action = (Action) item; + Transition trans = (Transition) entry; + int actionNumber = getIndexFromName(action.getName()); + if (actionNumber == trans.getActionIndex()) { + found = true; + } + } + } + + if (found) { + hitFrame.addHit(dlg.getResourceEntry(), entry.getName(), entry); + } + } + + // tries to return the last number in the name + private int getIndexFromName(String name) { + int posSpace = name.lastIndexOf(' '); + if (posSpace != -1) { + try { + return Integer.parseInt(name.substring(posSpace + 1)); + } catch (NumberFormatException nfe) {} + } + return -1; + } } \ No newline at end of file diff --git a/infinity/resource/dlg/DlgResource.java b/src/infinity/resource/dlg/DlgResource.java similarity index 100% rename from infinity/resource/dlg/DlgResource.java rename to src/infinity/resource/dlg/DlgResource.java diff --git a/infinity/resource/dlg/ResponseTrigger.java b/src/infinity/resource/dlg/ResponseTrigger.java similarity index 100% rename from infinity/resource/dlg/ResponseTrigger.java rename to src/infinity/resource/dlg/ResponseTrigger.java diff --git a/infinity/resource/dlg/State.java b/src/infinity/resource/dlg/State.java similarity index 100% rename from infinity/resource/dlg/State.java rename to src/infinity/resource/dlg/State.java diff --git a/infinity/resource/dlg/StateTrigger.java b/src/infinity/resource/dlg/StateTrigger.java similarity index 100% rename from infinity/resource/dlg/StateTrigger.java rename to src/infinity/resource/dlg/StateTrigger.java diff --git a/infinity/resource/dlg/Transition.java b/src/infinity/resource/dlg/Transition.java similarity index 100% rename from infinity/resource/dlg/Transition.java rename to src/infinity/resource/dlg/Transition.java diff --git a/infinity/resource/dlg/Viewer.java b/src/infinity/resource/dlg/Viewer.java similarity index 100% rename from infinity/resource/dlg/Viewer.java rename to src/infinity/resource/dlg/Viewer.java diff --git a/infinity/resource/gam/Familiar.java b/src/infinity/resource/gam/Familiar.java similarity index 100% rename from infinity/resource/gam/Familiar.java rename to src/infinity/resource/gam/Familiar.java diff --git a/infinity/resource/gam/GamResource.java b/src/infinity/resource/gam/GamResource.java similarity index 93% rename from infinity/resource/gam/GamResource.java rename to src/infinity/resource/gam/GamResource.java index 0332a66..d7e7a10 100644 --- a/infinity/resource/gam/GamResource.java +++ b/src/infinity/resource/gam/GamResource.java @@ -15,7 +15,9 @@ public final class GamResource extends AbstractStruct implements Resource, HasAddRemovable, HasDetailViewer { private static final String s_formation[] = {"Button 1", "Button 2", "Button 3", "Button 4", "Button 5"}; - private static final String s_weather[] = {"No weather", "Raining", "Snowing"}; + private static final String s_weather[] = {"No weather", "Raining", "Snowing", "Light weather", + "Medium weather", "Light wind", "Medium wind", "Rare lightning", + "Regular lightning", "Storm increasing"}; private static final String s_torment[] = {"Follow", "T", "Gather", "4 and 2", "3 by 2", "Protect", "2 by 3", "Rank", "V", "Wedge", "S", "Line", "None"}; @@ -104,10 +106,10 @@ protected int read(byte buffer[], int offset) throws Exception SectionCount count_partynpc = new SectionCount(buffer, offset + 36, 4, "# party members", PartyNPC.class); list.add(count_partynpc); - SectionOffset offset_unknown = new SectionOffset(buffer, offset + 40, "Unknown section offset", + SectionOffset offset_unknown = new SectionOffset(buffer, offset + 40, "Party inventory offset", UnknownSection2.class); list.add(offset_unknown); - SectionCount count_unknown = new SectionCount(buffer, offset + 44, 4, "Unknown section count", + SectionCount count_unknown = new SectionCount(buffer, offset + 44, 4, "Party inventory count", UnknownSection2.class); list.add(count_unknown); SectionOffset offset_nonpartynpc = new SectionOffset(buffer, offset + 48, "Non-party characters offset", @@ -122,8 +124,8 @@ protected int read(byte buffer[], int offset) throws Exception SectionCount count_global = new SectionCount(buffer, offset + 60, 4, "# global variables", Variable.class); list.add(count_global); - list.add(new ResourceRef(buffer, offset + 64, "Main area", "ARE")); - list.add(new Unknown(buffer, offset + 72, 4)); + list.add(new ResourceRef(buffer, offset + 64, "Current area", "ARE")); + list.add(new DecNumber(buffer, offset + 72, 4, "Current link")); SectionCount count_journal = new SectionCount(buffer, offset + 76, 4, "# journal entries", JournalEntry.class); list.add(count_journal); @@ -138,17 +140,17 @@ protected int read(byte buffer[], int offset) throws Exception int gameid = ResourceFactory.getGameID(); if (gameid == ResourceFactory.ID_BG1 || gameid == ResourceFactory.ID_BG1TOTSC) { // V1.1 list.add(new DecNumber(buffer, offset + 84, 4, "Reputation")); - list.add(new ResourceRef(buffer, offset + 88, "Current area", "ARE")); + list.add(new ResourceRef(buffer, offset + 88, "Master area", "ARE")); list.add(new Flag(buffer, offset + 96, 4, "Configuration", new String[]{"Normal windows", "Party AI disabled", "Larger text window", "Largest text window"})); - list.add(new Unknown(buffer, offset + 100, 4)); + list.add(new DecNumber(buffer, offset + 100, 4, "Save version")); list.add(new Unknown(buffer, offset + 104, 76)); } else if (gameid == ResourceFactory.ID_ICEWIND || gameid == ResourceFactory.ID_ICEWINDHOW || gameid == ResourceFactory.ID_ICEWINDHOWTOT) { // V1.1 list.add(new DecNumber(buffer, offset + 84, 4, "Reputation")); - list.add(new ResourceRef(buffer, offset + 88, "Current area", "ARE")); + list.add(new ResourceRef(buffer, offset + 88, "Master area", "ARE")); list.add(new Flag(buffer, offset + 96, 4, "Configuration", new String[]{"Normal windows", "", "Larger text window", "Largest text window"})); @@ -162,7 +164,7 @@ else if (gameid == ResourceFactory.ID_TORMENT) { // V1.1 offRubikon = new SectionOffset(buffer, offset + 84, "Modron maze offset", Unknown.class); list.add(offRubikon); list.add(new DecNumber(buffer, offset + 88, 4, "Reputation")); - list.add(new ResourceRef(buffer, offset + 92, "Current area", "ARE")); + list.add(new ResourceRef(buffer, offset + 92, "Master area", "ARE")); offKillvariable = new SectionOffset(buffer, offset + 100, "Kill variables offset", KillVariable.class); list.add(offKillvariable); numKillVariable = new SectionCount(buffer, offset + 104, 4, "# kill variables", KillVariable.class); @@ -175,12 +177,12 @@ else if (gameid == ResourceFactory.ID_TORMENT) { // V1.1 else if (gameid == ResourceFactory.ID_BG2 || gameid == ResourceFactory.ID_BG2TOB || gameid == ResourceFactory.ID_TUTU) { // V2.0 list.add(new DecNumber(buffer, offset + 84, 4, "Reputation")); - list.add(new ResourceRef(buffer, offset + 88, "Current area", "ARE")); + list.add(new ResourceRef(buffer, offset + 88, "Master area", "ARE")); list.add(new Flag(buffer, offset + 96, 4, "Configuration", new String[]{"Normal windows", "Party AI disabled", "Larger text window", "Largest text window", "", "Fullscreen mode", "Left pane hidden", "Right pane hidden", "Automap notes hidden"})); - list.add(new Unknown(buffer, offset + 100, 4)); + list.add(new DecNumber(buffer, offset + 100, 4, "Save version")); offFamiliar = new SectionOffset(buffer, offset + 104, "Familiar info offset", Familiar.class); list.add(offFamiliar); // list.add(new DecNumber(buffer, offset + 108, 4, "File size")); @@ -196,7 +198,7 @@ else if (gameid == ResourceFactory.ID_BG2 || gameid == ResourceFactory.ID_BG2TOB } else if (gameid == ResourceFactory.ID_ICEWIND2) { // V2.2 (V1.1 & V2.0 in BIFF) list.add(new Unknown(buffer, offset + 84, 4)); - list.add(new ResourceRef(buffer, offset + 88, "Current area?", "ARE")); + list.add(new ResourceRef(buffer, offset + 88, "Master area", "ARE")); list.add(new Flag(buffer, offset + 96, 4, "Configuration", new String[]{"Normal windows", "Party AI disabled", "", "", "", "Fullscreen mode", "Button bar hidden", diff --git a/infinity/resource/gam/JournalEntry.java b/src/infinity/resource/gam/JournalEntry.java similarity index 100% rename from infinity/resource/gam/JournalEntry.java rename to src/infinity/resource/gam/JournalEntry.java diff --git a/infinity/resource/gam/KillVariable.java b/src/infinity/resource/gam/KillVariable.java similarity index 100% rename from infinity/resource/gam/KillVariable.java rename to src/infinity/resource/gam/KillVariable.java diff --git a/infinity/resource/gam/NonPartyNPC.java b/src/infinity/resource/gam/NonPartyNPC.java similarity index 100% rename from infinity/resource/gam/NonPartyNPC.java rename to src/infinity/resource/gam/NonPartyNPC.java diff --git a/infinity/resource/gam/PartyNPC.java b/src/infinity/resource/gam/PartyNPC.java similarity index 82% rename from infinity/resource/gam/PartyNPC.java rename to src/infinity/resource/gam/PartyNPC.java index d3367ab..048bee4 100644 --- a/infinity/resource/gam/PartyNPC.java +++ b/src/infinity/resource/gam/PartyNPC.java @@ -16,7 +16,6 @@ class PartyNPC extends AbstractStruct implements HasDetailViewer, HasAddRemovabl { private static final LongIntegerHashMap partyOrder = new LongIntegerHashMap(); private static final LongIntegerHashMap m_selected = new LongIntegerHashMap(); - private static final LongIntegerHashMap m_partyslot = new LongIntegerHashMap(); private static final String s_noyes[] = {"No", "Yes"}; static { @@ -32,9 +31,6 @@ class PartyNPC extends AbstractStruct implements HasDetailViewer, HasAddRemovabl m_selected.put(0L, "Not selected"); m_selected.put(1L, "Selected"); m_selected.put(32768L, "Dead"); - - m_partyslot.put(0L, "Yes"); - m_partyslot.put(65535L, "No"); } PartyNPC() throws Exception @@ -133,19 +129,19 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new IdsBitmap(buffer, offset + 142, 2, "Quick weapon slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 144, 2, "Quick weapon slot 3", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 146, 2, "Quick weapon slot 4", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 148, 2, "Show quick weapon 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 150, 2, "Show quick weapon 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 152, 2, "Show quick weapon 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 154, 2, "Show quick weapon 4?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 148, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 150, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 152, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 154, 2, "Quick weapon 4 ability")); list.add(new ResourceRef(buffer, offset + 156, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 164, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 172, "Quick spell 3", "SPL")); list.add(new IdsBitmap(buffer, offset + 180, 2, "Quick item slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 182, 2, "Quick item slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 184, 2, "Quick item slot 3", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 186, 2, "Show quick item 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 188, 2, "Show quick item 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 190, 2, "Show quick item 3?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 186, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 188, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 190, 2, "Quick item 3 ability")); list.add(new TextString(buffer, offset + 192, 32, "Name")); list.add(new DecNumber(buffer, offset + 224, 4, "# times talked to")); offset = readCharStats(buffer, offset + 228); @@ -161,19 +157,19 @@ else if (gameid == ResourceFactory.ID_BG2 || gameid == ResourceFactory.ID_BG2TOB list.add(new IdsBitmap(buffer, offset + 142, 2, "Quick weapon slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 144, 2, "Quick weapon slot 3", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 146, 2, "Quick weapon slot 4", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 148, 2, "Show quick weapon 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 150, 2, "Show quick weapon 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 152, 2, "Show quick weapon 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 154, 2, "Show quick weapon 4?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 148, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 150, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 152, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 154, 2, "Quick weapon 4 ability")); list.add(new ResourceRef(buffer, offset + 156, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 164, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 172, "Quick spell 3", "SPL")); list.add(new IdsBitmap(buffer, offset + 180, 2, "Quick item slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 182, 2, "Quick item slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 184, 2, "Quick item slot 3", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 186, 2, "Show quick item 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 188, 2, "Show quick item 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 190, 2, "Show quick item 3?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 186, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 188, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 190, 2, "Quick item 3 ability")); list.add(new TextString(buffer, offset + 192, 32, "Name")); list.add(new DecNumber(buffer, offset + 224, 4, "# times talked to")); offset = readCharStats(buffer, offset + 228); @@ -188,10 +184,10 @@ else if (gameid == ResourceFactory.ID_TORMENT) { list.add(new DecNumber(buffer, offset + 142, 2, "Quick weapon slot 2")); list.add(new DecNumber(buffer, offset + 144, 2, "Quick weapon slot 3")); list.add(new DecNumber(buffer, offset + 146, 2, "Quick weapon slot 4")); - list.add(new HashBitmap(buffer, offset + 148, 2, "Show quick weapon 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 150, 2, "Show quick weapon 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 152, 2, "Show quick weapon 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 154, 2, "Show quick weapon 4?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 148, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 150, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 152, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 154, 2, "Quick weapon 4 ability")); list.add(new ResourceRef(buffer, offset + 156, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 164, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 172, "Quick spell 3", "SPL")); @@ -200,11 +196,11 @@ else if (gameid == ResourceFactory.ID_TORMENT) { list.add(new DecNumber(buffer, offset + 184, 2, "Quick item slot 3")); list.add(new DecNumber(buffer, offset + 186, 2, "Quick item slot 4")); list.add(new DecNumber(buffer, offset + 188, 2, "Quick item slot 5")); - list.add(new HashBitmap(buffer, offset + 190, 2, "Show quick item 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 192, 2, "Show quick item 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 194, 2, "Show quick item 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 196, 2, "Show quick item 4?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 198, 2, "Show quick item 5?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 190, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 192, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 194, 2, "Quick item 3 ability")); + list.add(new DecNumber(buffer, offset + 196, 2, "Quick item 4 ability")); + list.add(new DecNumber(buffer, offset + 198, 2, "Quick item 5 ability")); list.add(new TextString(buffer, offset + 200, 32, "Name")); list.add(new DecNumber(buffer, offset + 232, 4, "# times talked to")); offset = readCharStats(buffer, offset + 236); @@ -219,19 +215,19 @@ else if (gameid == ResourceFactory.ID_ICEWIND || gameid == ResourceFactory.ID_IC list.add(new IdsBitmap(buffer, offset + 142, 2, "Quick weapon slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 144, 2, "Quick weapon slot 3", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 146, 2, "Quick weapon slot 4", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 148, 2, "Show quick weapon 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 150, 2, "Show quick weapon 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 152, 2, "Show quick weapon 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 154, 2, "Show quick weapon 4?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 148, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 150, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 152, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 154, 2, "Quick weapon 4 ability")); list.add(new ResourceRef(buffer, offset + 156, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 164, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 172, "Quick spell 3", "SPL")); list.add(new IdsBitmap(buffer, offset + 180, 2, "Quick item slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 182, 2, "Quick item slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 184, 2, "Quick item slot 3", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 186, 2, "Show quick item 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 188, 2, "Show quick item 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 190, 2, "Show quick item 3?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 186, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 188, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 190, 2, "Quick item 3 ability")); list.add(new TextString(buffer, offset + 192, 32, "Name")); list.add(new Unknown(buffer, offset + 224, 4)); offset = readCharStats(buffer, offset + 228); @@ -250,14 +246,14 @@ else if (gameid == ResourceFactory.ID_ICEWIND2) { list.add(new IdsBitmap(buffer, offset + 150, 2, "Quick shield slot 3", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 152, 2, "Quick weapon slot 4", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 154, 2, "Quick shield slot 4", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 156, 2, "Show quick weapon 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 158, 2, "Show quick shield 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 160, 2, "Show quick weapon 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 162, 2, "Show quick shield 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 164, 2, "Show quick weapon 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 166, 2, "Show quick shield 3?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 168, 2, "Show quick weapon 4?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 170, 2, "Show quick shield 4?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 156, 2, "Quick weapon 1 ability")); + list.add(new DecNumber(buffer, offset + 158, 2, "Quick shield 1 ability")); + list.add(new DecNumber(buffer, offset + 160, 2, "Quick weapon 2 ability")); + list.add(new DecNumber(buffer, offset + 162, 2, "Quick shield 2 ability")); + list.add(new DecNumber(buffer, offset + 164, 2, "Quick weapon 3 ability")); + list.add(new DecNumber(buffer, offset + 166, 2, "Quick shield 3 ability")); + list.add(new DecNumber(buffer, offset + 168, 2, "Quick weapon 4 ability")); + list.add(new DecNumber(buffer, offset + 170, 2, "Quick shield 4 ability")); list.add(new ResourceRef(buffer, offset + 172, "Quick spell 1", "SPL")); list.add(new ResourceRef(buffer, offset + 180, "Quick spell 2", "SPL")); list.add(new ResourceRef(buffer, offset + 188, "Quick spell 3", "SPL")); @@ -280,9 +276,9 @@ else if (gameid == ResourceFactory.ID_ICEWIND2) { list.add(new IdsBitmap(buffer, offset + 254, 2, "Quick item slot 1", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 256, 2, "Quick item slot 2", "SLOTS.IDS")); list.add(new IdsBitmap(buffer, offset + 258, 2, "Quick item slot 3", "SLOTS.IDS")); - list.add(new HashBitmap(buffer, offset + 260, 2, "Show quick item 1?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 262, 2, "Show quick item 2?", m_partyslot)); - list.add(new HashBitmap(buffer, offset + 264, 2, "Show quick item 3?", m_partyslot)); + list.add(new DecNumber(buffer, offset + 260, 2, "Quick item 1 ability")); + list.add(new DecNumber(buffer, offset + 262, 2, "Quick item 2 ability")); + list.add(new DecNumber(buffer, offset + 264, 2, "Quick item 3 ability")); list.add(new ResourceRef(buffer, offset + 266, "Quick ability 1", "SPL")); list.add(new ResourceRef(buffer, offset + 274, "Quick ability 2", "SPL")); list.add(new ResourceRef(buffer, offset + 282, "Quick ability 3", "SPL")); diff --git a/infinity/resource/gam/StoredLocation.java b/src/infinity/resource/gam/StoredLocation.java similarity index 100% rename from infinity/resource/gam/StoredLocation.java rename to src/infinity/resource/gam/StoredLocation.java diff --git a/infinity/resource/gam/UnknownSection.java b/src/infinity/resource/gam/UnknownSection.java similarity index 100% rename from infinity/resource/gam/UnknownSection.java rename to src/infinity/resource/gam/UnknownSection.java diff --git a/infinity/resource/gam/UnknownSection2.java b/src/infinity/resource/gam/UnknownSection2.java similarity index 100% rename from infinity/resource/gam/UnknownSection2.java rename to src/infinity/resource/gam/UnknownSection2.java diff --git a/infinity/resource/gam/UnknownSection3.java b/src/infinity/resource/gam/UnknownSection3.java similarity index 100% rename from infinity/resource/gam/UnknownSection3.java rename to src/infinity/resource/gam/UnknownSection3.java diff --git a/infinity/resource/gam/Variable.java b/src/infinity/resource/gam/Variable.java similarity index 76% rename from infinity/resource/gam/Variable.java rename to src/infinity/resource/gam/Variable.java index 5a4537f..555ae99 100644 --- a/infinity/resource/gam/Variable.java +++ b/src/infinity/resource/gam/Variable.java @@ -10,6 +10,9 @@ class Variable extends AbstractStruct implements AddRemovable { + private static final String s_type[] = {"Integer", "Float", "Script name", "Resource reference", + "String reference", "Double word"}; + Variable() throws Exception { super(null, "Variable", new byte[84], 0); @@ -28,7 +31,8 @@ class Variable extends AbstractStruct implements AddRemovable protected int read(byte buffer[], int offset) throws Exception { list.add(new TextString(buffer, offset, 32, "Name")); - list.add(new Unknown(buffer, offset + 32, 8)); + list.add(new Bitmap(buffer, offset + 32, 2, "Type", s_type)); + list.add(new Unknown(buffer, offset + 34, 6)); list.add(new DecNumber(buffer, offset + 40, 4, "Value")); list.add(new Unknown(buffer, offset + 44, 40)); return offset + 84; diff --git a/infinity/resource/gam/Viewer.java b/src/infinity/resource/gam/Viewer.java similarity index 97% rename from infinity/resource/gam/Viewer.java rename to src/infinity/resource/gam/Viewer.java index 106598e..792f196 100644 --- a/infinity/resource/gam/Viewer.java +++ b/src/infinity/resource/gam/Viewer.java @@ -26,7 +26,7 @@ private static JPanel makeMiscPanel(GamResource gam) ResourceFactory.getGameID() == ResourceFactory.ID_TUTU) // V2.0 - better check? ViewerUtil.addLabelFieldPair(panel, gam.getAttribute("Game time (real seconds)"), gbl, gbc, true); ViewerUtil.addLabelFieldPair(panel, gam.getAttribute("Party gold"), gbl, gbc, true); - ViewerUtil.addLabelFieldPair(panel, gam.getAttribute("Main area"), gbl, gbc, true); + ViewerUtil.addLabelFieldPair(panel, gam.getAttribute("Master area"), gbl, gbc, true); return panel; } diff --git a/infinity/resource/gam/ViewerNPC.java b/src/infinity/resource/gam/ViewerNPC.java similarity index 100% rename from infinity/resource/gam/ViewerNPC.java rename to src/infinity/resource/gam/ViewerNPC.java diff --git a/infinity/resource/graphics/BamResource.java b/src/infinity/resource/graphics/BamResource.java similarity index 98% rename from infinity/resource/graphics/BamResource.java rename to src/infinity/resource/graphics/BamResource.java index 30aea69..e30fe00 100644 --- a/infinity/resource/graphics/BamResource.java +++ b/src/infinity/resource/graphics/BamResource.java @@ -103,8 +103,7 @@ else if (event.getSource() == bprevframe) { else if (event.getSource() == bnextanim) { selectedAnim++; // stop timer if no frames in current cycle - if ((timer != null) && timer.isRunning() - && (anims[selectedAnim].frameCount == 0)) { + if (timer != null && timer.isRunning() && anims[selectedAnim].frameCount == 0) { timer.stop(); bplay.setSelected(false); } @@ -113,8 +112,7 @@ else if (event.getSource() == bnextanim) { } else if (event.getSource() == bprevanim) { selectedAnim--; - if ((timer != null) && timer.isRunning() - && (anims[selectedAnim].frameCount == 0)) { + if (timer != null && timer.isRunning() && anims[selectedAnim].frameCount == 0) { timer.stop(); bplay.setSelected(false); } diff --git a/infinity/resource/graphics/BmpResource.java b/src/infinity/resource/graphics/BmpResource.java similarity index 100% rename from infinity/resource/graphics/BmpResource.java rename to src/infinity/resource/graphics/BmpResource.java diff --git a/infinity/resource/graphics/Compressor.java b/src/infinity/resource/graphics/Compressor.java similarity index 100% rename from infinity/resource/graphics/Compressor.java rename to src/infinity/resource/graphics/Compressor.java diff --git a/infinity/resource/graphics/MosResource.java b/src/infinity/resource/graphics/MosResource.java similarity index 100% rename from infinity/resource/graphics/MosResource.java rename to src/infinity/resource/graphics/MosResource.java diff --git a/infinity/resource/graphics/MveResource.java b/src/infinity/resource/graphics/MveResource.java similarity index 100% rename from infinity/resource/graphics/MveResource.java rename to src/infinity/resource/graphics/MveResource.java diff --git a/infinity/resource/graphics/Palette.java b/src/infinity/resource/graphics/Palette.java similarity index 100% rename from infinity/resource/graphics/Palette.java rename to src/infinity/resource/graphics/Palette.java diff --git a/infinity/resource/graphics/PltResource.java b/src/infinity/resource/graphics/PltResource.java similarity index 100% rename from infinity/resource/graphics/PltResource.java rename to src/infinity/resource/graphics/PltResource.java diff --git a/infinity/resource/graphics/TgaResource.java b/src/infinity/resource/graphics/TgaResource.java similarity index 100% rename from infinity/resource/graphics/TgaResource.java rename to src/infinity/resource/graphics/TgaResource.java diff --git a/infinity/resource/graphics/TisResource.java b/src/infinity/resource/graphics/TisResource.java similarity index 100% rename from infinity/resource/graphics/TisResource.java rename to src/infinity/resource/graphics/TisResource.java diff --git a/infinity/resource/graphics/mve.stub b/src/infinity/resource/graphics/mve.stub similarity index 100% rename from infinity/resource/graphics/mve.stub rename to src/infinity/resource/graphics/mve.stub diff --git a/infinity/resource/itm/Ability.java b/src/infinity/resource/itm/Ability.java similarity index 97% rename from infinity/resource/itm/Ability.java rename to src/infinity/resource/itm/Ability.java index c15fe26..2de11e9 100644 --- a/infinity/resource/itm/Ability.java +++ b/src/infinity/resource/itm/Ability.java @@ -18,7 +18,8 @@ final class Ability extends AbstractAbility implements AddRemovable, HasAddRemov private static final String[] s_abilityuse = {"", "Weapon slots", "", "Item slots", "Gem?"}; private static final String[] s_recharge = {"No flags set", "Add strength bonus", "Breakable", "", "", "", "", "", "", "", "", "Hostile", "Recharge after resting", - "", "", "", "", "Bypass armor", "Keen edge"}; + "", "", "", "", "Bypass armor", "Keen edge", "", "", "", "", "", "", + "", "Ex: toggle backstab", "Ex: cannot target invisible"}; Ability() throws Exception { diff --git a/infinity/resource/itm/ItmResource.java b/src/infinity/resource/itm/ItmResource.java similarity index 97% rename from infinity/resource/itm/ItmResource.java rename to src/infinity/resource/itm/ItmResource.java index f75bd5e..b4148e6 100644 --- a/infinity/resource/itm/ItmResource.java +++ b/src/infinity/resource/itm/ItmResource.java @@ -43,10 +43,11 @@ public final class ItmResource extends AbstractStruct implements Resource, HasAd "Earrings", "Tattoos", "Lenses", "Teeth"}; private static final String[] s_flags = {"None", "Unsellable", "Two-handed", "Droppable", "Displayable", - "Cursed", "Not copyable", "Magical", "Bow", "Silver", "Cold iron", "", "Conversable"}; + "Cursed", "Not copyable", "Magical", "Left-handed", "Silver", "Cold iron", "Off-handed", "Conversable", "", "", "", "", + "", "", "", "", "", "", "", "", "Ex: undispellable", "Ex: toggle critical hits"}; private static final String[] s_flags11 = {"None", "Unsellable", "Two-handed", "Droppable", "Displayable", - "Cursed", "Not copyable", "Magical", "", "Silver", "Cold iron", "Steel", "Conversable", + "Cursed", "Not copyable", "Magical", "Left-handed", "Silver", "Cold iron", "Steel", "Conversable", "Pulsating"}; private static final String[] s_usability = {"None", "Chaotic", "Evil", "Good", "... Neutral", "Lawful", diff --git a/infinity/resource/itm/Viewer.java b/src/infinity/resource/itm/Viewer.java similarity index 100% rename from infinity/resource/itm/Viewer.java rename to src/infinity/resource/itm/Viewer.java diff --git a/infinity/resource/itm/ViewerAbility.java b/src/infinity/resource/itm/ViewerAbility.java similarity index 100% rename from infinity/resource/itm/ViewerAbility.java rename to src/infinity/resource/itm/ViewerAbility.java diff --git a/infinity/resource/key/BIFFArchive.java b/src/infinity/resource/key/BIFFArchive.java similarity index 100% rename from infinity/resource/key/BIFFArchive.java rename to src/infinity/resource/key/BIFFArchive.java diff --git a/infinity/resource/key/BIFFEntry.java b/src/infinity/resource/key/BIFFEntry.java similarity index 100% rename from infinity/resource/key/BIFFEntry.java rename to src/infinity/resource/key/BIFFEntry.java diff --git a/infinity/resource/key/BIFFResourceEntry.java b/src/infinity/resource/key/BIFFResourceEntry.java similarity index 100% rename from infinity/resource/key/BIFFResourceEntry.java rename to src/infinity/resource/key/BIFFResourceEntry.java diff --git a/infinity/resource/key/BIFFWriter.java b/src/infinity/resource/key/BIFFWriter.java similarity index 100% rename from infinity/resource/key/BIFFWriter.java rename to src/infinity/resource/key/BIFFWriter.java diff --git a/infinity/resource/key/FileResourceEntry.java b/src/infinity/resource/key/FileResourceEntry.java similarity index 100% rename from infinity/resource/key/FileResourceEntry.java rename to src/infinity/resource/key/FileResourceEntry.java diff --git a/infinity/resource/key/Keyfile.java b/src/infinity/resource/key/Keyfile.java similarity index 100% rename from infinity/resource/key/Keyfile.java rename to src/infinity/resource/key/Keyfile.java diff --git a/infinity/resource/key/ResourceEntry.java b/src/infinity/resource/key/ResourceEntry.java similarity index 100% rename from infinity/resource/key/ResourceEntry.java rename to src/infinity/resource/key/ResourceEntry.java diff --git a/infinity/resource/key/ResourceTreeFolder.java b/src/infinity/resource/key/ResourceTreeFolder.java similarity index 100% rename from infinity/resource/key/ResourceTreeFolder.java rename to src/infinity/resource/key/ResourceTreeFolder.java diff --git a/infinity/resource/key/ResourceTreeModel.java b/src/infinity/resource/key/ResourceTreeModel.java similarity index 100% rename from infinity/resource/key/ResourceTreeModel.java rename to src/infinity/resource/key/ResourceTreeModel.java diff --git a/infinity/resource/kotor/GlobalVarsResource.java b/src/infinity/resource/kotor/GlobalVarsResource.java similarity index 100% rename from infinity/resource/kotor/GlobalVarsResource.java rename to src/infinity/resource/kotor/GlobalVarsResource.java diff --git a/infinity/resource/kotor/RimResource.java b/src/infinity/resource/kotor/RimResource.java similarity index 100% rename from infinity/resource/kotor/RimResource.java rename to src/infinity/resource/kotor/RimResource.java diff --git a/infinity/resource/mus/Entry.java b/src/infinity/resource/mus/Entry.java similarity index 100% rename from infinity/resource/mus/Entry.java rename to src/infinity/resource/mus/Entry.java diff --git a/infinity/resource/mus/MusResource.java b/src/infinity/resource/mus/MusResource.java similarity index 100% rename from infinity/resource/mus/MusResource.java rename to src/infinity/resource/mus/MusResource.java diff --git a/infinity/resource/mus/Viewer.java b/src/infinity/resource/mus/Viewer.java similarity index 98% rename from infinity/resource/mus/Viewer.java rename to src/infinity/resource/mus/Viewer.java index f047530..e0b8052 100644 --- a/infinity/resource/mus/Viewer.java +++ b/src/infinity/resource/mus/Viewer.java @@ -191,7 +191,7 @@ public void run() e.printStackTrace(); JOptionPane.showMessageDialog(parent, "Error converting " + entry + '\n' + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); - if (e.getMessage().equals("acm2wav.exe not found")) + if (e.getMessage().equals("Sound converter not found")) break; } blocker.setBlocked(false); diff --git a/infinity/resource/nwn/ErfResource.java b/src/infinity/resource/nwn/ErfResource.java similarity index 100% rename from infinity/resource/nwn/ErfResource.java rename to src/infinity/resource/nwn/ErfResource.java diff --git a/infinity/resource/nwn/NcsResource.java b/src/infinity/resource/nwn/NcsResource.java similarity index 100% rename from infinity/resource/nwn/NcsResource.java rename to src/infinity/resource/nwn/NcsResource.java diff --git a/infinity/resource/nwn/SsfResource.java b/src/infinity/resource/nwn/SsfResource.java similarity index 100% rename from infinity/resource/nwn/SsfResource.java rename to src/infinity/resource/nwn/SsfResource.java diff --git a/infinity/resource/nwn/TableTextResource.java b/src/infinity/resource/nwn/TableTextResource.java similarity index 100% rename from infinity/resource/nwn/TableTextResource.java rename to src/infinity/resource/nwn/TableTextResource.java diff --git a/infinity/resource/nwn/gff/DefaultGffEditor.java b/src/infinity/resource/nwn/gff/DefaultGffEditor.java similarity index 100% rename from infinity/resource/nwn/gff/DefaultGffEditor.java rename to src/infinity/resource/nwn/gff/DefaultGffEditor.java diff --git a/infinity/resource/nwn/gff/GffResource.java b/src/infinity/resource/nwn/gff/GffResource.java similarity index 100% rename from infinity/resource/nwn/gff/GffResource.java rename to src/infinity/resource/nwn/gff/GffResource.java diff --git a/infinity/resource/nwn/gff/field/GffByte.java b/src/infinity/resource/nwn/gff/field/GffByte.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffByte.java rename to src/infinity/resource/nwn/gff/field/GffByte.java diff --git a/infinity/resource/nwn/gff/field/GffChar.java b/src/infinity/resource/nwn/gff/field/GffChar.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffChar.java rename to src/infinity/resource/nwn/gff/field/GffChar.java diff --git a/infinity/resource/nwn/gff/field/GffDouble.java b/src/infinity/resource/nwn/gff/field/GffDouble.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffDouble.java rename to src/infinity/resource/nwn/gff/field/GffDouble.java diff --git a/infinity/resource/nwn/gff/field/GffDword.java b/src/infinity/resource/nwn/gff/field/GffDword.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffDword.java rename to src/infinity/resource/nwn/gff/field/GffDword.java diff --git a/infinity/resource/nwn/gff/field/GffDword64.java b/src/infinity/resource/nwn/gff/field/GffDword64.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffDword64.java rename to src/infinity/resource/nwn/gff/field/GffDword64.java diff --git a/infinity/resource/nwn/gff/field/GffExoLocString.java b/src/infinity/resource/nwn/gff/field/GffExoLocString.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffExoLocString.java rename to src/infinity/resource/nwn/gff/field/GffExoLocString.java diff --git a/infinity/resource/nwn/gff/field/GffExoString.java b/src/infinity/resource/nwn/gff/field/GffExoString.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffExoString.java rename to src/infinity/resource/nwn/gff/field/GffExoString.java diff --git a/infinity/resource/nwn/gff/field/GffField.java b/src/infinity/resource/nwn/gff/field/GffField.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffField.java rename to src/infinity/resource/nwn/gff/field/GffField.java diff --git a/infinity/resource/nwn/gff/field/GffFloat.java b/src/infinity/resource/nwn/gff/field/GffFloat.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffFloat.java rename to src/infinity/resource/nwn/gff/field/GffFloat.java diff --git a/infinity/resource/nwn/gff/field/GffInt.java b/src/infinity/resource/nwn/gff/field/GffInt.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffInt.java rename to src/infinity/resource/nwn/gff/field/GffInt.java diff --git a/infinity/resource/nwn/gff/field/GffInt64.java b/src/infinity/resource/nwn/gff/field/GffInt64.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffInt64.java rename to src/infinity/resource/nwn/gff/field/GffInt64.java diff --git a/infinity/resource/nwn/gff/field/GffList.java b/src/infinity/resource/nwn/gff/field/GffList.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffList.java rename to src/infinity/resource/nwn/gff/field/GffList.java diff --git a/infinity/resource/nwn/gff/field/GffResRef.java b/src/infinity/resource/nwn/gff/field/GffResRef.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffResRef.java rename to src/infinity/resource/nwn/gff/field/GffResRef.java diff --git a/infinity/resource/nwn/gff/field/GffShort.java b/src/infinity/resource/nwn/gff/field/GffShort.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffShort.java rename to src/infinity/resource/nwn/gff/field/GffShort.java diff --git a/infinity/resource/nwn/gff/field/GffStruct.java b/src/infinity/resource/nwn/gff/field/GffStruct.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffStruct.java rename to src/infinity/resource/nwn/gff/field/GffStruct.java diff --git a/infinity/resource/nwn/gff/field/GffVoid.java b/src/infinity/resource/nwn/gff/field/GffVoid.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffVoid.java rename to src/infinity/resource/nwn/gff/field/GffVoid.java diff --git a/infinity/resource/nwn/gff/field/GffWord.java b/src/infinity/resource/nwn/gff/field/GffWord.java similarity index 100% rename from infinity/resource/nwn/gff/field/GffWord.java rename to src/infinity/resource/nwn/gff/field/GffWord.java diff --git a/infinity/resource/other/EffResource.java b/src/infinity/resource/other/EffResource.java similarity index 100% rename from infinity/resource/other/EffResource.java rename to src/infinity/resource/other/EffResource.java diff --git a/infinity/resource/other/PlainTextResource.java b/src/infinity/resource/other/PlainTextResource.java similarity index 100% rename from infinity/resource/other/PlainTextResource.java rename to src/infinity/resource/other/PlainTextResource.java diff --git a/infinity/resource/other/ProResource.java b/src/infinity/resource/other/ProResource.java similarity index 85% rename from infinity/resource/other/ProResource.java rename to src/infinity/resource/other/ProResource.java index bd5f13f..934f4c5 100644 --- a/infinity/resource/other/ProResource.java +++ b/src/infinity/resource/other/ProResource.java @@ -24,18 +24,18 @@ public final class ProResource extends AbstractStruct implements Resource // "Purple fireball", "Green dragon blast"}; private static final String[] s_areaflags = { "Trap not visible", "Trap visible", "Triggered by inanimates", "Triggered by condition", - "No overlapping effects", "Secondary projectile", "Fragments", "Not affecting allies", - "Not affecting enemies"}; + "Delayed trigger", "Secondary projectile", "Fragments", "Not affecting allies", + "Not affecting enemies", "Mage-level duration", "Cleric-level duration", "Draw animation", + "Cone-shaped", "Ignore visibility", "Delayed explosion", "Skip first condition", "Single target" + }; private static final String[] s_flags = { - "No flags set", "Colored BAM", "Creates smoke", "", "Not light source", "Modify for height", + "No flags set", "Colored BAM", "Creates smoke", "Colored smoke", "Not light source", "Modify for height", "Casts shadow", "Light spot enabled", "Translucent", "Mid-level brighten", "Blended" }; - private static final String[] s_behave = {"No flags set", "Show sparks", "3D traveling", - "Loop sound 1", "Loop sound 2", "Ignore center", + private static final String[] s_behave = {"No flags set", "Show sparks", "Use height", + "Loop fire sound", "Loop impact sound", "Ignore center", "Draw as background"}; - private static final String[] s_areatype = {"Round", "Mage level duration", "Cleric level duration", - "Draw animation", "Cone-shaped", "Non-clipped explosion", - "Delayed explosion", "Skip first condition", "Single target"}; + private static final String[] s_trail = {"No flags set", "Draw at target", "Draw at source"}; static { s_proj.put(0L, "Fireball"); @@ -74,8 +74,8 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset + 10, 2, "Speed")); list.add(new Flag(buffer, offset + 12, 4, "Behavior", s_behave)); // list.add(new Unknown(buffer, offset + 14, 2)); - list.add(new ResourceRef(buffer, offset + 16, "Sound 1", "WAV")); - list.add(new ResourceRef(buffer, offset + 24, "Sound 2", "WAV")); + list.add(new ResourceRef(buffer, offset + 16, "Fire sound", "WAV")); + list.add(new ResourceRef(buffer, offset + 24, "Impact sound", "WAV")); list.add(new ResourceRef(buffer, offset + 32, "Source animation", "BAM")); list.add(new Bitmap(buffer, offset + 40, 4, "Particle color", s_color)); list.add(new Unknown(buffer, offset + 44, 212)); @@ -113,20 +113,22 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset + 334, 2, "Tailing animation delay 1")); list.add(new DecNumber(buffer, offset + 336, 2, "Tailing animation delay 2")); list.add(new DecNumber(buffer, offset + 338, 2, "Tailing animation delay 3")); - list.add(new Unknown(buffer, offset + 340, 172)); + list.add(new Flag(buffer, offset + 340, 4, "Trail flags", s_trail)); + list.add(new Unknown(buffer, offset + 344, 168)); if (projtype.getValue() != 3) return offset + 512; // Area of effect - list.add(new Flag(buffer, offset + 512, 1, "Area of effect target", s_areaflags)); - list.add(new Flag(buffer, offset + 513, 1, "Area of effect type", s_areatype)); - list.add(new Unknown(buffer, offset + 514, 2)); + list.add(new Flag(buffer, offset + 512, 4, "Area flags", s_areaflags)); +// list.add(new Flag(buffer, offset + 513, 1, "Area of effect type", +// new String[]{"Round", "", "", "Secondary projectile", "", "", "Cone-shaped"})); +// list.add(new Unknown(buffer, offset + 514, 2)); list.add(new DecNumber(buffer, offset + 516, 2, "Trap size")); list.add(new DecNumber(buffer, offset + 518, 2, "Explosion size")); list.add(new ResourceRef(buffer, offset + 520, "Explosion sound", "WAV")); list.add(new DecNumber(buffer, offset + 528, 2, "Explosion frequency (frames)")); list.add(new IdsBitmap(buffer, offset + 530, 2, "Fragment animation", "ANIMATE.IDS")); list.add(new ProRef(buffer, offset + 532, "Secondary projectile")); - list.add(new DecNumber(buffer, offset + 534, 1, "Duration")); + list.add(new DecNumber(buffer, offset + 534, 1, "# repetitions")); list.add(new HashBitmap(buffer, offset + 535, 1, "Explosion effect", s_proj)); list.add(new ColorValue(buffer, offset + 536, 1, "Explosion color")); list.add(new Unknown(buffer, offset + 537, 1)); diff --git a/infinity/resource/other/UnknownResource.java b/src/infinity/resource/other/UnknownResource.java similarity index 100% rename from infinity/resource/other/UnknownResource.java rename to src/infinity/resource/other/UnknownResource.java diff --git a/infinity/resource/other/VvcResource.java b/src/infinity/resource/other/VvcResource.java similarity index 89% rename from infinity/resource/other/VvcResource.java rename to src/infinity/resource/other/VvcResource.java index 7d99ef9..b12906f 100644 --- a/infinity/resource/other/VvcResource.java +++ b/src/infinity/resource/other/VvcResource.java @@ -19,7 +19,7 @@ public final class VvcResource extends AbstractStruct implements Resource "Internal gamma", "Non-reserved palette", "Full palette", "", "Dream palette"}; private static final String s_seq[] = {"No flags set", "Looping", "Special lighting", "Modify for height", "Draw animation", "Custom palette", "Purgeable", "Not covered by wall", "Mid-level brighten", "High-level brighten"}; - private static final String s_face[] = {"Use current", "Orbit parent", "Parent orientation", "", "Ignore orientation"}; + private static final String s_face[] = {"Use current", "Face target", "Follow target", "Follow path", "Lock orientation"}; private static final String s_noyes[] = {"No", "Yes"}; public VvcResource(ResourceEntry entry) throws Exception @@ -48,11 +48,11 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new ResourceRef(buffer, offset + 68, "Palette", "BMP")); // list.add(new Unknown(buffer, offset + 72, 4)); list.add(new DecNumber(buffer, offset + 76, 4, "Position: Z")); - list.add(new DecNumber(buffer, offset + 80, 4, "Center point: X")); - list.add(new DecNumber(buffer, offset + 84, 4, "Center point: Y")); + list.add(new DecNumber(buffer, offset + 80, 4, "Light spot width")); + list.add(new DecNumber(buffer, offset + 84, 4, "Light spot height")); list.add(new DecNumber(buffer, offset + 88, 4, "Light spot brightness")); list.add(new DecNumber(buffer, offset + 92, 4, "Duration (frames)")); - list.add(new Unknown(buffer, offset + 96, 8)); + list.add(new ResourceRef(buffer, offset + 96, "Resource", "VVC")); // list.add(new Unknown(buffer, offset + 100, 4)); list.add(new DecNumber(buffer, offset + 104, 4, "First animation number")); list.add(new DecNumber(buffer, offset + 108, 4, "Second animation number")); @@ -60,8 +60,8 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new Bitmap(buffer, offset + 116, 4, "Continuous playback", s_noyes)); list.add(new ResourceRef(buffer, offset + 120, "Starting sound", "WAV")); list.add(new ResourceRef(buffer, offset + 128, "Duration sound", "WAV")); - list.add(new Unknown(buffer, offset + 136, 8)); -// list.add(new Unknown(buffer, offset + 140, 4)); + list.add(new ResourceRef(buffer, offset + 136, "Alpha mask", "BAM")); +// list.add(new Unknown(buffer, offset + 136, 4)); list.add(new DecNumber(buffer, offset + 144, 4, "Third animation number")); list.add(new ResourceRef(buffer, offset + 148, "Ending sound", "WAV")); list.add(new Unknown(buffer, offset + 156, 336)); diff --git a/infinity/resource/other/WfxResource.java b/src/infinity/resource/other/WfxResource.java similarity index 100% rename from infinity/resource/other/WfxResource.java rename to src/infinity/resource/other/WfxResource.java diff --git a/infinity/resource/sav/IOHandler.java b/src/infinity/resource/sav/IOHandler.java similarity index 100% rename from infinity/resource/sav/IOHandler.java rename to src/infinity/resource/sav/IOHandler.java diff --git a/infinity/resource/sav/SavResource.java b/src/infinity/resource/sav/SavResource.java similarity index 100% rename from infinity/resource/sav/SavResource.java rename to src/infinity/resource/sav/SavResource.java diff --git a/infinity/resource/sound/AcmResource.java b/src/infinity/resource/sound/AcmResource.java similarity index 100% rename from infinity/resource/sound/AcmResource.java rename to src/infinity/resource/sound/AcmResource.java diff --git a/src/infinity/resource/sound/AudioConverter.java b/src/infinity/resource/sound/AudioConverter.java new file mode 100644 index 0000000..e8308ef --- /dev/null +++ b/src/infinity/resource/sound/AudioConverter.java @@ -0,0 +1,103 @@ + +package infinity.resource.sound; + +import infinity.gui.BrowserMenuBar; +import infinity.resource.ResourceFactory; +import infinity.util.StreamDiscarder; + +import java.io.File; +import java.io.IOException; + +/** + * @author Fredrik Lindgren + * @since 2012-08-20 + */ +public class AudioConverter +{ + public static final String ACM2WAV = "acm2wav.exe"; + public static final String ACMTOOL = "acmtool"; + private File acm2wav; + private String decoder; + + private static final StreamDiscarder outReader = new StreamDiscarder(); + private static final StreamDiscarder errReader = new StreamDiscarder(); + private static final Thread outThread = new Thread(outReader); + private static final Thread errThread = new Thread(errReader); + + /** + * Retrieves the selected converter from the gui and binds it to an instance variable + * + * If the converter is acm2wav, the existence of the file acm2wav.exe is tested for in the root game directory and in the + * current working directory. If the file exists it is bound to the decoder instance variable. If the converter is acmtool, + * that is bound to the decoder variable instead. + */ + public AudioConverter() + { + String d = BrowserMenuBar.getInstance().getAudioDecoder(); + if (d.equalsIgnoreCase(ACM2WAV)) { + if (acm2wav == null || !acm2wav.exists()) + acm2wav = new File(ResourceFactory.getRootDir(), ACM2WAV); + if (!acm2wav.exists()) + acm2wav = new File(ACM2WAV); + if (acm2wav.exists()) + decoder = ACM2WAV; + } + else if (d.equalsIgnoreCase(ACMTOOL)) { + decoder = ACMTOOL; + } + } + + /** + * Invokes the external audio converter + * + * @param acmfile the acm file to be converted + * @param wavfile the output file of the conversion + * @param isMono whether the converter should force mono sound + * @throws IOException if an I/O error occurs + * @return void + */ + public void convert(File acmfile, File wavfile, boolean isMono) throws IOException + { + try { + Process p; + Runtime rt = Runtime.getRuntime(); + if (decoder.equalsIgnoreCase(ACM2WAV)) { + if (isMono) + p = rt.exec("\"" + acm2wav.getAbsolutePath() + "\" \"" + acmfile.getPath() + "\" -m", null, + wavfile.getAbsoluteFile().getParentFile()); + else + p = rt.exec("\"" + acm2wav.getAbsolutePath() + "\" \"" + acmfile.getPath() + "\"", null, + wavfile.getAbsoluteFile().getParentFile()); + } + else if (decoder.equalsIgnoreCase(ACMTOOL)) { + if (isMono) + //acmtool -d -m -o outfile infile + p = rt.exec("acmtool -d -m" + " -o " + wavfile.getPath() + " " + acmfile.getPath()); + else + //atmtool -d -o outfile infile + p = rt.exec("acmtool -d" + " -o " + wavfile.getPath() + " " + acmfile.getPath()); + } + else + return; + outReader.setStream(p.getInputStream()); + errReader.setStream(p.getErrorStream()); + outThread.run(); + errThread.run(); + p.waitFor(); + } catch (InterruptedException e) {} + } + + /** + * Tests whether a converter is available + * + * @return true if the converter is acm2wav and the file acm2wav.exe exists; true if the converter is acmtool; otherwise false + */ + public boolean converterExists() + { + if (decoder == null) + return false; + if (decoder.equalsIgnoreCase(ACM2WAV)) + return acm2wav.exists(); + return true; + } +} diff --git a/infinity/resource/sound/SoundUtilities.java b/src/infinity/resource/sound/SoundUtilities.java similarity index 92% rename from infinity/resource/sound/SoundUtilities.java rename to src/infinity/resource/sound/SoundUtilities.java index 6fc500d..140e77b 100644 --- a/infinity/resource/sound/SoundUtilities.java +++ b/src/infinity/resource/sound/SoundUtilities.java @@ -5,6 +5,7 @@ package infinity.resource.sound; import infinity.resource.ResourceFactory; +import infinity.resource.sound.AudioConverter; import infinity.util.Byteconvert; import infinity.util.Filewriter; @@ -14,7 +15,6 @@ public final class SoundUtilities { private static final AdpcmFmt fmt = new AdpcmFmt(); - private static File acm2wav; private static final byte myData[] = new byte[8196]; // old value: 32769 private static final int stepTable[] = { 7, 8, 9, 10, 11, 12, 13, 14, @@ -33,24 +33,15 @@ public final class SoundUtilities private AudioFormat audioFormat; private SourceDataLine dataLine; private boolean notstop = true, stopped = true; + private static AudioConverter converter; public static File convert(File acmfile, boolean isMono) throws IOException { - File wavfile = new File(acmfile.getName().substring(0, acmfile.getName().lastIndexOf((int)'.')) + ".WAV"); + File wavfile = new File(acmfile.getAbsoluteFile().getParent() ,acmfile.getName().substring(0, acmfile.getName().lastIndexOf((int)'.')) + ".WAV"); if (!wavfile.exists()) { - if (acm2wav == null || !acm2wav.exists()) - acm2wav = new File(ResourceFactory.getRootDir(), "acm2wav.exe"); - if (!acm2wav.exists()) - acm2wav = new File("acm2wav.exe"); - if (!acm2wav.exists()) - throw new IOException("acm2wav.exe not found"); - try { - if (isMono) - Runtime.getRuntime().exec('\"' + acm2wav.getAbsolutePath() + "\" \"" + acmfile + "\" -m").waitFor(); - else - Runtime.getRuntime().exec('\"' + acm2wav.getAbsolutePath() + "\" \"" + acmfile + '\"').waitFor(); - } catch (InterruptedException e) { - } + if (converter == null || !converter.converterExists()) + converter = new AudioConverter(); + converter.convert(acmfile, wavfile, isMono); } return wavfile; } @@ -69,6 +60,13 @@ public static File convert(byte data[], int offset, String filename, boolean isM return wavfile; } + public static boolean converterExists() + { + if (converter == null || !converter.converterExists()) + converter = new AudioConverter(); + return converter.converterExists(); + } + public static File convertADPCM(byte data[], int offset, String filename) throws IOException { File pcmwav = new File(filename); diff --git a/infinity/resource/sound/WavResource.java b/src/infinity/resource/sound/WavResource.java similarity index 88% rename from infinity/resource/sound/WavResource.java rename to src/infinity/resource/sound/WavResource.java index 7fb8e51..4b88985 100644 --- a/infinity/resource/sound/WavResource.java +++ b/src/infinity/resource/sound/WavResource.java @@ -130,24 +130,8 @@ else if (event.getSource() == bexportConvert) { chooser.setSelectedFile(new File(entry.toString())); if (chooser.showDialog(panel, "Export") == JFileChooser.APPROVE_OPTION) { String filename = chooser.getSelectedFile().toString(); - File acmfile = new File(filename.substring(0, filename.lastIndexOf('.')) + ".ACM"); try { - BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(acmfile)); - byte data[] = entry.getResourceData(); - bos.write(data, 28, data.length - 28); - bos.close(); - File acm2wav = new File(ResourceFactory.getRootDir(), "acm2wav.exe"); - if (!acm2wav.exists()) - acm2wav = new File("acm2wav.exe"); - if (!acm2wav.exists()) - return; - if (channels == 1) - Runtime.getRuntime().exec('\"' + acm2wav.getAbsolutePath() + "\" \"" + acmfile + "\" -m", null, - chooser.getSelectedFile().getParentFile()).waitFor(); - else - Runtime.getRuntime().exec('\"' + acm2wav.getAbsolutePath() + "\" \"" + acmfile + '\"', null, - chooser.getSelectedFile().getParentFile()).waitFor(); - acmfile.delete(); + SoundUtilities.convert(entry.getResourceData(), 28, filename, channels == 1); } catch (Exception e) { JOptionPane.showMessageDialog(panel, "Error during conversion", "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); @@ -260,12 +244,11 @@ public JComponent makeViewer(ViewableContainer container) if (signature.equalsIgnoreCase("WAVC")) { bexportConvert = new JButton("Export & Convert...", Icons.getIcon("Export16.gif")); bexportConvert.addActionListener(this); - if (new File(ResourceFactory.getRootDir(), "acm2wav.exe").exists() || - new File("acm2wav.exe").exists()) + if (SoundUtilities.converterExists()) ; else { bexportConvert.setSelected(false); - bexportConvert.setToolTipText("acm2wav.exe not found"); + bexportConvert.setToolTipText("Sound converter not found"); } lowerpanel.add(bexportConvert); } diff --git a/infinity/resource/spl/Ability.java b/src/infinity/resource/spl/Ability.java similarity index 97% rename from infinity/resource/spl/Ability.java rename to src/infinity/resource/spl/Ability.java index 02307a6..247c7ad 100644 --- a/infinity/resource/spl/Ability.java +++ b/src/infinity/resource/spl/Ability.java @@ -45,11 +45,11 @@ public JComponent getDetailViewer() protected int read(byte buffer[], int offset) throws Exception { + if (ResourceFactory.getGameID() == ResourceFactory.ID_TORMENT) { list.add(new Bitmap(buffer, offset, 1, "Type", s_type)); - if (ResourceFactory.getGameID() == ResourceFactory.ID_TORMENT) list.add(new Bitmap(buffer, offset + 1, 1, "Hostility", s_hostility)); - else - list.add(new Unknown(buffer, offset + 1, 1)); + } else + list.add(new Bitmap(buffer, offset, 2, "Type", s_type)); list.add(new Bitmap(buffer, offset + 2, 2, "Ability location", s_abilityuse)); list.add(new ResourceRef(buffer, offset + 4, "Icon", "BAM")); list.add(new Bitmap(buffer, offset + 12, 1, "Target", s_targettype)); diff --git a/infinity/resource/spl/SplResource.java b/src/infinity/resource/spl/SplResource.java similarity index 86% rename from infinity/resource/spl/SplResource.java rename to src/infinity/resource/spl/SplResource.java index a236a4b..1623812 100644 --- a/infinity/resource/spl/SplResource.java +++ b/src/infinity/resource/spl/SplResource.java @@ -22,7 +22,7 @@ public final class SplResource extends AbstractStruct implements Resource, HasAd public static final String[] s_school = {"None", "Abjurer", "Conjurer", "Diviner", "Enchanter", "Illusionist", "Invoker", "Necromancer", "Transmuter", "Generalist"}; // private static final LongIntegerHashMap m_wizardtype = new LongIntegerHashMap(); - private static final LongIntegerHashMap m_priesttype = new LongIntegerHashMap(); +// private static final LongIntegerHashMap m_priesttype = new LongIntegerHashMap(); private static final String[] s_spelltype = {"Special", "Wizard", "Priest", "Psionic", "Innate", "Bard song"}; private static final String[] s_anim = {"None", "Fire aqua", "Fire blue", "Fire gold", "Fire green", "Fire magenta", "Fire purple", "Fire red", "Fire white", @@ -36,13 +36,17 @@ public final class SplResource extends AbstractStruct implements Resource, HasAd "Swirl white"}; private static final String[] s_spellflag = {"No flags set", "", "", "", "", "", "", "", "", "", "", "Hostile", - "No LOS required", "", "Outdoors only", - "Non-magical ability", "Trigger/Contingency"}; - private static final String[] s_exclude = { "None", "Chaotic priest", "Evil priest", "Good priest", - "... Neutral priest", "Lawful priest", "Neutral ... priest", + "No LOS required", "Allow spotting", "Outdoors only", + "Non-magical ability", "Trigger/Contingency", + "Non-combat ability", "", "", "", "", "", "", "", + "Ex: can target invisible", "Ex: castable when silenced"}; + private static final String[] s_exclude = { "None", "Chaotic", "Evil", "Good", + "... Neutral", "Lawful", "Neutral ...", "Abjurer", "Conjurer", "Diviner", "Enchanter", "Illusionist", "Invoker", "Necromancer", "Transmuter", - "Generalist"}; + "Generalist", "", "", "", "", "", "", "", "", "Elf", + "Dwarf", "Half-elf", "Halfling", "Human", "Gnome", "", + "Cleric", "Druid"}; static { @@ -56,9 +60,9 @@ public final class SplResource extends AbstractStruct implements Resource, HasAd // m_wizardtype.put((long)0x2000, "Abjuration"); // m_wizardtype.put((long)0x2400, "Necromancy"); - m_priesttype.put((long)0x0000, "All priests"); - m_priesttype.put((long)0x4000, "Druid/Ranger"); - m_priesttype.put((long)0x8000, "Cleric/Paladin"); +// m_priesttype.put((long)0x0000, "All priests"); +// m_priesttype.put((long)0x4000, "Druid/Ranger"); +// m_priesttype.put((long)0x8000, "Cleric/Paladin"); } public static String getSearchString(byte buffer[]) @@ -189,26 +193,27 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new ResourceRef(buffer, offset + 16, "Casting sound", "WAV")); list.add(new Flag(buffer, offset + 24, 4, "Flags", s_spellflag)); list.add(new Bitmap(buffer, offset + 28, 2, "Spell type", s_spelltype)); - list.add(new Flag(buffer, offset + 30, 2, "Exclusion flags", s_exclude)); // 0x1e - list.add(new HashBitmap(buffer, offset + 32, 2, "Priest type", m_priesttype)); // 0x20 + list.add(new Flag(buffer, offset + 30, 4, "Exclusion flags", s_exclude)); // 0x1e +// list.add(new HashBitmap(buffer, offset + 32, 2, "Priest type", m_priesttype)); // 0x20 list.add(new Bitmap(buffer, offset + 34, 2, "Casting animation", s_anim)); // 0x22 list.add(new Unknown(buffer, offset + 36, 1)); // 0x23 if (ResourceFactory.getInstance().resourceExists("SCHOOL.IDS")) - list.add(new IdsBitmap(buffer, offset + 37, 2, "Primary type (school)", "SCHOOL.IDS")); // 0x25 + list.add(new IdsBitmap(buffer, offset + 37, 1, "Primary type (school)", "SCHOOL.IDS")); // 0x25 else - list.add(new Bitmap(buffer, offset + 37, 2, "Primary type (school)", s_school)); // 0x25 + list.add(new Bitmap(buffer, offset + 37, 1, "Primary type (school)", s_school)); // 0x25 + list.add(new Unknown(buffer, offset + 38, 1)); list.add(new Bitmap(buffer, offset + 39, 1, "Secondary type", s_category)); // 0x27 list.add(new Unknown(buffer, offset + 40, 12)); list.add(new DecNumber(buffer, offset + 52, 4, "Spell level")); list.add(new Unknown(buffer, offset + 56, 2)); list.add(new ResourceRef(buffer, offset + 58, "Spell icon", "BAM")); - list.add(new Unknown(buffer, offset + 66, 14)); -// list.add(new TextString(buffer, offset + 68, 8, "ResRef?")); -// list.add(new Unknown(buffer, offset + 76, 4)); + list.add(new Unknown(buffer, offset + 66, 2)); + list.add(new ResourceRef(buffer, offset + 68, "Ground icon", "BAM")); + list.add(new Unknown(buffer, offset + 76, 4)); list.add(new StringRef(buffer, offset + 80, "Spell description")); list.add(new StringRef(buffer, offset + 84, "Identified description")); -// list.add(new ResourceRef(buffer, offset + 88, 8, "Animation?", "BAM")); - list.add(new Unknown(buffer, offset + 88, 12)); + list.add(new ResourceRef(buffer, offset + 88, "Description image", "BAM")); + list.add(new Unknown(buffer, offset + 96, 4)); SectionOffset abil_offset = new SectionOffset(buffer, offset + 100, "Abilities offset", Ability.class); list.add(abil_offset); diff --git a/infinity/resource/spl/Viewer.java b/src/infinity/resource/spl/Viewer.java similarity index 95% rename from infinity/resource/spl/Viewer.java rename to src/infinity/resource/spl/Viewer.java index aa83574..850aba6 100644 --- a/infinity/resource/spl/Viewer.java +++ b/src/infinity/resource/spl/Viewer.java @@ -23,7 +23,7 @@ private static JPanel makeFieldPanel(SplResource spl) ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Spell name"), gbl, gbc, true); ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Spell type"), gbl, gbc, true); // ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Wizard school"), gbl, gbc, true); - ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Priest type"), gbl, gbc, true); +// ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Priest type"), gbl, gbc, true); ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Casting animation"), gbl, gbc, true); ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Primary type (school)"), gbl, gbc, true); ViewerUtil.addLabelFieldPair(fieldPanel, spl.getAttribute("Secondary type"), gbl, gbc, true); diff --git a/infinity/resource/spl/ViewerAbility.java b/src/infinity/resource/spl/ViewerAbility.java similarity index 100% rename from infinity/resource/spl/ViewerAbility.java rename to src/infinity/resource/spl/ViewerAbility.java diff --git a/infinity/resource/src/Entry.java b/src/infinity/resource/src/Entry.java similarity index 100% rename from infinity/resource/src/Entry.java rename to src/infinity/resource/src/Entry.java diff --git a/infinity/resource/src/SrcResource.java b/src/infinity/resource/src/SrcResource.java similarity index 100% rename from infinity/resource/src/SrcResource.java rename to src/infinity/resource/src/SrcResource.java diff --git a/infinity/resource/sto/Cure.java b/src/infinity/resource/sto/Cure.java similarity index 100% rename from infinity/resource/sto/Cure.java rename to src/infinity/resource/sto/Cure.java diff --git a/infinity/resource/sto/Drink.java b/src/infinity/resource/sto/Drink.java similarity index 100% rename from infinity/resource/sto/Drink.java rename to src/infinity/resource/sto/Drink.java diff --git a/infinity/resource/sto/ItemSale.java b/src/infinity/resource/sto/ItemSale.java similarity index 100% rename from infinity/resource/sto/ItemSale.java rename to src/infinity/resource/sto/ItemSale.java diff --git a/infinity/resource/sto/ItemSale11.java b/src/infinity/resource/sto/ItemSale11.java similarity index 100% rename from infinity/resource/sto/ItemSale11.java rename to src/infinity/resource/sto/ItemSale11.java diff --git a/infinity/resource/sto/Purchases.java b/src/infinity/resource/sto/Purchases.java similarity index 100% rename from infinity/resource/sto/Purchases.java rename to src/infinity/resource/sto/Purchases.java diff --git a/infinity/resource/sto/StoResource.java b/src/infinity/resource/sto/StoResource.java similarity index 98% rename from infinity/resource/sto/StoResource.java rename to src/infinity/resource/sto/StoResource.java index d7c2256..3110565 100644 --- a/infinity/resource/sto/StoResource.java +++ b/src/infinity/resource/sto/StoResource.java @@ -21,7 +21,7 @@ public final class StoResource extends AbstractStruct implements Resource, HasAd private static final String[] s_flag_bg2 = {"Can only rest", "Can buy", "Can sell", "Can identify", "Can steal", "Can donate", "Can buy cures", "Can buy drinks", "", "", "Tavern quality 1", "Tavern quality 2", - "", "Fence"}; + "", "Fence", "", "Ex: toggle recharge"}; private static final String[] s_rooms = {"No rooms available", "Peasant", "Merchant", "Noble", "Royal"}; public static String getSearchString(byte buffer[]) @@ -84,6 +84,7 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset + 20, 4, "Sell markup")); list.add(new DecNumber(buffer, offset + 24, 4, "Buy markup")); list.add(new DecNumber(buffer, offset + 28, 4, "Depreciation rate")); +// list.add(new Unknown(buffer, offset + 30, 2)); list.add(new DecNumber(buffer, offset + 32, 2, "Stealing difficulty")); if (version.toString().equalsIgnoreCase("V9.0")) list.add(new Unknown(buffer, offset + 34, 2)); diff --git a/infinity/resource/sto/Viewer.java b/src/infinity/resource/sto/Viewer.java similarity index 100% rename from infinity/resource/sto/Viewer.java rename to src/infinity/resource/sto/Viewer.java diff --git a/infinity/resource/var/Entry.java b/src/infinity/resource/var/Entry.java similarity index 100% rename from infinity/resource/var/Entry.java rename to src/infinity/resource/var/Entry.java diff --git a/infinity/resource/var/VarResource.java b/src/infinity/resource/var/VarResource.java similarity index 100% rename from infinity/resource/var/VarResource.java rename to src/infinity/resource/var/VarResource.java diff --git a/infinity/resource/vertex/ClosedVertex.java b/src/infinity/resource/vertex/ClosedVertex.java similarity index 100% rename from infinity/resource/vertex/ClosedVertex.java rename to src/infinity/resource/vertex/ClosedVertex.java diff --git a/infinity/resource/vertex/ClosedVertexImpeded.java b/src/infinity/resource/vertex/ClosedVertexImpeded.java similarity index 100% rename from infinity/resource/vertex/ClosedVertexImpeded.java rename to src/infinity/resource/vertex/ClosedVertexImpeded.java diff --git a/infinity/resource/vertex/OpenVertex.java b/src/infinity/resource/vertex/OpenVertex.java similarity index 100% rename from infinity/resource/vertex/OpenVertex.java rename to src/infinity/resource/vertex/OpenVertex.java diff --git a/infinity/resource/vertex/OpenVertexImpeded.java b/src/infinity/resource/vertex/OpenVertexImpeded.java similarity index 100% rename from infinity/resource/vertex/OpenVertexImpeded.java rename to src/infinity/resource/vertex/OpenVertexImpeded.java diff --git a/infinity/resource/vertex/Vertex.java b/src/infinity/resource/vertex/Vertex.java similarity index 100% rename from infinity/resource/vertex/Vertex.java rename to src/infinity/resource/vertex/Vertex.java diff --git a/infinity/resource/wed/ClosedPolygon.java b/src/infinity/resource/wed/ClosedPolygon.java similarity index 100% rename from infinity/resource/wed/ClosedPolygon.java rename to src/infinity/resource/wed/ClosedPolygon.java diff --git a/infinity/resource/wed/Door.java b/src/infinity/resource/wed/Door.java similarity index 97% rename from infinity/resource/wed/Door.java rename to src/infinity/resource/wed/Door.java index fe672dc..f493b5b 100644 --- a/infinity/resource/wed/Door.java +++ b/src/infinity/resource/wed/Door.java @@ -9,6 +9,8 @@ final class Door extends AbstractStruct implements AddRemovable, HasAddRemovable { + private static final String[] s_yesno = {"No", "Yes"}; + Door() throws Exception { super(null, "Door", new byte[26], 0); @@ -75,7 +77,7 @@ public void updatePolygonsOffset(int offset) protected int read(byte buffer[], int offset) throws Exception { list.add(new TextString(buffer, offset, 8, "Name")); - list.add(new Unknown(buffer, offset + 8, 2)); + list.add(new Bitmap(buffer, offset + 8, 2, "Is door?", s_yesno)); DecNumber indexTileCell = new DecNumber(buffer, offset + 10, 2, "Tilemap lookup index"); list.add(indexTileCell); SectionCount countTileCell = new SectionCount(buffer, offset + 12, 2, "# tilemap indexes", diff --git a/infinity/resource/wed/OpenPolygon.java b/src/infinity/resource/wed/OpenPolygon.java similarity index 100% rename from infinity/resource/wed/OpenPolygon.java rename to src/infinity/resource/wed/OpenPolygon.java diff --git a/infinity/resource/wed/Overlay.java b/src/infinity/resource/wed/Overlay.java similarity index 100% rename from infinity/resource/wed/Overlay.java rename to src/infinity/resource/wed/Overlay.java diff --git a/infinity/resource/wed/Polygon.java b/src/infinity/resource/wed/Polygon.java similarity index 97% rename from infinity/resource/wed/Polygon.java rename to src/infinity/resource/wed/Polygon.java index 88a5e58..e9b1e49 100644 --- a/infinity/resource/wed/Polygon.java +++ b/src/infinity/resource/wed/Polygon.java @@ -67,7 +67,7 @@ protected int read(byte buffer[], int offset) throws Exception { list.add(new DecNumber(buffer, offset, 4, "Vertex index")); list.add(new SectionCount(buffer, offset + 4, 4, "# vertices", Vertex.class)); - list.add(new Unknown(buffer, offset + 8, 2, "Hole flags")); + list.add(new Unknown(buffer, offset + 8, 2)); // list.add(new Unknown(buffer, offset + 9, 1)); list.add(new DecNumber(buffer, offset + 10, 2, "Minimum coordinate: X")); list.add(new DecNumber(buffer, offset + 12, 2, "Maximum coordinate: X")); diff --git a/infinity/resource/wed/Tilemap.java b/src/infinity/resource/wed/Tilemap.java similarity index 94% rename from infinity/resource/wed/Tilemap.java rename to src/infinity/resource/wed/Tilemap.java index 9ec7dc4..863f173 100644 --- a/infinity/resource/wed/Tilemap.java +++ b/src/infinity/resource/wed/Tilemap.java @@ -32,7 +32,7 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new DecNumber(buffer, offset, 2, "Primary tile index")); list.add(new DecNumber(buffer, offset + 2, 2, "Primary tile count")); list.add(new DecNumber(buffer, offset + 4, 2, "Secondary tile index")); - list.add(new Unknown(buffer, offset + 6, 4, "Overlays drawn")); + list.add(new Unknown(buffer, offset + 6, 4)); // list.add(new Unknown(buffer, offset + 7, 3)); return offset + 10; } diff --git a/infinity/resource/wed/WallPolygon.java b/src/infinity/resource/wed/WallPolygon.java similarity index 100% rename from infinity/resource/wed/WallPolygon.java rename to src/infinity/resource/wed/WallPolygon.java diff --git a/infinity/resource/wed/Wallgroup.java b/src/infinity/resource/wed/Wallgroup.java similarity index 100% rename from infinity/resource/wed/Wallgroup.java rename to src/infinity/resource/wed/Wallgroup.java diff --git a/infinity/resource/wed/WedResource.java b/src/infinity/resource/wed/WedResource.java similarity index 100% rename from infinity/resource/wed/WedResource.java rename to src/infinity/resource/wed/WedResource.java diff --git a/infinity/resource/wmp/AreaEntry.java b/src/infinity/resource/wmp/AreaEntry.java similarity index 96% rename from infinity/resource/wmp/AreaEntry.java rename to src/infinity/resource/wmp/AreaEntry.java index eb54b29..c86c935 100644 --- a/infinity/resource/wmp/AreaEntry.java +++ b/src/infinity/resource/wmp/AreaEntry.java @@ -41,8 +41,8 @@ public JComponent getDetailViewer() protected int read(byte buffer[], int offset) throws Exception { - list.add(new ResourceRef(buffer, offset, "Area content", "ARE")); - list.add(new TextString(buffer, offset + 8, 8, "Area name")); + list.add(new ResourceRef(buffer, offset, "Current area", "ARE")); + list.add(new ResourceRef(buffer, offset + 8, "Original area", "ARE")); list.add(new TextString(buffer, offset + 16, 32, "Script name")); list.add(new Flag(buffer, offset + 48, 4, "Flags", s_flag)); list.add(new DecNumber(buffer, offset + 52, 4, "Icon number")); diff --git a/infinity/resource/wmp/AreaLink.java b/src/infinity/resource/wmp/AreaLink.java similarity index 100% rename from infinity/resource/wmp/AreaLink.java rename to src/infinity/resource/wmp/AreaLink.java diff --git a/infinity/resource/wmp/AreaLinkEast.java b/src/infinity/resource/wmp/AreaLinkEast.java similarity index 100% rename from infinity/resource/wmp/AreaLinkEast.java rename to src/infinity/resource/wmp/AreaLinkEast.java diff --git a/infinity/resource/wmp/AreaLinkNorth.java b/src/infinity/resource/wmp/AreaLinkNorth.java similarity index 100% rename from infinity/resource/wmp/AreaLinkNorth.java rename to src/infinity/resource/wmp/AreaLinkNorth.java diff --git a/infinity/resource/wmp/AreaLinkSouth.java b/src/infinity/resource/wmp/AreaLinkSouth.java similarity index 100% rename from infinity/resource/wmp/AreaLinkSouth.java rename to src/infinity/resource/wmp/AreaLinkSouth.java diff --git a/infinity/resource/wmp/AreaLinkWest.java b/src/infinity/resource/wmp/AreaLinkWest.java similarity index 100% rename from infinity/resource/wmp/AreaLinkWest.java rename to src/infinity/resource/wmp/AreaLinkWest.java diff --git a/infinity/resource/wmp/MapEntry.java b/src/infinity/resource/wmp/MapEntry.java similarity index 92% rename from infinity/resource/wmp/MapEntry.java rename to src/infinity/resource/wmp/MapEntry.java index 53ecff1..0a738ca 100644 --- a/infinity/resource/wmp/MapEntry.java +++ b/src/infinity/resource/wmp/MapEntry.java @@ -40,10 +40,10 @@ protected int read(byte buffer[], int offset) throws Exception list.add(new ResourceRef(buffer, offset, "Map", "MOS")); list.add(new DecNumber(buffer, offset + 8, 4, "Width")); list.add(new DecNumber(buffer, offset + 12, 4, "Height")); - list.add(new Unknown(buffer, offset + 16, 4)); + list.add(new DecNumber(buffer, offset + 16, 4, "Map ID")); list.add(new StringRef(buffer, offset + 20, "Name")); - list.add(new Unknown(buffer, offset + 24, 4)); - list.add(new Unknown(buffer, offset + 28, 4)); + list.add(new DecNumber(buffer, offset + 24, 4, "Center location: X")); + list.add(new DecNumber(buffer, offset + 28, 4, "Center location: Y")); SectionCount area_count = new SectionCount(buffer, offset + 32, 4, "# areas", AreaEntry.class); list.add(area_count); diff --git a/infinity/resource/wmp/ViewerArea.java b/src/infinity/resource/wmp/ViewerArea.java similarity index 99% rename from infinity/resource/wmp/ViewerArea.java rename to src/infinity/resource/wmp/ViewerArea.java index e5e11c0..2cdbce2 100644 --- a/infinity/resource/wmp/ViewerArea.java +++ b/src/infinity/resource/wmp/ViewerArea.java @@ -27,7 +27,7 @@ private static JPanel makeInfoPanel(AreaEntry areaEntry) JPanel panel = new JPanel(gbl); gbc.insets = new Insets(3, 3, 3, 3); ViewerUtil.addLabelFieldPair(panel, areaEntry.getAttribute("Name"), gbl, gbc, true); - ViewerUtil.addLabelFieldPair(panel, areaEntry.getAttribute("Area content"), gbl, gbc, true); + ViewerUtil.addLabelFieldPair(panel, areaEntry.getAttribute("Current area"), gbl, gbc, true); ViewerUtil.addLabelFieldPair(panel, areaEntry.getAttribute("Loading image"), gbl, gbc, true); return panel; } diff --git a/infinity/resource/wmp/ViewerMap.java b/src/infinity/resource/wmp/ViewerMap.java similarity index 100% rename from infinity/resource/wmp/ViewerMap.java rename to src/infinity/resource/wmp/ViewerMap.java diff --git a/infinity/resource/wmp/WmpResource.java b/src/infinity/resource/wmp/WmpResource.java similarity index 100% rename from infinity/resource/wmp/WmpResource.java rename to src/infinity/resource/wmp/WmpResource.java diff --git a/infinity/search/AbstractReferenceSearcher.java b/src/infinity/search/AbstractReferenceSearcher.java similarity index 100% rename from infinity/search/AbstractReferenceSearcher.java rename to src/infinity/search/AbstractReferenceSearcher.java diff --git a/infinity/search/AttributeSearcher.java b/src/infinity/search/AttributeSearcher.java similarity index 100% rename from infinity/search/AttributeSearcher.java rename to src/infinity/search/AttributeSearcher.java diff --git a/infinity/search/DialogSearcher.java b/src/infinity/search/DialogSearcher.java similarity index 100% rename from infinity/search/DialogSearcher.java rename to src/infinity/search/DialogSearcher.java diff --git a/infinity/search/DialogStateReferenceSearcher.java b/src/infinity/search/DialogStateReferenceSearcher.java similarity index 100% rename from infinity/search/DialogStateReferenceSearcher.java rename to src/infinity/search/DialogStateReferenceSearcher.java diff --git a/infinity/search/ReferenceHitFrame.java b/src/infinity/search/ReferenceHitFrame.java similarity index 100% rename from infinity/search/ReferenceHitFrame.java rename to src/infinity/search/ReferenceHitFrame.java diff --git a/infinity/search/ReferenceSearcher.java b/src/infinity/search/ReferenceSearcher.java similarity index 100% rename from infinity/search/ReferenceSearcher.java rename to src/infinity/search/ReferenceSearcher.java diff --git a/infinity/search/ScriptReferenceSearcher.java b/src/infinity/search/ScriptReferenceSearcher.java similarity index 100% rename from infinity/search/ScriptReferenceSearcher.java rename to src/infinity/search/ScriptReferenceSearcher.java diff --git a/infinity/search/SearchClient.java b/src/infinity/search/SearchClient.java similarity index 100% rename from infinity/search/SearchClient.java rename to src/infinity/search/SearchClient.java diff --git a/infinity/search/SearchFrame.java b/src/infinity/search/SearchFrame.java similarity index 99% rename from infinity/search/SearchFrame.java rename to src/infinity/search/SearchFrame.java index 54ca6b3..a442b70 100644 --- a/infinity/search/SearchFrame.java +++ b/src/infinity/search/SearchFrame.java @@ -179,7 +179,7 @@ public void windowOpened(WindowEvent event) gbl.setConstraints(bpanel, gbc); pane.add(bpanel); - setSize(450, 450); + setSize(500, 450); Center.center(this, NearInfinity.getInstance().getBounds()); } diff --git a/infinity/search/SearchMaster.java b/src/infinity/search/SearchMaster.java similarity index 100% rename from infinity/search/SearchMaster.java rename to src/infinity/search/SearchMaster.java diff --git a/infinity/search/StringReferenceSearcher.java b/src/infinity/search/StringReferenceSearcher.java similarity index 100% rename from infinity/search/StringReferenceSearcher.java rename to src/infinity/search/StringReferenceSearcher.java diff --git a/infinity/search/TextHitFrame.java b/src/infinity/search/TextHitFrame.java similarity index 100% rename from infinity/search/TextHitFrame.java rename to src/infinity/search/TextHitFrame.java diff --git a/infinity/search/TextResourceSearcher.java b/src/infinity/search/TextResourceSearcher.java similarity index 100% rename from infinity/search/TextResourceSearcher.java rename to src/infinity/search/TextResourceSearcher.java diff --git a/infinity/search/WavReferenceSearcher.java b/src/infinity/search/WavReferenceSearcher.java similarity index 100% rename from infinity/search/WavReferenceSearcher.java rename to src/infinity/search/WavReferenceSearcher.java diff --git a/infinity/util/ArrayUtil.java b/src/infinity/util/ArrayUtil.java similarity index 100% rename from infinity/util/ArrayUtil.java rename to src/infinity/util/ArrayUtil.java diff --git a/infinity/util/Byteconvert.java b/src/infinity/util/Byteconvert.java similarity index 100% rename from infinity/util/Byteconvert.java rename to src/infinity/util/Byteconvert.java diff --git a/infinity/util/Decryptor.java b/src/infinity/util/Decryptor.java similarity index 100% rename from infinity/util/Decryptor.java rename to src/infinity/util/Decryptor.java diff --git a/infinity/util/Filereader.java b/src/infinity/util/Filereader.java similarity index 100% rename from infinity/util/Filereader.java rename to src/infinity/util/Filereader.java diff --git a/infinity/util/Filewriter.java b/src/infinity/util/Filewriter.java similarity index 100% rename from infinity/util/Filewriter.java rename to src/infinity/util/Filewriter.java diff --git a/infinity/util/IdsMap.java b/src/infinity/util/IdsMap.java similarity index 100% rename from infinity/util/IdsMap.java rename to src/infinity/util/IdsMap.java diff --git a/infinity/util/IdsMapCache.java b/src/infinity/util/IdsMapCache.java similarity index 100% rename from infinity/util/IdsMapCache.java rename to src/infinity/util/IdsMapCache.java diff --git a/infinity/util/IdsMapEntry.java b/src/infinity/util/IdsMapEntry.java similarity index 100% rename from infinity/util/IdsMapEntry.java rename to src/infinity/util/IdsMapEntry.java diff --git a/infinity/util/IntegerHashMap.java b/src/infinity/util/IntegerHashMap.java similarity index 100% rename from infinity/util/IntegerHashMap.java rename to src/infinity/util/IntegerHashMap.java diff --git a/infinity/util/LongIntegerHashMap.java b/src/infinity/util/LongIntegerHashMap.java similarity index 100% rename from infinity/util/LongIntegerHashMap.java rename to src/infinity/util/LongIntegerHashMap.java diff --git a/infinity/util/MassExporter.java b/src/infinity/util/MassExporter.java similarity index 94% rename from infinity/util/MassExporter.java rename to src/infinity/util/MassExporter.java index 126bd14..16558ce 100644 --- a/infinity/util/MassExporter.java +++ b/src/infinity/util/MassExporter.java @@ -15,6 +15,7 @@ import infinity.resource.graphics.Compressor; import infinity.resource.graphics.MveResource; import infinity.resource.key.ResourceEntry; +import infinity.resource.sound.SoundUtilities; import javax.swing.*; import javax.swing.event.*; @@ -62,13 +63,12 @@ public MassExporter() getRootPane().setDefaultButton(bExport); bExport.setMnemonic('e'); bCancel.setMnemonic('d'); - if (new File(ResourceFactory.getRootDir(), "acm2wav.exe").exists() || - new File("acm2wav.exe").exists()) + if (SoundUtilities.converterExists()) ; else { cbConvertWAV.setSelected(false); cbConvertWAV.setEnabled(false); - cbConvertWAV.setToolTipText("acm2wav.exe not found"); + cbConvertWAV.setToolTipText("Sound converter not found"); } JPanel leftPanel = new JPanel(new BorderLayout()); @@ -136,6 +136,7 @@ public void actionPerformed(ActionEvent event) if (event.getSource() == bExport) { selectedTypes = listTypes.getSelectedValues(); outputDir = new File(tfDirectory.getText()); + outputDir.mkdirs(); setVisible(false); new Thread(this).start(); } @@ -266,17 +267,10 @@ else if (entry.getExtension().equalsIgnoreCase("WAV") && cbConvertWAV.isSelected BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(acmfile)); bos.write(data, 28, data.length - 28); bos.close(); - File acm2wav = new File(ResourceFactory.getRootDir(), "acm2wav.exe"); - if (!acm2wav.exists()) - acm2wav = new File("acm2wav.exe"); - if (!acm2wav.exists()) + if (!SoundUtilities.converterExists()) return; - if (channels == 1) - Runtime.getRuntime().exec('\"' + acm2wav.getAbsolutePath() + "\" \"" + acmfile + "\" -m", null, - outputDir).waitFor(); else - Runtime.getRuntime().exec('\"' + acm2wav.getAbsolutePath() + "\" \"" + acmfile + '\"', null, - outputDir).waitFor(); + SoundUtilities.convert(acmfile, channels == 1); acmfile.delete(); } else { diff --git a/src/infinity/util/StreamDiscarder.java b/src/infinity/util/StreamDiscarder.java new file mode 100644 index 0000000..e69acea --- /dev/null +++ b/src/infinity/util/StreamDiscarder.java @@ -0,0 +1,42 @@ +package infinity.util; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.IOException; + +/** + * @author Fredrik Lindgren + * @since 2012-08-20 + */ +public class StreamDiscarder implements Runnable +{ + private InputStream in; + + /** + * Binds the argument stream to an instance variable + * + * @param in the input stream to be read from + */ + public void setStream(InputStream in) + { + this.in = in; + } + + /** + * Reads from the provided input stream + * + * @return void + */ + public void run() + { + try { + InputStreamReader r = new InputStreamReader(in); + BufferedReader b = new BufferedReader(r); + String s = null; + while ((s = b.readLine()) != null) {} + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/infinity/util/StringResource.java b/src/infinity/util/StringResource.java similarity index 100% rename from infinity/util/StringResource.java rename to src/infinity/util/StringResource.java diff --git a/infinity/util/StructClipboard.java b/src/infinity/util/StructClipboard.java similarity index 100% rename from infinity/util/StructClipboard.java rename to src/infinity/util/StructClipboard.java