Skip to content

Commit

Permalink
Disable the ownership icons for collectibles when placing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Apr 8, 2024
1 parent 8db185c commit afa3ce3
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 28 deletions.
11 changes: 8 additions & 3 deletions Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ enum TYPE {
EXTRA = 696969
}


var data_structure_name = {
TYPE.NONE: "Empty",
TYPE.OBJECT: "Object",
Expand All @@ -41,6 +40,7 @@ var data_structure_name = {
TYPE.CAVEIN: "CaveIn",
TYPE.EXTRA: "Extra"
}

var reverse_data_structure_name = {
"Empty": TYPE.NONE,
"Object":TYPE.OBJECT,
Expand All @@ -59,8 +59,6 @@ var reverse_data_structure_name = {
"Extra":TYPE.EXTRA,
}



enum {
NAME = 0
KEEPERFX_NAME = 1
Expand Down Expand Up @@ -400,6 +398,13 @@ enum SPELLBOOK {
DESTROY_WALLS = 47
}

var genre_belonging = {
TAB_GOLD : Slabs.TREASURE_ROOM,
TAB_SPELL : Slabs.LIBRARY,
TAB_SPECIAL : Slabs.LIBRARY,
TAB_BOX : Slabs.WORKSHOP,
}

#OBJECT = 1
#CREATURE = 5
#EFFECT = 7
Expand Down
11 changes: 3 additions & 8 deletions Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,12 @@ func manage_things_on_slab(xSlab, ySlab, slabID, ownership):
on_slab_delete_stray_door_thing_and_key(id, slabID)
on_slab_set_belongings_ownership(id, slabID, ownership)

var genre_belonging = {
Things.TAB_GOLD : Slabs.TREASURE_ROOM,
Things.TAB_SPELL : Slabs.LIBRARY,
Things.TAB_SPECIAL : Slabs.LIBRARY,
Things.TAB_BOX : Slabs.WORKSHOP,
}

func on_slab_set_belongings_ownership(id, slabID, ownership):
if id.thingType == Things.TYPE.OBJECT:
var genre = Things.DATA_OBJECT[id.subtype][Things.EDITOR_TAB]
if genre_belonging.has(genre):
if slabID == genre_belonging[genre]:
if Things.genre_belonging.has(genre):
if slabID == Things.genre_belonging[genre]:
id.ownership = ownership
else:
id.ownership = 5
Expand Down
9 changes: 9 additions & 0 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,15 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="CollectibleLabel" type="Label" parent="Ui/UiTools/PropertiesWindow/VBoxContainer/PropertiesTabs/PlacingSettings/OwnerSelection"]
visible = false
margin_top = 9.0
margin_right = 40.0
margin_bottom = 30.0
hint_tooltip = "Collectibles have their ownership set to Neutral unless placed in their specified room: Gold in Treasury, Boxes in Workshop, Specials/Spells in Library."
mouse_filter = 1
text = "Collectible"
[node name="Control" type="Control" parent="Ui/UiTools/PropertiesWindow/VBoxContainer/PropertiesTabs/PlacingSettings/OwnerSelection"]
margin_top = 42.0
margin_right = 276.0
Expand Down
34 changes: 30 additions & 4 deletions Scenes/OwnerSelection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ onready var oOnlyOwnership = Nodelist.list["oOnlyOwnership"]
onready var oUseSlabOwnerCheckBox = Nodelist.list["oUseSlabOwnerCheckBox"]
onready var oOwnershipGridContainer = Nodelist.list["oOwnershipGridContainer"]
onready var oMirrorOptions = Nodelist.list["oMirrorOptions"]
onready var oCollectibleLabel = Nodelist.list["oCollectibleLabel"]

#onready var oEditor = Nodelist.list["oEditor"]
onready var gridItemScene = preload("res://Scenes/GenericGridItem.tscn")
Expand All @@ -15,6 +16,8 @@ onready var oCenteredLabel = $Control/CenteredLabel
#
var owner_order = [0,1,2,3,4,5]

var ownership_available = true

func _ready():
for i in owner_order:
var id = gridItemScene.instance()
Expand Down Expand Up @@ -46,8 +49,9 @@ func add_child_to_grid(id, set_text):

func pressed(id):
var setValue = id.get_meta("grid_value")
if oUseSlabOwnerCheckBox.pressed == true and oUseSlabOwnerCheckBox.visible == true:
#setValue = 5
if oCollectibleLabel.visible == true:
return
elif oUseSlabOwnerCheckBox.pressed == true and oUseSlabOwnerCheckBox.visible == true:
oUseSlabOwnerCheckBox.pressed = false
oSelection.paintOwnership = setValue
set_selection(setValue)
Expand All @@ -59,10 +63,12 @@ func _process(delta): # It's necessary to use _process to update selection, beca
func update_selection():
if oSelectedRect == null: return
if is_instance_valid(oSelectedRect.boundToItem) == false: return
# If checkbox is checked then don't do anything
if oUseSlabOwnerCheckBox.pressed == true and oUseSlabOwnerCheckBox.visible == true:

# If greyed out then don't do anything
if ownership_available == false:
oSelectedRect.visible = false
return

oSelectedRect.visible = true
oSelectedRect.rect_global_position = oSelectedRect.boundToItem.rect_global_position
oSelectedRect.rect_size = oSelectedRect.boundToItem.rect_size
Expand All @@ -87,6 +93,26 @@ func set_selection(value):
if id.get_meta("grid_value") == value:
oSelectedRect.boundToItem = id

func collectible_ownership_mode(collMode):
if collMode == true:
oCollectibleLabel.visible = true
oUseSlabOwnerCheckBox.visible = false
else:
oCollectibleLabel.visible = false
oUseSlabOwnerCheckBox.visible = true
update_ownership_available()

func update_ownership_available():
ownership_available = true
oOwnershipGridContainer.modulate.a = 1.00

if oCollectibleLabel.visible == true:
ownership_available = false
oOwnershipGridContainer.modulate.a = 0.25
elif oUseSlabOwnerCheckBox.visible == true and oUseSlabOwnerCheckBox.pressed == true:
ownership_available = false
oOwnershipGridContainer.modulate.a = 0.25


#
#func clear_grid():
Expand Down
7 changes: 7 additions & 0 deletions Scenes/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ func newPaintSubtype(value):
oSelector.change_mode(oSelector.MODE_SUBTILE)
oPickSlabWindow.set_selection(null) # Deselect anything in slab window
paintSubtype = value

oOwnerSelection.collectible_ownership_mode(false)
if paintThingType == Things.TYPE.OBJECT:
var genre = Things.DATA_OBJECT[paintSubtype][Things.EDITOR_TAB]
if Things.genre_belonging.has(genre):
oOwnerSelection.collectible_ownership_mode(true)


func newOwnership(value):
oUi.update_theme_colour(value)
Expand Down
9 changes: 3 additions & 6 deletions Scenes/SlabOwnerCheckBox.gd
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
extends CheckBox
onready var oOwnerSelection = Nodelist.list["oOwnerSelection"]
onready var oOwnershipGridContainer = Nodelist.list["oOwnershipGridContainer"]

func _on_UseSlabOwnerCheckBox_toggled(button_pressed):
if button_pressed == true and visible == true:
oOwnershipGridContainer.modulate = Color(1,1,1,0.25)
else:
oOwnershipGridContainer.modulate = Color(1,1,1,1.00)

oOwnerSelection.update_ownership_available()

func _on_UseSlabOwnerCheckBox_visibility_changed():
yield(get_tree(),'idle_frame')
_on_UseSlabOwnerCheckBox_toggled(pressed)
oOwnerSelection.update_ownership_available()
14 changes: 7 additions & 7 deletions Scenes/WriteData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ func write_slb(buffer):
buffer.put_8(0)

func write_own(buffer):
var dataHeight = (M.ySize*3)+1
var dataWidth = (M.xSize*3)+1
for subtileY in dataHeight:
for subtileX in dataWidth:
buffer.seek(subtileX + (subtileY*dataWidth))
value = oDataOwnership.get_cell(subtileX/3,subtileY/3)
buffer.put_8(value)
var dataHeight = (M.ySize * 3) + 1
var dataWidth = (M.xSize * 3) + 1
var size = dataHeight * dataWidth
for i in size:
var subtileX = i % dataWidth
var subtileY = i / dataWidth
buffer.put_8(oDataOwnership.get_cell(subtileX / 3, subtileY / 3))

func write_tng(buffer):
var numberOfTngEntries = get_tree().get_nodes_in_group("Thing").size()
Expand Down

0 comments on commit afa3ce3

Please sign in to comment.