Started working on save_map_as
This commit is contained in:
parent
e2055f7bc7
commit
f123b26f12
4 changed files with 33 additions and 12 deletions
|
|
@ -15,9 +15,13 @@ func _input(event: InputEvent):
|
|||
if event is InputEventMouseButton:
|
||||
if event.pressed==false: return
|
||||
|
||||
|
||||
var mouse_pos = get_local_mouse_position()
|
||||
#print("Local Mouse Position:", mouse_pos)
|
||||
if mouse_pos.y < 0: return # outside of TileMap
|
||||
var cell_pos = local_to_map(mouse_pos)
|
||||
|
||||
|
||||
var source_id = get_cell_source_id(cell_pos)
|
||||
|
||||
if source_id > -1:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ extends Node
|
|||
@onready var ground_map = %GroundMapLayer
|
||||
@onready var map_menu_container = %MapMenuContainer
|
||||
|
||||
@onready var ui_logic = %UILogic
|
||||
|
||||
var content = null
|
||||
var coord2tilename = {}
|
||||
var tilename2coord = {}
|
||||
|
|
@ -84,21 +86,37 @@ func get_tile_texcoord(str_palette:String, tile_name:String) -> Vector2i:
|
|||
|
||||
|
||||
func _on_map_item_selected(index: int) -> void: # 1 laden, 2 speichern, 3 speichern als
|
||||
%MapItemList.deselect_all()
|
||||
match index:
|
||||
0: print("Neue Karte erstellen")
|
||||
1: print("Karte laden")
|
||||
2:
|
||||
print("Karte speichern: %s/%s" % [Global.settings.current_project_dir,Global.settings.current_map_name])
|
||||
%ResourceSaver.saveMap(Global.settings.current_project_dir + "/" + Global.settings.current_map_name)
|
||||
3: print("Karte speichern als")
|
||||
3:
|
||||
print("Karte speichern als...")
|
||||
save_map_as()
|
||||
|
||||
map_menu_container.hide()
|
||||
|
||||
func save_map_as():
|
||||
#var file_dialog1 = FileDialog.new()
|
||||
%FileDialog.mode_overrides_title = false
|
||||
%FileDialog.title="Karte speichern als..."
|
||||
%FileDialog.access=FileDialog.ACCESS_FILESYSTEM
|
||||
%FileDialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
|
||||
print("Setting map directory to {0}".format([Global.settings.current_project_dir]))
|
||||
%FileDialog.set_current_dir(Global.settings.current_project_dir) # or any other path
|
||||
|
||||
func _on_menu_interaction_started():
|
||||
print("Disabling TileMap clickability")
|
||||
ground_map.interaction_enabled = false
|
||||
%FileDialog.popup_centered()
|
||||
%FileDialog.file_selected.connect(func(full_filename):
|
||||
|
||||
func _on_menu_interaction_ended():
|
||||
print("Enabling TileMap clickability")
|
||||
ground_map.interaction_enabled = true
|
||||
%MapItemList.deselect_all()
|
||||
if not full_filename.ends_with(".tres"): full_filename = full_filename + ".tres"
|
||||
print("Selected file: ", full_filename)
|
||||
var filename:String = full_filename.split("/")[-1]
|
||||
print("Shortname: ", filename)
|
||||
Global.settings.current_map_name = filename
|
||||
#save_settings()
|
||||
|
||||
#emit_signal("selected_map_for_loading", full_filename)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ func _ready():
|
|||
|
||||
#map_menu.pressed.connect(map_manager._on_map_menu_toggled)
|
||||
map_menu_item_list.item_selected.connect(map_manager._on_map_item_selected)
|
||||
map_menu_item_list.focus_entered.connect(map_manager._on_menu_interaction_started)
|
||||
map_menu_item_list.focus_exited.connect(map_manager._on_menu_interaction_ended)
|
||||
|
||||
palette_panel.mouse_entered.connect(map_cursor_timer.disable_cursor)
|
||||
palette_panel.mouse_exited.connect(map_cursor_timer.enable_cursor)
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@ extends Button
|
|||
|
||||
func _gui_input(event):
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
|
||||
print("Palette UI toggled")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue