Skip to content

Commit

Permalink
Merge pull request #262 from klingbolt/godot_texture_id
Browse files Browse the repository at this point in the history
Updated gdscript to reflect changes to texture field in proto
  • Loading branch information
AsherGlick authored Jan 3, 2024
2 parents 2fa4415 + 00e35ee commit 622a391
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 71 deletions.
12 changes: 6 additions & 6 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ func _waypoint_categories_to_godot_nodes(item: TreeItem, waypoint_category: Wayp
print("Warning: Trail ", category_name, " does not have equal number of X, Y, and Z coordinates.")
for index in range(0, trail_data.get_points_z().size()):
path_points.append(Vector3(trail_data.get_points_x()[index], trail_data.get_points_y()[index], trail_data.get_points_z()[index]))
var texture_path = path.get_texture_path()
if texture_path == null:
var texture_id = path.get_texture_id()
if texture_id == null:
print("Warning: No texture found in " , category_name)
continue
var full_texture_path = self.marker_file_dir + texture_path.get_path()
var full_texture_path = self.marker_file_dir + self.waypoint_data.get_textures()[texture_id].get_filepath()
gen_new_path(path_points, full_texture_path, path, category_item)


Expand All @@ -551,11 +551,11 @@ func _waypoint_categories_to_godot_nodes(item: TreeItem, waypoint_category: Wayp
print("Warning: No position found for icon ", category_name)
continue
var position_vector = Vector3(position.get_x(), position.get_y(), position.get_z())
var texture_path = icon.get_texture_path()
if texture_path == null:
var texture_id = icon.get_texture_id()
if texture_id == null:
print("Warning: No texture found in " , category_name)
continue
var full_texture_path = self.marker_file_dir + texture_path.get_path()
var full_texture_path = self.marker_file_dir + self.waypoint_data.get_textures()[texture_id].get_filepath()
gen_new_icon(position_vector, full_texture_path, icon, category_item)

for category_child in waypoint_category.get_children():
Expand Down
143 changes: 78 additions & 65 deletions waypoint.gd
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,12 @@ class Waypoint:
service.func_ref = funcref(self, "add_category")
data[_category.tag] = service

_textures = PBField.new("textures", PB_DATA_TYPE.MESSAGE, PB_RULE.REPEATED, 2, true, [])
service = PBServiceField.new()
service.field = _textures
service.func_ref = funcref(self, "add_textures")
data[_textures.tag] = service

var data = {}

var _category: PBField
Expand All @@ -683,6 +689,58 @@ class Waypoint:
_category.value.append(element)
return element

var _textures: PBField
func get_textures() -> Array:
return _textures.value
func clear_textures() -> void:
data[2].state = PB_SERVICE_STATE.UNFILLED
_textures.value = []
func add_textures() -> TextureData:
var element = TextureData.new()
_textures.value.append(element)
return element

func to_string() -> String:
return PBPacker.message_to_string(data)

func to_bytes() -> PoolByteArray:
return PBPacker.pack_message(data)

func from_bytes(bytes : PoolByteArray, offset : int = 0, limit : int = -1) -> int:
var cur_limit = bytes.size()
if limit != -1:
cur_limit = limit
var result = PBPacker.unpack_message(data, bytes, offset, cur_limit)
if result == cur_limit:
if PBPacker.check_required(data):
if limit == -1:
return PB_ERR.NO_ERRORS
else:
return PB_ERR.REQUIRED_FIELDS
elif limit == -1 && result > 0:
return PB_ERR.PARSE_INCOMPLETE
return result

class TextureData:
func _init():
var service

_filepath = PBField.new("filepath", PB_DATA_TYPE.STRING, PB_RULE.OPTIONAL, 1, true, DEFAULT_VALUES_3[PB_DATA_TYPE.STRING])
service = PBServiceField.new()
service.field = _filepath
data[_filepath.tag] = service

var data = {}

var _filepath: PBField
func get_filepath() -> String:
return _filepath.value
func clear_filepath() -> void:
data[1].state = PB_SERVICE_STATE.UNFILLED
_filepath.value = DEFAULT_VALUES_3[PB_DATA_TYPE.STRING]
func set_filepath(value : String) -> void:
_filepath.value = value

func to_string() -> String:
return PBPacker.message_to_string(data)

Expand Down Expand Up @@ -842,11 +900,10 @@ class Icon:
func _init():
var service

_texture_path = PBField.new("texture_path", PB_DATA_TYPE.MESSAGE, PB_RULE.OPTIONAL, 2, true, DEFAULT_VALUES_3[PB_DATA_TYPE.MESSAGE])
_texture_id = PBField.new("texture_id", PB_DATA_TYPE.UINT32, PB_RULE.OPTIONAL, 2, true, DEFAULT_VALUES_3[PB_DATA_TYPE.UINT32])
service = PBServiceField.new()
service.field = _texture_path
service.func_ref = funcref(self, "new_texture_path")
data[_texture_path.tag] = service
service.field = _texture_id
data[_texture_id.tag] = service

_guid = PBField.new("guid", PB_DATA_TYPE.BYTES, PB_RULE.OPTIONAL, 3, true, DEFAULT_VALUES_3[PB_DATA_TYPE.BYTES])
service = PBServiceField.new()
Expand Down Expand Up @@ -1020,15 +1077,14 @@ class Icon:

var data = {}

var _texture_path: PBField
func get_texture_path() -> TexturePath:
return _texture_path.value
func clear_texture_path() -> void:
var _texture_id: PBField
func get_texture_id() -> int:
return _texture_id.value
func clear_texture_id() -> void:
data[2].state = PB_SERVICE_STATE.UNFILLED
_texture_path.value = DEFAULT_VALUES_3[PB_DATA_TYPE.MESSAGE]
func new_texture_path() -> TexturePath:
_texture_path.value = TexturePath.new()
return _texture_path.value
_texture_id.value = DEFAULT_VALUES_3[PB_DATA_TYPE.UINT32]
func set_texture_id(value : int) -> void:
_texture_id.value = value

var _guid: PBField
func get_guid() -> PoolByteArray:
Expand Down Expand Up @@ -1353,11 +1409,10 @@ class Trail:
func _init():
var service

_texture_path = PBField.new("texture_path", PB_DATA_TYPE.MESSAGE, PB_RULE.OPTIONAL, 2, true, DEFAULT_VALUES_3[PB_DATA_TYPE.MESSAGE])
_texture_id = PBField.new("texture_id", PB_DATA_TYPE.UINT32, PB_RULE.OPTIONAL, 2, true, DEFAULT_VALUES_3[PB_DATA_TYPE.UINT32])
service = PBServiceField.new()
service.field = _texture_path
service.func_ref = funcref(self, "new_texture_path")
data[_texture_path.tag] = service
service.field = _texture_id
data[_texture_id.tag] = service

_guid = PBField.new("guid", PB_DATA_TYPE.BYTES, PB_RULE.OPTIONAL, 3, true, DEFAULT_VALUES_3[PB_DATA_TYPE.BYTES])
service = PBServiceField.new()
Expand Down Expand Up @@ -1499,15 +1554,14 @@ class Trail:

var data = {}

var _texture_path: PBField
func get_texture_path() -> TexturePath:
return _texture_path.value
func clear_texture_path() -> void:
var _texture_id: PBField
func get_texture_id() -> int:
return _texture_id.value
func clear_texture_id() -> void:
data[2].state = PB_SERVICE_STATE.UNFILLED
_texture_path.value = DEFAULT_VALUES_3[PB_DATA_TYPE.MESSAGE]
func new_texture_path() -> TexturePath:
_texture_path.value = TexturePath.new()
return _texture_path.value
_texture_id.value = DEFAULT_VALUES_3[PB_DATA_TYPE.UINT32]
func set_texture_id(value : int) -> void:
_texture_id.value = value

var _guid: PBField
func get_guid() -> PoolByteArray:
Expand Down Expand Up @@ -1772,47 +1826,6 @@ class Trail:
return PB_ERR.PARSE_INCOMPLETE
return result

class TexturePath:
func _init():
var service

_path = PBField.new("path", PB_DATA_TYPE.STRING, PB_RULE.OPTIONAL, 1, true, DEFAULT_VALUES_3[PB_DATA_TYPE.STRING])
service = PBServiceField.new()
service.field = _path
data[_path.tag] = service

var data = {}

var _path: PBField
func get_path() -> String:
return _path.value
func clear_path() -> void:
data[1].state = PB_SERVICE_STATE.UNFILLED
_path.value = DEFAULT_VALUES_3[PB_DATA_TYPE.STRING]
func set_path(value : String) -> void:
_path.value = value

func to_string() -> String:
return PBPacker.message_to_string(data)

func to_bytes() -> PoolByteArray:
return PBPacker.pack_message(data)

func from_bytes(bytes : PoolByteArray, offset : int = 0, limit : int = -1) -> int:
var cur_limit = bytes.size()
if limit != -1:
cur_limit = limit
var result = PBPacker.unpack_message(data, bytes, offset, cur_limit)
if result == cur_limit:
if PBPacker.check_required(data):
if limit == -1:
return PB_ERR.NO_ERRORS
else:
return PB_ERR.REQUIRED_FIELDS
elif limit == -1 && result > 0:
return PB_ERR.PARSE_INCOMPLETE
return result

class RGBAColor:
func _init():
var service
Expand Down

0 comments on commit 622a391

Please sign in to comment.