Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
- Things will update their Z position based on slab height when editing surrounding slabs. This fixes a bug where if a Thing was placed on top of a Library bookcase and then the Library was slightly shrunk so that the bookcase disappears, the Thing's Z position wasn't updating in that circumstance.
- Use room colours instead of floor colours for ownership shader
- Prevent placing something on map when clicking to close a window
- Browse maps: prevent keyboard camera panning if browser is open
- Browse maps: display quick map preview when selecting a map with single-click (or use keyboard)
- Properties window: action points won't display Z field anymore
  • Loading branch information
rainlizard committed May 10, 2022
1 parent 47fb41c commit 2e6b060
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 61 deletions.
4 changes: 2 additions & 2 deletions AutoLoad/Constants.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const VERSION = "0.19"
const TILE_SIZE = 96
const SUBTILE_SIZE = 32

#var ownershipColors = [Color8(156,48,0,255), Color8(160,136,180,255), Color8(56,112,12,255), Color8(228,212,0,255), Color8(188,168,132,255), Color8(0,0,0,0)]
const ownershipColors = [Color8(132,44,0,255), Color8(136,112,148,255), Color8(52,96,4,255), Color8(188,156,0,255), Color8(180,160,124,255), Color8(0,0,0,0)]
const ownerFloorCol = [Color8(132,44,0,255), Color8(136,112,148,255), Color8(52,92,4,255), Color8(188,156,0,255), Color8(180,160,124,255), Color8(52,36,4,255)]
const ownerRoomCol = [Color8(156,48,0,255), Color8(160,136,180,255), Color8(56,112,12,255), Color8(228,212,0,255), Color8(188,168,132,255), Color8(0,0,0,0)]
const ownershipNames = ["Red","Blue","Green","Yellow","White","None"]

enum {
Expand Down
3 changes: 2 additions & 1 deletion Scenes/Camera2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ onready var oSelector = Nodelist.list["oSelector"]
onready var oUi = Nodelist.list["oUi"]
onready var oMain = Nodelist.list["oMain"]
onready var oScriptTextEdit = Nodelist.list["oScriptTextEdit"]
onready var oMapBrowser = Nodelist.list["oMapBrowser"]

signal zoom_level_changed

Expand Down Expand Up @@ -59,7 +60,7 @@ func _process(delta):
#Do not allow mouse window edge panning if window is unfocused
panDirectionMouse = Vector2(0,0)

if oUi.mouseOnUi == false and oScriptTextEdit.has_focus() == false:
if oUi.mouseOnUi == false and oScriptTextEdit.has_focus() == false and oMapBrowser.visible == false:
keyboard_pan()
else:
panDirectionKeyboard = Vector2(0,0)
Expand Down
4 changes: 2 additions & 2 deletions Scenes/InstanceOwnership.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ var materialInstanceOwnership = [
func _ready():
#print(materialInstanceOwnership)
for i in 6:
materialInstanceOwnership[i].set_shader_param("ownerCol", Constants.ownershipColors[i])
materialInstanceOwnership[i].set_shader_param("ownerCol", Constants.ownerRoomCol[i])
materialInstanceOwnership[i].set_shader_param("alphaFilled", 0.5)

func _process(delta):
for i in 6: # 0 to 5
materialInstanceOwnership[i].set_shader_param("fadeAlpha", 1.0-oOverheadOwnership.alphaFadeColor[i])
if i == 5:
materialInstanceOwnership[i].set_shader_param("ownerCol", Constants.ownershipColors[Random.choose([0,1,2,3])])
materialInstanceOwnership[i].set_shader_param("ownerCol", Constants.ownerRoomCol[Random.choose([0,1,2,3])])
18 changes: 15 additions & 3 deletions Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ extends Node2D
onready var oMessage = Nodelist.list["oMessage"]
onready var oDataSlab = Nodelist.list["oDataSlab"]
onready var oPlacingSettings = Nodelist.list["oPlacingSettings"]
onready var oDataClm = Nodelist.list["oDataClm"]
onready var oDataClmPos = Nodelist.list["oDataClmPos"]

var thingScn = preload("res://Scenes/ThingInstance.tscn")
var actionPointScn = preload("res://Scenes/ActionPointInstance.tscn")
Expand Down Expand Up @@ -208,10 +210,20 @@ func spawn(xSlab, ySlab, slabID, ownership, subtile, tngObj): # Spawns from tng
# 3: partnerArrow.texture = preload("res://Art/torchdir3.png")
# id.add_child(partnerArrow)

func delete_all_objects_on_slab(xSlab, ySlab):
for id in get_tree().get_nodes_in_group("Instance"):
func update_height_of_things_on_slab(xSlab, ySlab):
for id in get_tree().get_nodes_in_group("Thing"):
if id.locationX >= xSlab*3 and id.locationX < (xSlab+1) * 3 and id.locationY >= ySlab*3 and id.locationY < (ySlab+1) * 3:
id.queue_free()
if id.sensitiveTile == 65535: # None. Not attached to any slab.
var xSubtile = floor(id.locationX)
var ySubtile = floor(id.locationY)
var detectTerrainHeight = oDataClm.height[oDataClmPos.get_cell(xSubtile,ySubtile)]
id.locationZ = detectTerrainHeight

func delete_all_on_slab(xSlab, ySlab, arrayOfGroupNameStrings):
for groupName in arrayOfGroupNameStrings:
for id in get_tree().get_nodes_in_group(groupName):
if id.locationX >= xSlab*3 and id.locationX < (xSlab+1) * 3 and id.locationY >= ySlab*3 and id.locationY < (ySlab+1) * 3:
id.queue_free()

func get_node_on_subtile(nodegroup, xSubtile, ySubtile):
for id in get_tree().get_nodes_in_group(nodegroup):
Expand Down
12 changes: 9 additions & 3 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=154 format=2]
[gd_scene load_steps=156 format=2]

[ext_resource path="res://Scenes/SlabStyle.gd" type="Script" id=1]
[ext_resource path="res://Scenes/SlabPlacement.gd" type="Script" id=2]
Expand Down Expand Up @@ -35,6 +35,7 @@
[ext_resource path="res://Scenes/Message.gd" type="Script" id=33]
[ext_resource path="res://Scenes/ThingsOnSlabs.gd" type="Script" id=34]
[ext_resource path="res://Scenes/ConfirmDecompression.gd" type="Script" id=35]
[ext_resource path="res://Shaders/FlashNeutralRooms.gdshader" type="Shader" id=36]
[ext_resource path="res://Scenes/Editor.gd" type="Script" id=37]
[ext_resource path="res://Art/Wibble_2.png" type="Texture" id=38]
[ext_resource path="res://Scenes/DataClm.gd" type="Script" id=39]
Expand Down Expand Up @@ -221,6 +222,9 @@ shader_param/color3 = null
shader_param/color4 = null
shader_param/color5 = null

[sub_resource type="ShaderMaterial" id=20]
shader = ExtResource( 36 )

[sub_resource type="ShaderMaterial" id=9]
shader = ExtResource( 8 )
shader_param/zoom = 2.0
Expand Down Expand Up @@ -525,7 +529,8 @@ script = ExtResource( 114 )
script = ExtResource( 133 )
[node name="QuickMapPreview" type="Sprite" parent="Game2D"]
scale = Vector2( 100, 100 )
material = SubResource( 20 )
scale = Vector2( 96, 96 )
z_index = 100
centered = false
script = ExtResource( 136 )
Expand Down Expand Up @@ -1403,7 +1408,7 @@ custom_colors/font_color_hover = Color( 1, 0.65098, 0.556863, 1 )
custom_colors/font_color_pressed = Color( 0.333333, 0.607843, 1, 1 )
text = "Edit"
align = 0
items = [ "Map settings", null, 0, false, false, 0, 0, null, "", false, "Open map folder", null, 0, false, false, 1, 0, null, "", false, "Open script file", null, 0, false, false, 2, 0, null, "", false, "Column editor", null, 0, false, false, 3, 0, null, "", false, "Placement options", null, 0, false, false, 4, 0, null, "", false, "Update all slabs", null, 0, false, false, 5, 0, null, "", false, "Add custom object", null, 0, false, false, 6, 0, null, "", false, "Texture editing", null, 0, false, false, 7, 0, null, "", false, "Slabset", null, 0, false, false, 8, 0, null, "", false ]
items = [ "Map settings", null, 0, false, false, 0, 0, null, "", false, "Open map folder", null, 0, false, false, 1, 0, null, "", false, "Open script file", null, 0, false, false, 2, 0, null, "", false, "Column editor", null, 0, false, false, 3, 0, null, "", false, "Placement options", null, 0, false, false, 4, 0, null, "", false, "Update all slabs", null, 0, false, false, 5, 0, null, "", false, "Add custom object", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, true, -1, 0, null, "", true, "Texture editing", null, 0, false, false, 7, 0, null, "", false, "Slabset", null, 0, false, false, 8, 0, null, "", false ]
switch_on_hover = true
__meta__ = {
"_edit_use_anchors_": false
Expand Down Expand Up @@ -4882,6 +4887,7 @@ rounded = true
align = 1
script = ExtResource( 88 )

[connection signal="visibility_changed" from="Game2D/Selector" to="Game2D/Selector" method="_on_Selector_visibility_changed"]
[connection signal="pressed" from="Ui/Ui3D/Possess3DButton" to="Ui" method="_on_Possess3DButton_pressed"]
[connection signal="visibility_changed" from="Ui/UiTools/PickSlabWindow/SlabTabs/TabFolder/OnlyOwnership" to="Ui/UiTools/PickSlabWindow/SlabTabs/TabFolder/OnlyOwnership" method="_on_OnlyOwnership_visibility_changed"]
[connection signal="timeout" from="Ui/UiTools/PropertiesWindow/VBoxContainer/UniversalDetails/TimerUpdateColumnEntries" to="Ui/UiTools/PropertiesWindow/VBoxContainer/UniversalDetails" method="_on_TimerUpdateColumnEntries_timeout"]
Expand Down
6 changes: 5 additions & 1 deletion Scenes/MapBrowser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ onready var oConfirmDelete = Nodelist.list["oConfirmDelete"]
onready var oBrowserFilename = Nodelist.list["oBrowserFilename"]
onready var oUi = Nodelist.list["oUi"]
onready var oQuickMapPreview = Nodelist.list["oQuickMapPreview"]
onready var oSelector = Nodelist.list["oSelector"]

func _ready():
oBrowserFilename.text = oGame.GAME_DIRECTORY
Expand Down Expand Up @@ -53,8 +54,10 @@ func _on_DynamicMapTree_item_selected():
# oDateSaved.text = convert_unix_time_to_readable(modifiedTime) #'Last modified: '+
# file.close()

oQuickMapPreview.visible = true
oQuickMapPreview.update_img(path)
else:
oQuickMapPreview.visible = false
oBrowseOpenButton.visible = false
#oBrowsePlayButton.visible = false
# "Directory" modified time is not shown
Expand Down Expand Up @@ -128,9 +131,10 @@ func _on_MapBrowser_visibility_changed():
if is_instance_valid(oUi) == false: return
if visible == true:
oUi.hide_tools()
oQuickMapPreview.visible = true
else:
oUi.show_tools()

oQuickMapPreview.visible = false

func _on_BrowsePlayButton_pressed():
pass # Replace with function body.
Expand Down
2 changes: 1 addition & 1 deletion Scenes/OnlyOwnership.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func initialize_grid_items():
id.set_meta("ownershipID",i)
id.set_meta("grid_item_text",Constants.ownershipNames[i])

#var col = Constants.ownershipColors[i]
#var col = Constants.ownerRoomCol[i]
if i == oSelection.paintOwnership:
id.pressed = true

Expand Down
22 changes: 11 additions & 11 deletions Scenes/OverheadOwnership.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ onready var mat = oColorRectSlabOwner.get_material()

func _ready():
slabOwnershipImage.create(85,85,false,Image.FORMAT_RGBA8)
mat.set_shader_param("color0", Constants.ownershipColors[0])
mat.set_shader_param("color1", Constants.ownershipColors[1])
mat.set_shader_param("color2", Constants.ownershipColors[2])
mat.set_shader_param("color3", Constants.ownershipColors[3])
mat.set_shader_param("color4", Constants.ownershipColors[4])
mat.set_shader_param("color5", Constants.ownershipColors[5])
mat.set_shader_param("color0", Constants.ownerRoomCol[0])
mat.set_shader_param("color1", Constants.ownerRoomCol[1])
mat.set_shader_param("color2", Constants.ownerRoomCol[2])
mat.set_shader_param("color3", Constants.ownerRoomCol[3])
mat.set_shader_param("color4", Constants.ownerRoomCol[4])
mat.set_shader_param("color5", Constants.ownerRoomCol[5])

set_ownership_alpha_graphics(OWNERSHIP_ALPHA)

Expand All @@ -39,15 +39,15 @@ func set_ownership_alpha_graphics(value):
oInstanceOwnership.materialInstanceOwnership[i].set_shader_param("alphaFilled", value)

func clear():
slabOwnershipImage.fill(Constants.ownershipColors[5])
slabOwnershipImage.fill(Constants.ownerRoomCol[5])
slabOwnershipTexture.create_from_image(slabOwnershipImage, 0)

func start():
# Read ownership data as pixels
slabOwnershipImage.lock()
for ySlab in 85:
for xSlab in 85:
var setValue = Constants.ownershipColors[oDataOwnership.get_cell(xSlab,ySlab)]
var setValue = Constants.ownerRoomCol[oDataOwnership.get_cell(xSlab,ySlab)]
slabOwnershipImage.set_pixel(xSlab, ySlab, setValue)
slabOwnershipImage.unlock()

Expand All @@ -56,7 +56,7 @@ func start():

func ownership_update_shape(shapePositionArray, ownership):

var setColour = Constants.ownershipColors[ownership]
var setColour = Constants.ownerRoomCol[ownership]

slabOwnershipImage.lock()
for pos in shapePositionArray:
Expand All @@ -77,7 +77,7 @@ func ownership_update_things(shapePositionArray, paintOwnership):
# rectStart = Vector2(clamp(rectStart.x, 0, 84), clamp(rectStart.y, 0, 84))
# rectEnd = Vector2(clamp(rectEnd.x, 0, 84), clamp(rectEnd.y, 0, 84))
#
# var setColour = Constants.ownershipColors[ownership]
# var setColour = Constants.ownerRoomCol[ownership]
#
# slabOwnershipImage.lock()
# for ySlab in range(rectStart.y, rectEnd.y+1):
Expand All @@ -104,7 +104,7 @@ func _process(delta):
mat.set_shader_param("cursorOnColor", cursorOnColor)

for i in 6:
if cursorOnColor == Constants.ownershipColors[i]:
if cursorOnColor == Constants.ownerRoomCol[i]:
alphaFadeColor[i] = lerp(alphaFadeColor[i], 1.00, fadeSpeed*delta)
else:
alphaFadeColor[i] = lerp(alphaFadeColor[i], 0.00, fadeSpeed*delta)
Expand Down
13 changes: 10 additions & 3 deletions Scenes/PositionEditor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ onready var oLineEditY = $"HBoxContainer1/LineEditY"
onready var oLineEditZ = $"HBoxContainer2/LineEditZ"

func set_txt(array):
if array.size() >= 1: $"HBoxContainer1/LineEditX".text = str(array[0])
if array.size() >= 2: $"HBoxContainer1/LineEditY".text = str(array[1])
if array.size() >= 3: $"HBoxContainer2/LineEditZ".text = str(array[2])
if array.size() >= 1:
$"HBoxContainer1/LineEditX".text = str(array[0])
if array.size() >= 2:
$"HBoxContainer1/LineEditY".text = str(array[1])


if array.size() >= 3:
$"HBoxContainer2/LineEditZ".text = str(array[2])
else:
$"HBoxContainer2".visible = false # For Action Point, don't display Z field

#$LinEditX.hint_tooltip =

Expand Down
3 changes: 0 additions & 3 deletions Scenes/PositionEditor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HBoxContainer1" type="HBoxContainer" parent="."]
margin_right = 1024.0
Expand Down
Loading

0 comments on commit 2e6b060

Please sign in to comment.