Commit bbe86c2a authored by David Gonçalves's avatar David Gonçalves 📖

fixes

parent 105db394
dist
swf2exe/*.exe
!swf2exe/SA.exe
node_modules
ffdec/bash.exe.stackdump
......
......@@ -4,27 +4,43 @@ Hero Fighter story editor is a program for making custom stages that can be down
## Developers
- **MangaD** - Lead Developer
- **Tommy Chan** - Developer
- **zlyfer** - Developer
- **MangaD** - Lead Developer
- **Tommy Chan** - Developer
- **zlyfer** - Developer
## Development Requirements
- Install NodeJS
## Running the project
```sh
$ npm start
```
## Building the project
```sh
$ npm run dist
```
## TO-DO
- Improve UI. Give it a modern look.
- Use Bootsrap.
- Have toggle menu on the left. Menu will have following options:
- **Drag & Drop** page, that will let users select what they want to do and have the code generated for them. **This is very low on the priority of things to do.**
- **Source mode** page, that is basically Ace editor.
- **Tutorial** page.
- **About** page.
- Both editing modes (drag & drop and source mode) will show a page that will be about selecting which stage to edit, we will call this page the story menu. More than one stage can be edited at the same time (just go to the story menu page and select another story, changes will not be lost). The story menu will have the list of stories available for editing, showing their names (that the user can edit) and *possibly* a preview of the background (that the user can select. When clicking on a stage to edit, the editor will be shown and the user can edit his text and save it to a XML file. In the editor page the user will have the option to load the original story, in case the editor is empty (this will give him a reference on how to do things). In order to generate the executable the user must go to the story menu, which will have this option available. All the stories that have been modified by the user will be replaced in the executable.
- Verify if user has Java installed regardless of being in the path environment variable.
- Translate English to Chinese and vice-versa so that when writing a story both versions can be provided.
- XLS for validating the story XML file.
- Improve UI. Give it a modern look.
- Use Bootsrap.
- Have toggle menu on the left. Menu will have following options:
- **Drag & Drop** page, that will let users select what they want to do and have the code generated for them. **This is very low on the priority of things to do.**
- **Source mode** page, that is basically Ace editor.
- **Tutorial** page.
- **About** page.
- Both editing modes (drag & drop and source mode) will show a page that will be about selecting which stage to edit, we will call this page the story menu. More than one stage can be edited at the same time (just go to the story menu page and select another story, changes will not be lost). The story menu will have the list of stories available for editing, showing their names (that the user can edit) and *possibly* a preview of the background (that the user can select. When clicking on a stage to edit, the editor will be shown and the user can edit his text and save it to a XML file. In the editor page the user will have the option to load the original story, in case the editor is empty (this will give him a reference on how to do things). In order to generate the executable the user must go to the story menu, which will have this option available. All the stories that have been modified by the user will be replaced in the executable.
- Verify if user has Java installed regardless of being in the path environment variable.
- Translate English to Chinese and vice-versa so that when writing a story both versions can be provided.
- XLS for validating the story XML file.
## Updating
- Check for newer versions of Ace Editor and JPEXS and read the notes below about them.
- Check for newer versions of Ace Editor and JPEXS and read the notes below about them.
## Notes
......@@ -36,12 +52,12 @@ However, it comes with more than we need. Ace has "modes" that we can set so tha
The editor also has themes that do not highlight the XML tags. We can remove these themes.
- ambiance
- dracula
- github
- gob
- gruvbox
- katzenmilch
- ambiance
- dracula
- github
- gob
- gruvbox
- katzenmilch
### Editing the SWF
......@@ -49,10 +65,10 @@ We use the [JPEXS Free Flash Decompiler](https://www.free-decompiler.com/flash/)
Moreover, we only need the following files for it to work for our needs:
- ffdec.jar
- lib/ffdec_lib.jar
- lib/flashdebugger.jar
- lib/jna-x.x.x.jar
- ffdec.jar
- lib/ffdec_lib.jar
- lib/flashdebugger.jar
- lib/jna-x.x.x.jar
**All the other files can and should be removed.** Not only this reduces the size of our program as it will make it not possible to access the GUI of JPEXS.
......@@ -65,10 +81,10 @@ The algorithm is quite simple to implement, but I don't know yet why it works li
To convert programmatically, we do the following:
1. Create a copy of the Flash Player projector.
2. Append the .swf file to the projector's copy (merging the binaries basically).
3. Append the following footer to the file: [0x56, 0x34, 0x12, 0xFA]
4. Append the size of the .swf file (4 bytes) to the file.
1. Create a copy of the Flash Player projector.
2. Append the .swf file to the projector's copy (merging the binaries basically).
3. Append the following footer to the file: \[0x56, 0x34, 0x12, 0xFA]
4. Append the size of the .swf file (4 bytes) to the file.
There are different versions of the Flash Player projector, but this algorithm should work for all of them.
......
......@@ -255,63 +255,39 @@ function compileExe() {
function swf2exe(swfFile, outputFile) {
let footer = [0x56, 0x34, 0x12, 0xFA];
let projectorData = fs.readFileSync(`swf2exe/SA.exe`);
let swfData = fs.readFileSync(swfFile);
let footer = Buffer.from( new Uint8Array([0x56, 0x34, 0x12, 0xFA]) );
let swfLength = Buffer.from( new Uint8Array(intToByteArray(swfData.length)));
// Windows was having an error "EBUSY resource busy or locked" when
// using appendFile after writeFile, so we just write everything at once
let arr = [projectorData, swfData, footer, swfLength];
let buf = Buffer.concat(arr);
// Tommy was having an error "EBUSY resource busy or locked" when using the
// sync version of these functions
fs.writeFile(outputFile, projectorData, function (err) {
fs.writeFile(outputFile, buf, function (err) {
if (err) {
$('body').removeClass("loading");
dialog.err(window.lang.swf2exe_error, window.lang.error);
return console.log(err);
}
fs.appendFile(outputFile, swfData, function (err) {
if (err) {
$('body').removeClass("loading");
dialog.err(window.lang.swf2exe_error, window.lang.error);
return console.log(err);
}
fs.appendFile(outputFile, Buffer.from( new Uint8Array(footer) ), function (err) {
if (err) {
$('body').removeClass("loading");
dialog.err(window.lang.swf2exe_error, window.lang.error);
return console.log(err);
}
fs.appendFile(outputFile, Buffer.from( new Uint8Array(intToByteArray(swfData.length))), function (err) {
if (err) {
$('body').removeClass("loading");
dialog.err(window.lang.swf2exe_error, window.lang.error);
return console.log(err);
}
// Delete XML and SWF files
try {
fs.unlinkSync(xml_story_filename);
fs.unlinkSync(xml_storylist_filename);
fs.unlinkSync(swf_filename);
} catch(err) {
$('body').removeClass("loading");
console.log(err);
dialog.err(window.lang.unlink_error, window.lang.error);
return;
}
dialog.info(window.lang.exe_success, window.lang.success);
$('body').removeClass("loading");
});
});
});
// Delete XML and SWF files
try {
fs.unlinkSync(xml_story_filename);
fs.unlinkSync(xml_storylist_filename);
fs.unlinkSync(swf_filename);
} catch(err) {
$('body').removeClass("loading");
console.log(err);
dialog.err(window.lang.unlink_error, window.lang.error);
return;
}
dialog.info(window.lang.exe_success, window.lang.success);
$('body').removeClass("loading");
});
function intToByteArray(int) {
// we want to represent the input as a 4-bytes array
var byteArray = [0, 0, 0, 0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment