mapeditor / mapeditor/tiled

Custom numerical values for Enum custom properties

Open
#3,534 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12.9k
Forks
2k
Avg merge
4h 27m
Merged PRs (30d)
8

Description

Background

Currently, numerical enum values are set by Tiled based on whether that custom type is allowed to have multiple values. This is great as a default, but the lack of control makes it difficult to add Enums in Tiled that align with Enums in one's game, or enums that only allow a particular range of values, as those may have values that don't start at 0 and/or don't increase in the ways Tiled supports.

Feature request

For Enums that cannot have multiple values, it would be good to allow users to set custom numerical values. These would only be relevant when saving the values as numbers, so perhaps it would also make sense to limit this feature to those.

(In case this request sounds familiar, I brought this up before in https://github.com/mapeditor/tiled/issues/1211#issuecomment-943878139, but that issue was closed without this feature being added.)

UI suggestions

I think the numerical values should be displayed in the list of values, greyed out when they cannot be edited. Perhaps when saving as String, the number column should be hidden entirely since it's irrelevant, though it should keep any custom numerical values that were previously set.
When editing a value, you should be able to click or double-click the number and edit it like an integer. When committing a change, if there's a conflict, I think a warning should be displayed, with options to Edit NameOfValue, which puts the just-edited value back into focus without committing the change, and Edit NameOfConflictingValue, which commits the just-edited value and puts the conflicting value into focus for editing instead. This second option would put the definitions into an invalid state if the user closes the editor at this point (and while Tiled can try to keep the user from exiting, it can't stop a force-quit xP). A potential fix is to set the conflicting value to 1+ current highest value (but give the user the old value to edit), so that the enums are never in an invalid state under the hood, even if they're temporarily displayed with invalid values for editing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the issue. Start by locating the editor for custom Enum properties and the code that serializes their values as numbers; define the supported editing, conflict handling, and string-versus-number behavior before implementing and testing the feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.