Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve underscores between digits in map constant to filename conversion #56

Closed
Rangi42 opened this issue Aug 25, 2021 · 1 comment
Closed

Comments

@Rangi42
Copy link
Owner

Rangi42 commented Aug 25, 2021

Event::warp_map_name converts the map constant to a label, e.g. UNION_CAVE_1F to UnionCave1F. However, it doesn't appropriately handle a case that doesn't come up in pokecrystal, when the constant has an underscore between digits. LUSTER_APARTMENT_1_1F should convert to LusterApartment1_1F, not LusterApartment11F.

Here's a Python implementation for testing:

def constant2label(constant):
    label = ''
    downcase = False
    for c in constant:
        if downcase:
            c = c.lower()
        if c == '_':
            downcase = False
        else:
            label += c
            downcase = not c.isdigit()
    return label
@Rangi42
Copy link
Owner Author

Rangi42 commented Aug 26, 2021

This gives better results:

def constant2label(constant):
	label = ''
	wasletter = False
	wasdigit = False
	maybeunderscore = False
	for c in constant:
		if c != '_':
			if maybeunderscore and c.isdigit():
				label += '_'
			if wasletter:
				c = c.lower()
			label += c
			maybeunderscore = False
		elif wasdigit:
			maybeunderscore = True
		wasletter = c.isalpha()
		wasdigit = c.isdigit()
	return label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant