Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Oct 18, 2023
1 parent 994e891 commit 4a62f03
Show file tree
Hide file tree
Showing 117 changed files with 610 additions and 610 deletions.
4 changes: 2 additions & 2 deletions AutoLoad/Utils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func _ready():
noSpecialCharsRegex.compile("[^a-zA-Z0-9]")

func strip_special_chars_from_string(input_string: String) -> String:
var output_string = noSpecialCharsRegex.sub(input_string, "", true)
return output_string
var output_string = noSpecialCharsRegex.sub(input_string, "", true)
return output_string

func strip_letters_from_string(string):
for character in string:
Expand Down
24 changes: 12 additions & 12 deletions Scenes/ActionPointInstance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ var pointNumber = null setget set_pointNumber
var data7 = null

func set_location_x(setVal):
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationX = setVal
position.x = locationX * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationX = setVal
position.x = locationX * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))

func set_location_y(setVal):
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationY = setVal
position.y = locationY * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationY = setVal
position.y = locationY * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))

func set_location_z(setVal): # This is actually unused for action points, but its presence fixes errors
locationZ = setVal
Expand Down
50 changes: 25 additions & 25 deletions Scenes/Camera2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ func _ready():
reset_camera(M.xSize, M.ySize)

func reset_camera(x, y):
# Add 2 units for the border
x += 2
y += 2
# Calculate the width and height of the map in pixels
var mapWidthInPixels = x * 96
var mapHeightInPixels = y * 96

# Center the camera on the map, adjusting for the border
offset = Vector2(mapWidthInPixels, mapHeightInPixels) * Vector2(0.5, 0.5) - Vector2(96, 96) # Subtracting one unit (96 pixels) to center the map with the border
desired_offset = offset

# Determine the zoom levels required to fit the map's width and height within the viewport
var zoomForWidth = mapWidthInPixels / OS.window_size.x
var zoomForHeight = mapHeightInPixels / OS.window_size.y

# Set the zoom level to the maximum of the two calculated zoom levels to ensure the entire map fits within the viewport
var initialZoom = max(zoomForWidth, zoomForHeight) * Settings.UI_SCALE.y
zoom = Vector2(initialZoom, initialZoom)
desired_zoom = zoom

# Notify other nodes about the zoom level change
yield(get_tree(), 'idle_frame')
for id in get_tree().get_nodes_in_group("Thing"):
id._on_zoom_level_changed(zoom)
# Add 2 units for the border
x += 2
y += 2
# Calculate the width and height of the map in pixels
var mapWidthInPixels = x * 96
var mapHeightInPixels = y * 96

# Center the camera on the map, adjusting for the border
offset = Vector2(mapWidthInPixels, mapHeightInPixels) * Vector2(0.5, 0.5) - Vector2(96, 96) # Subtracting one unit (96 pixels) to center the map with the border
desired_offset = offset

# Determine the zoom levels required to fit the map's width and height within the viewport
var zoomForWidth = mapWidthInPixels / OS.window_size.x
var zoomForHeight = mapHeightInPixels / OS.window_size.y

# Set the zoom level to the maximum of the two calculated zoom levels to ensure the entire map fits within the viewport
var initialZoom = max(zoomForWidth, zoomForHeight) * Settings.UI_SCALE.y
zoom = Vector2(initialZoom, initialZoom)
desired_zoom = zoom

# Notify other nodes about the zoom level change
yield(get_tree(), 'idle_frame')
for id in get_tree().get_nodes_in_group("Thing"):
id._on_zoom_level_changed(zoom)



Expand Down
24 changes: 12 additions & 12 deletions Scenes/LightInstance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ var data18 = null
var data19 = null

func set_location_x(setVal):
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationX = setVal
position.x = locationX * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationX = setVal
position.x = locationX * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))

func set_location_y(setVal):
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationY = setVal
position.y = locationY * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationY = setVal
position.y = locationY * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))

func set_location_z(setVal):
locationZ = setVal
Expand Down
14 changes: 7 additions & 7 deletions Scenes/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,28 @@ func construct_shape_for_placement(constructType):
shapePositionArray.append(newPos)
CONSTRUCT_FILL:
var beginTile = oSelector.world2tile(get_global_mouse_position())
# Prevent clicking outside
# Prevent clicking outside
if beginTile.x < oEditor.fieldBoundary.position.x: return
if beginTile.x > oEditor.fieldBoundary.end.x-1: return
if beginTile.y < oEditor.fieldBoundary.position.y: return
if beginTile.y > oEditor.fieldBoundary.end.y-1: return
var coordsToCheck = [beginTile]
var fillTargetID = oSelector.get_slabID_at_pos(oSelector.cursorTile)
var checkedCoords = {} # Use a dictionary to mimic set behavior for checked coordinates
var preventFillingBorder = false
if fillTargetID == Slabs.ROCK:
preventFillingBorder = true

while coordsToCheck.size() > 0:
var coord = coordsToCheck.pop_back()
if coord in checkedCoords: # Skip if already checked
continue
checkedCoords[coord] = true
if preventFillingBorder:
if coord.x < oEditor.fieldBoundary.position.x: continue
if coord.x > oEditor.fieldBoundary.end.x-1: continue
Expand All @@ -198,7 +198,7 @@ func construct_shape_for_placement(constructType):

if oSelector.get_slabID_at_pos(coord) == fillTargetID:
shapePositionArray.append(coord)
var neighbors = [coord + Vector2(0,1), coord + Vector2(0,-1), coord + Vector2(1,0), coord + Vector2(-1,0)]
for neighbor in neighbors:
if not checkedCoords.has(neighbor):
Expand Down
2 changes: 1 addition & 1 deletion Scenes/SourceMapTree.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func add_directory_contents(dir, treeItem):
else:
itemsToAdd.append(["file", pathString, treeItem])

# Now, add the items to the Tree in one batch
# Now, add the items to the Tree in one batch
for itemData in itemsToAdd:
var itemType = itemData[0]
var pathString = itemData[1]
Expand Down
24 changes: 12 additions & 12 deletions Scenes/ThingInstance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,20 @@ func _exit_tree():


func set_location_x(setVal):
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationX = setVal
position.x = locationX * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationX = setVal
position.x = locationX * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))

func set_location_y(setVal):
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationY = setVal
position.y = locationY * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
if locationX != null and locationY != null:
remove_from_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))
locationY = setVal
position.y = locationY * 32
if locationX != null and locationY != null:
add_to_group("slab_location_group_" + str(floor(locationX/3)) + '_' + str(floor(locationY/3)))


func set_location_z(setVal):
Expand Down
2 changes: 1 addition & 1 deletion Scenes/TwoColumnData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func _on_optionbutton_item_selected(indexSelected, leftString):
var inst = oInspector.inspectingInstance
var property_name = ""
var value
match leftString:
"Ownership":
oSelection.paintOwnership = indexSelected
Expand Down
Loading

0 comments on commit 4a62f03

Please sign in to comment.