King's Valley Plus level edit plugin for Tiled 
v1.0 by FRS, 2021/11.
===============================================================================

Based on:
 - videogame-format.js by diogoeichert
 - "How to write a custom Text File importer for Tiled Map Editor" guide, by
   Mezzmer & eishiya

License: CC:BY-SA
Requires: 
 - Tiled v1.7.2 or higher
 - King's Valley Plus enhancement patch by FRS
   http://frs.badcoffee.info/patches.html

- Files included in this package:
   - DEMO1.KVG                : Demo level that shows all features of the engine
   - KV1Plus-format.js        : Javascript plugin for Tiled
   - KV1PlusEmpty1rooms.tmx   : Empty level template with 1 room
   - KV1PlusEmpty2rooms.tmx   : Empty level template with 2 rooms
   - KV1PlusEmpty3rooms.tmx   : Empty level template with 3 rooms
   - KV1TileSet.png           : Component of the KV1TileSet.tsx file
   - KV1TileSet.tsx           : The tileset for King's Valley Plus levels
   - ReadMe.txt               : This Readme file

This is a plug-in that allows the Tiled map editor to load/export custom stages
for the game King's Valley Plus (aka King's Valley with Editor). An accompanying
patch for the game is provided to replace the terrible built-in editor, fix some
bugs and implement some enhancements. 

Read the Patch.txt file for more details and the instructions on how to apply it.

You can download the latest version of Tiled here:
https://www.mapeditor.org

-  Special thanks for:
  - MsxKun@msx.org, for giving me the pointers on where to begin a Tiled plugin
  - MSX-Translations crew, for their "MSX Levels and Editors Contest 2021".


1) Install Instructions:
   Copy the KV1Plus-format.js, KV1TileSet.png and KV1TileSet.tsx files to
   the Tiled extensions folder, as explained in the following article:
   https://doc.mapeditor.org/en/stable/reference/scripting/#binaryfile

2) Edit instructions:

a) KV1PlusEmpty1rooms.tmx, KV1PlusEmpty2rooms.tmx and KV1PlusEmpty3rooms.tmx are
   empty level templates with 1, 2 and 3 rooms respectively. They can be used to
   easily start editing new levels.

d) Tiles and objects:

- Click on an tile in the tileset and check its name on the properties to check
  its name
- Some objects are composed by multiple tiles, like the enemies, exit doors,
  flip doors, trap doors etc. Select the whole set while holding left button,
  and then start drawing it on the map.
- Stairs can be easily drawn by selecting the its lower tiles and then drawing with
  the SHIFT key hold, then trace a diagonal line. Later, remember to place the
  header tiles of all stairs accordingly, on the top of all stairs.

c) Some objects have special tiles to configure them, like:

- exitDoors: 
  - The ? tile inside it is the default and assigns the exit door directions
    automagically. You can manually assign them to exit to be the left,
    right, down or right doors using the respective "arrow" tiles available on the
    tileset.
  - Right beside it, you can place another configuration tile to set to which
    door on the destination level this door will connect to. If you don't set
    this, it will be automatically assigned to the opposite door direction: left
    to right, up to down and so on.
- Flip doors: If you place the "flipDoorInverter" tile on the top of row of a
  flip door, it will enable a property where the door will automatically flip
  itself just after the level has started, to fool the player memory

d) Check the included DEMO1.KVG file to see all features being used and how
   they behave in the game

e) Remember to set the Author, Song, Theme and Title for your stage in the
   Map->Map Properties menu:
- Author: author initials (max 3 chars)
- Title : title for this stage (max 19 chars)
- Theme : 0=random, 1~3=selects a specific theme
- Destination levels for each exitDoor type, if you intend to use this level to
  replace a level in the GAME mode

f) Limitations:
- Strings and values for the map properties above will be cropped/clamped to
  fit within limits.
- All texts (author, title) will be converted to uppercase by the game

3) Gameplay

a) You can play any level individually in the LOAD mode
b) If you name a level as GAMExx.KVG, the game will automatically replace the
   respective xx level in the PLAY mode with your custom level. But remember to
   set all exitDoor destination levels in the Tiled map->properties menu.



4) FAQ:

Q: I have many levels in the old EDATAx format. What can I do to edit
   or play these levels?
A: Just add the .KVE extension to these old files, then Tiled will be able
   to load them. Then you can save your levels in the fully featured
   .KVG format.

Q: I also have some levels only in the old GAMExx.DAT format, and lost the
   respective EDATAx files. What can I do to edit or play these levels?
A: - Rename the .DAT extension to .KVG
   - Load the file on Tiled. A popup dialog will warn you that this doesn't seem
     to be a valid KVG file and ask if you want to try to force to load it.
     Click on Yes and your level will be loaded. 

Q: How do I select the number of rooms on my level?
A: The plugin will automatically show only the number of rooms you actually
   used. If you want to add or remove rooms, just enlarge or shrink the map
   on the Map->Resize Map menu.

Q: How can I see the boundaries between the rooms?
A: On the Tiled editor preferences, set the "Interface->Major Grid every" to 16 or
   32 tiles. I prefer to use 16 tiles so I can also see where the middle of each
   room is.



