Giter Site home page Giter Site logo

wad-js's Introduction

Front-end tool for editing wads on the web.

Load a wad from your device, or by URL and view many different types of lumps.

Preview support includes:

  • Text files
  • Audio files
  • Midi files
  • Graphics (Doom Image Format, Flats, PNGs)
  • ENDOOM, PLAYPAL and COLORMAP files
  • THINGS (displays thing count of Doom and Doom 2 types)

WAD.js

Javascript Library for manipulating Doom WAD format files

Read Doom WADs and access data from many different common lump types easily.

Current features include:

  • Loading WADs from local directories or URLs
  • Finding lumps in a WAD by name or index
  • Retrieving lump data as either text or binary data
  • Lump type detection (Common Text Data types, Mapdata, Graphics, Sprites, Flats, MIDI, MUS, and many more)
  • ENDOOM renderer (requires dos.png, a character map for the ASCII characters used)
  • PLAYPAL, COLORMAP renderer
  • Export Graphics and Flats to Canvas
  • Render Maps to Canvas

Development

Follow the instructions here on how to install and use Grunt.

Install Browserify using npm with npm install -g browserify

Why?

Libraries for reading and manipulating doom wads exist in many languages, but not Javascript (until now). Exposing this access to the web can make for a much wider variety of interesting possibilities. Please make a cool web tool with this!

How?

Load WAD file from desktop

In your HTML, any standard file input such as: <input type="file" id="fileInput"/>

And create a WAD object, and load the file like this:

var wad = Object.create(Wad); // Create a new WAD object to load our file into

// Create a callback function when loading is complete
wad.onLoad = function() {
  alert('Wad successfully loaded!');
};

var fileInput = document.getElementById('fileInput');
fileInput.addEventListener('change', function(e) {
  var file = fileInput.files[0];
  wad.load(file); // Load the file into the WAD object we created
}

Load WAD file from URL

Create a WAD object and load the URL

var wad = Object.create(Wad); // Create a new WAD object to load our file into

// Create a callback function when loading is complete
wad.onLoad = function() {
  alert('Wad successfully loaded!');
}; 

wad.loadURL('http://www.example.com/file.wad');

Lumps

A directory of lump information is stored in wad.lumps, storing the names and also used internally to access the data of the lumps.

for (var i = 0; i < wad.lumps.length; i++) {
  console.log(wad.lumps[i].name); // Print the name of every lump in the WAD file.
}

These lump objects store name, size and pos (byte position in the WAD file). However, only the name will be useful for most cases.

To get the actual data for a lump, use the commands: wad.getLump(index) Return the lump data by index of the lump. wad.getLumpByName(name) Return the data of the first lump in the wad that matches name.

To ease finding lumps, there are some helper functions: wad.lumpExists(name) Returns true if a lump in the wad exists with the given name. wad.getLumpIndexByName(name) Just returns the index of the first lump matching the given name, instead of the entire data of the lump. wad.getLumpAsText(index) Return the lump data as a string instead of byte data.

Lump interfaces

Graphics

Doom uses a custom image format for most of the graphics in the game. These can be automatically converted to standard images by wad.js.

Example:

graphic = Object.create(Graphic); // We create Graphic objects just like Wad object files
graphic.load(wad.getLumpByName('PLAYA1'); // Load the player sprite from DOOM2.WAD
canvas = graphic.toCanvas(); // Export the image to a HTML5 canvas
document.body.appendChild(canvas); // Place the image on the page

Flats

Flats are another image format used in Doom games, for sector floors and ceilings. The API matches the graphic format API.

flat = Object.create(Flat); Create a new Flat object flat.load(data); Load lump data into flat object flat.toCanvas(); Return new canvas object with the flat's data rendered to it

Playpal

The PLAYPAL lump is the palette used in the Doom wad, present in the IWAD files. If no PLAYPAL is present, a copy of the DOOM/2.WAD palette is used internally for graphics rendering.

playpal = Object.Create(Playpal); Create a new Playpal object playpal.load(data); Load lump data into playpal object playpal.toCanvas(); Render playpal to a canvas object and return it

Colormap

The COLORMAP lump is used in Doom for lighting effects. It is an indexed list for each color in the palette with a ramp to darkness.

colormap = Object.Create(Colormap); Create a new Colormap object colormap.load(data); Load lump data into colormap object colormap.toCanvas(); Render the colormap to a canvas object and return it

wad-js's People

Contributors

jmickle66666666 avatar remyabel avatar remyabel2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wad-js's Issues

Play tracker audio files

It would be great if there was support for playing module/tracker file lumps in wads. It looks like this JavaScript library would be a good solution for it (with a version of it on npm here if the project starts using a build system like Webpack or something).

DECORATE parsing

actor listing
actor {
parent ...
replaces ...
doomednum ...
properties [...]
flags [...]
states {
frames [...]
}
}

Support arrow key lump navigation

This would be super great to have! Mainly up/down arrows for navigating between lumps, rather than having to manually scroll and click on everything.

http:// URL is preventing scripts from loading

Simply change http:// to https:// or use protocol-less URLs (depending on your opinion on which is better.)

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script> 
<script type='text/javascript' src='https://www.midijs.net/lib/midi.js'></script>

midijs.net doesn't have HTTPS actually, so you're probably better putting it in the project and loading it locally.

Minor progress bar problem

The progress bar works now (open up the inspector and watch the #loading element), however it doesn't appear to work because it disappears as soon as it fills up completely. The question becomes a UI issue: will this look bad or should there be a small delay to let it look complete, even if that'll waste time?

MAPINFO parsing

Detect whether it is Hexen, ZDoom old, or ZDoom new mapinfo format

map clusters with key/object pairs
episode clusters with the same

Flats

Flat parsing

Store as array of palette indexes
Render as image

Replace Lump

Add a function to replace a lump with a user-uploaded file.

PNAMES parsing

parse/store data
use this information in lump detection for more accuracy

Mapdata information tables

See SLADE's implementation. When opening a mapdata lump like THINGS etc, it lists the data in a neat table.

Text lump editing

Along with #18, #16 etc., there needs to be editable lumps to even test the feature out properly.

One implementation would be a "Edit" button that shows up on the preview, and that replaces the normal preview with an editing panel, which includes the main text editing box (I assume there is already a DOM element that can support this, but we could also look into a library that supports extra features such as syntax highlighting), a Save, Cancel, and area for any future options we may support.

Hexen format support

Hexen format maps have a different data structure, but are still bytedata. Also important is to make sure both Hexen and ZDoom in Hexen format maps both work.

Map data parsing

parse and store all the map data lumps
automatically find all the correct lumps for a specified map
render the map image to a canvas

Add a license

A license should be added to this repository, so that people can know about their rights when using the software.

See Choose a License for more information.

Show error messages for invalid file load attempts

Thanks for making such a kickass tool ๐ŸŒฎ ๐ŸŒฎ As I said on DW I'd be happy to help in any way I can.

Quick thing for now though is that it would be nice if the UI told you when you try to upload an invalid file type, or when loading from URL fails for any reason (CORS issue, not a valid file type, or field left empty). It looks like in such cases errors are getting spit out in the console, but the UI still displays a loading thing indefinitely.

Asynchronous wad loader

I did an overhaul of the wad loader, see 878b051. Essentially before you read the wad into memory and looped over the contents. As a result, the progress bar only updated once because for loops are not "asychronous". This fixes that. The general process is:

  1. Read the contents of the wad to check if it's a valid wad, get the initial number of lumps and pointer to the dictionary

  2. Initiate the chain with a call to chunkReaderBlock. This function takes the offset (initially self.dictpos), chunkSize (16 as each lump is 16 bytes in size) as well as the file (named blob).

  3. All chunkReaderBlock does is create a new FileReader that takes a 16 byte slice.

  4. nextChunk is basically the main chunk of the original code except offsets were corrected for

  5. Once we've reached the end of the file, we call onLoad, etc.

Subsequently I changed the logic of the progress bar. Right now it's actually kinda broken (it works but I have magic values) but the gist of it is:

There are two global counters now: progress and bar. The logic I'm trying to follow is that the width of the bar is 284 pixels and should be split into even sections (I picked a magic value of 284 divided by 14, which is the font pixel size, which approximately is 20). Then we want to normalize the total progress somehow so that a proportional amount of progress equates to some bars, resulting in a constant bar width for all filetypes. But it's morning here and I've been working on this all night, so I'm not going to fix it right now.

The other major issue is that my new code is actually a bit slower. It can be fixed by increasing the chunk size from something like 16 or 64 and looping inside nextChunk like done in the previous code. I'm not actually sure if this will create blocking, but hopefully not enough to disrupt the loading animation. Again, it's late and that's why I created this issue.

Split all javascript from index.html into separate files

One potential structure of the tool would could be to have each of the preview panels (text preview, audio preview, image preview, etc.) as their own .js file, and similar for different parts of the ui, such as the menu for loading and in future saving wads.

PLAYPAL range previews

Currently it only previews the first palette. Need to add functionality to pull other palettes from the playpal lump.

Icons

  • text
  • unknown
  • map
  • mapdata
  • music
  • midi
  • mp3
  • mus
  • png
  • graphic
  • flat
  • marker
  • PLAYPAL
  • COLORMAP
  • TEXTUREx
  • PNAMES
  • ENDOOM

Standard lump function buttons

A possible wrapper element when viewing lumps that includes a few common functions to all lumps:

Buttons for "View as text" "View as hex", for both undetectable types and even when wanting to view detected lumps in different ways.
Buttons for "Save" and "Replace"
Button/Input field for "Rename"

Crash when opening large(?) wads

I created a wad with 2 full mp3 albums in, to test loading large files. Wad.js will begin loading, but eventually crash before completion.

Doom graphic

Parse it

Decide how to store it

Render as image

Reorganize lump browsing

Currently just looking at a list of all the lumps in order is Not Cool, so I need to think of a new way of organising them.

Omgifol sorts lumps into separate categories; graphics, audio, data, and maps into groups of lumps. This is pretty ergonomic and will probably be the basis of my system.

I would like to revamp the way maps work too, possibly with integration from MAPINFO if present, letting the user edit data in a completely new and more intuitive way.

This also brings into question the possibility of some kind of metadata lump. who knows.

Playpal

Create parser and object for playpal lumps

Store as array of colours.
Decide best way to store colours.
Preview/image exporter

Colormap

Colormap parser

Store as list of palette indexes
Export as array of colours
Export as image

UDMF support

Unlike doom and hexen format maps, UDMF is a text-based parser, meaning a different kind of parser will need to be created for it. However, aside from the parser there shouldn't be too much work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.