Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Commit

Permalink
Map editor
Browse files Browse the repository at this point in the history
  • Loading branch information
superRaptor911 committed Aug 17, 2020
1 parent 01955e1 commit 96ccf3f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 18 deletions.
7 changes: 6 additions & 1 deletion Menus/Editor/EditorspawnPoint.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ var team_id = 0
var red_circle = preload("res://Menus/Editor/T_icon.png")
var blue_circle = preload("res://Menus/Editor/CT_icon.png")

var camera

signal selected(spawn_point)

func _ready():
camera = get_parent().get_parent().camera


func setTeamID(id):
if team_id != id:
Expand All @@ -20,7 +25,7 @@ func setTeamID(id):
func _unhandled_input(event):
if event is InputEventScreenTouch or event is InputEventMouseButton:
if event.pressed:
if (event.position - position).length() < 100:
if (event.position - (position - camera.position)).length() < 100:
emit_signal("selected", self)


Expand Down
34 changes: 34 additions & 0 deletions Menus/Editor/LevelEditorMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,37 @@ func _on_gameMode_pressed():
func _on_back_pressed():
MusicMan.click()
MenuManager.changeScene("EditorMapSelector")


func _on_convert_pressed():
var levelInfo = {
name = "Dust II",
minimap = "",
game_modes = [
{bombing = "" },
{FFA = ""}
],
desc = "",
debug = false
}

var base_map = null
var game_modes = [null, null]
var map_name = game_server.serverInfo.map

var file = File.new()
var file_name = "user://custom_maps/maps/" + map_name + ".tscn"
if file.file_exists(file_name):
base_map = load(file_name).instance()
base_map.name = "BaseMap"
base_map.force_update = false

file_name = "user://custom_maps/gameModes/TDM/" + map_name + ".tscn"
if file.file_exists(file_name):
game_modes[0] = load(file_name).instance()

file_name = "user://custom_maps/gameModes/Zombie/" + map_name + ".tscn"
if file.file_exists(file_name):
game_modes[1] = load(file_name).instance()

var level_node = Node2D.new()
32 changes: 18 additions & 14 deletions Menus/Editor/LevelEditorMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ __meta__ = {
}

[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/Panel"]
anchor_left = 0.161
anchor_top = 0.269
anchor_left = 0.163
anchor_top = 0.165
anchor_right = 0.839
anchor_bottom = 0.731
margin_left = -0.114014
margin_top = -0.029007
margin_right = 0.113953
margin_bottom = 0.0289917
anchor_bottom = 0.627
margin_left = -0.249725
margin_top = -0.0572891
margin_right = 1.61224
margin_bottom = 0.000701904
custom_constants/separation = 50
__meta__ = {
"_edit_use_anchors_": false
Expand Down Expand Up @@ -73,17 +73,21 @@ custom_fonts/font = ExtResource( 1 )
disabled = true
text = "OBJECT EDITOR(SOON)"

[node name="back" type="Button" parent="PanelContainer/Panel"]
margin_left = 548.0
margin_top = 479.0
margin_right = 699.0
margin_bottom = 537.0
[node name="convert" type="Button" parent="PanelContainer/Panel"]
anchor_left = 0.309
anchor_top = 0.736
anchor_right = 0.738
anchor_bottom = 0.847
margin_left = 0.322678
margin_top = 0.161133
margin_right = -0.170349
margin_bottom = 0.225128
custom_styles/normal = ExtResource( 2 )
custom_fonts/font = ExtResource( 1 )
text = "BACK"
text = "CONVERT TO LEVEL"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="PanelContainer/Panel/VBoxContainer/mapEditor" to="." method="_on_mapEditor_pressed"]
[connection signal="pressed" from="PanelContainer/Panel/VBoxContainer/gameMode" to="." method="_on_gameMode_pressed"]
[connection signal="pressed" from="PanelContainer/Panel/back" to="." method="_on_back_pressed"]
[connection signal="pressed" from="PanelContainer/Panel/convert" to="." method="_on_convert_pressed"]
18 changes: 15 additions & 3 deletions Menus/Editor/TDMspawnEditor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,26 @@ func loadSpawnPoints():
points_node.queue_free()


func saveSpawnPoints():
func saveSpawnPoints() -> bool:
var spawn_parent = $spawns
var points = $editorSpawns.get_children()

if points.size() == 0:
return false

var teams = [0,0]

for i in points:
var point = spawn_point.instance()
point.position = i.position
point.team_id = i.team_id
teams[i.team_id] += 1
spawn_parent.add_child(point)
point.owner = spawn_parent

if teams[0] == 0 or teams[1] == 0:
return false

remove_child(spawn_parent)
var packed_scene = PackedScene.new()
var result = packed_scene.pack(spawn_parent)
Expand All @@ -97,12 +106,15 @@ func saveSpawnPoints():
else:
push_error("An error occurred while saving the scene to disk.")
spawn_parent.queue_free()
return true


func _on_back_pressed():
MusicMan.click()
saveSpawnPoints()
MenuManager.changeScene("EMS/LEM/GameModesMenu")
if saveSpawnPoints():
MenuManager.changeScene("EMS/LEM/GameModesMenu")
else:
Logger.notice($uiLayer, "Error", "Add atleast 1 spawn point for each team.", Color.red)


func _on_spawn_delete_pressed():
Expand Down
2 changes: 2 additions & 0 deletions Menus/Lobby/Lobby.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func loadLevelInfos():
else:
Logger.LogError("loadLevelInfos", "Failed to load levels")

func loadCustomMaps():
pass

func setLevelInfo(info):
if selected_level != info:
Expand Down

0 comments on commit 96ccf3f

Please sign in to comment.