2023-07-27 16:41:49 +09:30
|
|
|
extends Node2D
|
2024-07-15 02:31:36 +09:30
|
|
|
signal exit
|
2024-07-06 01:23:40 +09:30
|
|
|
var tileset_tex := TextureRect.new()
|
|
|
|
var worldmaps := []
|
|
|
|
var block_images := []
|
|
|
|
var block_textures := []
|
2023-07-27 16:41:49 +09:30
|
|
|
var block_labels = []
|
2024-07-06 01:23:40 +09:30
|
|
|
var worldmap_shader_mat := preload('res://worldmap_palette_mat.tres')
|
2023-07-27 16:41:49 +09:30
|
|
|
|
|
|
|
func bin2str(bin: int) -> String:
|
|
|
|
var string := ''
|
|
|
|
for i in 8:
|
|
|
|
if i == 4:
|
|
|
|
string += ' '
|
|
|
|
if ((bin >> 7-i) & 0x01) != 0:
|
2024-07-06 01:23:40 +09:30
|
|
|
string += ',' #'1'
|
2023-07-27 16:41:49 +09:30
|
|
|
else:
|
2024-07-06 01:23:40 +09:30
|
|
|
string += '.' #'0'
|
2023-07-27 16:41:49 +09:30
|
|
|
return string
|
|
|
|
|
2024-07-15 02:31:36 +09:30
|
|
|
func _exit() -> void:
|
|
|
|
emit_signal('exit')
|
2024-07-06 01:23:40 +09:30
|
|
|
|
2023-07-27 16:41:49 +09:30
|
|
|
func _ready() -> void:
|
2024-07-15 02:31:36 +09:30
|
|
|
$btn_exit.connect('pressed', self, '_exit')
|
2024-07-06 01:23:40 +09:30
|
|
|
var blockmap = PoolByteArray()
|
|
|
|
for i in 0xC0:
|
|
|
|
blockmap.append(i)
|
|
|
|
for i in 0x40:
|
|
|
|
blockmap.append(i)
|
2023-07-27 16:41:49 +09:30
|
|
|
for i in 3:
|
2024-07-06 01:23:40 +09:30
|
|
|
worldmaps.append(MapLoader.WorldMap.new(16, 16))
|
|
|
|
worldmaps[i].block_tile_ids = SpriteLoader.worldmap_block_tile_ids[i]
|
|
|
|
worldmaps[i].blockmap = blockmap
|
|
|
|
block_images.append(worldmaps[i].make_tile_map())
|
|
|
|
block_textures.append(SpriteLoader.texture_from_image(block_images[i]))
|
|
|
|
|
|
|
|
self.tileset_tex.show_behind_parent = true
|
|
|
|
self.tileset_tex.material = worldmap_shader_mat.duplicate()
|
|
|
|
self.tileset_tex.material.set_shader_param('enable_waterfall_scroll', 0)
|
|
|
|
self.tileset_tex.material.set_shader_param('enable_sea_scroll', 0)
|
|
|
|
self.tileset_tex.material.set_shader_param('tilemap_width', 32)
|
|
|
|
self.tileset_tex.material.set_shader_param('uv_scale', 32)
|
|
|
|
var _scale := 8
|
|
|
|
var _size = Vector2.ONE * 2 * _scale
|
|
|
|
self.tileset_tex.rect_scale *= _scale
|
|
|
|
# x0 += 4 * _scale
|
|
|
|
# y0 += 12 * _scale
|
|
|
|
var pos = Vector2(0, 48)
|
|
|
|
self.tileset_tex.rect_position = pos
|
|
|
|
add_child(tileset_tex)
|
|
|
|
|
|
|
|
for block in 0xC0:
|
|
|
|
var label = Label.new()
|
|
|
|
var p = 0 #MapLoader.worldmap_block_properties[i][block]
|
|
|
|
label.text = '%s\n%s\n%s' % [bin2str(p&0xff), bin2str((p>>8)&0xff), bin2str(p>>16)]
|
|
|
|
label.add_color_override('font_color_shadow', Color.black)
|
|
|
|
label.add_constant_override('shadow_as_outline', true)
|
|
|
|
label.rect_position = pos + (Vector2(block%16, block/16) * _size)
|
|
|
|
label.rect_size = _size
|
|
|
|
label.align = Label.ALIGN_LEFT
|
|
|
|
label.valign = Label.VALIGN_TOP
|
|
|
|
add_child(label)
|
|
|
|
block_labels.append(label)
|
2023-07-27 16:41:49 +09:30
|
|
|
$BitSelector.connect('value_changed', self, '_update_block_mask')
|
2024-07-06 01:23:40 +09:30
|
|
|
$tileset_sel.connect('value_changed', self, '_update_tileset')
|
|
|
|
self._update_tileset(0)
|
2023-07-27 16:41:49 +09:30
|
|
|
|
|
|
|
func _update_block_mask(value: int):
|
|
|
|
var mask = 0xFFFFFF if (value<0) else (1<<value)
|
|
|
|
$BitSelectorMask.text = '%s\n%s\n%s' % [bin2str(mask&0xff), bin2str((mask>>8)&0xff), bin2str(mask>>16)]
|
|
|
|
for i in block_labels.size():
|
2024-07-06 01:23:40 +09:30
|
|
|
var p = 0 #MapLoader.worldmap_block_properties[i/0xC0][i%0xC0]
|
2023-07-27 16:41:49 +09:30
|
|
|
if (p & mask) > 0:
|
|
|
|
block_labels[i].add_color_override('font_color', Color.white)
|
|
|
|
else:
|
|
|
|
block_labels[i].add_color_override('font_color', Color.black)
|
2024-07-06 01:23:40 +09:30
|
|
|
|
|
|
|
func _update_tileset(i: int):
|
|
|
|
self.tileset_tex.texture = block_textures[i]
|
|
|
|
self.tileset_tex.material.set_shader_param('palette', SpriteLoader.worldmap_palette_textures[i])
|
|
|
|
self.tileset_tex.material.set_shader_param('tile_atlas', SpriteLoader.worldmap_tile_atlas_textures[i])
|
|
|
|
var map = RomLoader.snes_data.worldmap_block_properties[i]
|
|
|
|
var fmt = '.,'
|
|
|
|
for b in 0xC0:
|
|
|
|
var p = map[b]
|
|
|
|
block_labels[b].text = fmt[p.isnt_landable_chocobo] + fmt[p.isnt_landable_black_chocobo] + fmt[p.isnt_landable_hiryuu] + fmt[p.isnt_landable_airship]
|