Skip to content

Commit

Permalink
Added extra ID/Name entry to Properties window, adjust font size base…
Browse files Browse the repository at this point in the history
…d on largest word
  • Loading branch information
rainlizard committed May 16, 2024
1 parent 1455093 commit bfc063c
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 70 deletions.
13 changes: 13 additions & 0 deletions Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ func fetch_name(thing_type, sub_type):
else:
return "Unknown Thingtype " + str(thing_type) + ", Subtype: " + str(sub_type)

func fetch_id_string(thing_type, sub_type):
var data_structure = data_structure(thing_type)
var sub_type_data = data_structure.get(sub_type)
if sub_type_data:
var nameId = sub_type_data[NAME_ID]
if nameId is String:
return nameId
elif nameId is Array: # This is to take into considersation someone accidentally using two words with spaces as an object name. (otherwise we get a crash)
return nameId[0].capitalize()
return "Error1337"
else:
return "Unknown " + data_structure_name[thing_type] + " Subtype: " + str(sub_type)


var data_structure_name = {
TYPE.NONE: "Empty",
Expand Down
2 changes: 2 additions & 0 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ enum {
}

func start(mapPath):

if Cube.tex.empty():
Cube.read_cubes_cfg()

var CODETIME_LOADCFG_START = OS.get_ticks_msec()

Things.reset_thing_data_to_default()

var campaign_cfg = load_campaign_data(mapPath)

var config_dirs = {
Expand Down
4 changes: 2 additions & 2 deletions Scenes/CurrentTextures.gd
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ func convert_img_to_two_texture_arrays(img):


func set_current_texture_pack():
var value = oDataLevelStyle.data

var value = oDataLevelStyle.data
if cachedTextures.empty() == true:
oMessage.big("Error", "One or more tilesets failed to load. Try pressing the [Reload tileset cache] button in File->Preferences and then reopen the map.")
return
if cachedTextures[value] == null or cachedTextures[value][0] == null or cachedTextures[value][1] == null:
if value < cachedTextures.size() == false or cachedTextures[value] == null or cachedTextures[value][0] == null or cachedTextures[value][1] == null:
oMessage.big("Error", "Unable to load tileset number " + str(value) + ". Try pressing the [Reload tileset cache] button in File->Preferences.")
return

Expand Down
4 changes: 2 additions & 2 deletions Scenes/OpenMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func continue_load(map):
oScriptEditor.initialize_for_new_map()
oOverheadOwnership.start()
oScriptHelpers.start()

# update_editor_data
if Slabset.dat.empty() == true:
Slabset.load_default_slabset()
Expand All @@ -204,7 +204,7 @@ func continue_load(map):
oOverheadGraphics.update_full_overhead_map(oOverheadGraphics.MULTI_THREADED)

oDataClm.count_filled_clm_entries()

oTextureCache.set_current_texture_pack()

# finalize_map_opening
Expand Down
39 changes: 20 additions & 19 deletions Scenes/PlacingSettings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ var orientation = 0
var goldValue = 0

enum FIELDS {
ID
TYPE
SUBTYPE
NAME_ID
THINGTYPE
OWNERSHIP
EFFECT_RANGE
CREATURE_LEVEL
Expand Down Expand Up @@ -68,51 +69,51 @@ func update_placing_tab():
var availableFields = []
match thingType:
Things.TYPE.NONE:
availableFields = [FIELDS.ID]
availableFields = [FIELDS.SUBTYPE]
Things.TYPE.OBJECT:
availableFields = [FIELDS.ID, FIELDS.TYPE]
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE]
if subtype == 133: #Mysterious Box
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.CUSTOM_BOX_ID]
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.CUSTOM_BOX_ID]
if oCurrentFormat.selected != 0: # Classic format
availableFields.append(FIELDS.ORIENTATION)
Things.TYPE.CREATURE:
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.CREATURE_LEVEL]
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.CREATURE_LEVEL]
if oCurrentFormat.selected != 0: # Classic format
availableFields.append(FIELDS.INITIAL_HEALTH)
availableFields.append(FIELDS.CREATURE_GOLD)
availableFields.append(FIELDS.CREATURE_NAME)
#availableFields.append(FIELDS.ORIENTATION)
Things.TYPE.EFFECTGEN:
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.EFFECT_RANGE, FIELDS.ORIENTATION]
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.EFFECT_RANGE, FIELDS.ORIENTATION]
if oCurrentFormat.selected != 0: # Classic format
availableFields.append(FIELDS.ORIENTATION)
Things.TYPE.TRAP:
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.ORIENTATION]
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.ORIENTATION]
if oCurrentFormat.selected != 0: # Classic format
availableFields.append(FIELDS.ORIENTATION)
Things.TYPE.DOOR:
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.DOOR_LOCKED]
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.DOOR_LOCKED]
Things.TYPE.EXTRA:
match subtype:
1:
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.POINT_RANGE] # Action point
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.POINT_RANGE] # Action point
2:
availableFields = [FIELDS.ID, FIELDS.TYPE, FIELDS.LIGHT_RANGE, FIELDS.LIGHT_INTENSITY] # Light
availableFields = [FIELDS.SUBTYPE, FIELDS.NAME_ID, FIELDS.THINGTYPE, FIELDS.LIGHT_RANGE, FIELDS.LIGHT_INTENSITY] # Light

for i in FIELDS.size():
var description = null
var value = null
if i in availableFields:
match i:
FIELDS.ID:
description = "ID"
FIELDS.SUBTYPE:
description = "Name"
value = Things.fetch_name(thingType, subtype)
FIELDS.TYPE:
FIELDS.NAME_ID:
description = "ID"
value = Things.fetch_id_string(thingType, subtype)
FIELDS.THINGTYPE:
description = "Type"
value = oThingDetails.retrieve_subtype_value(thingType, subtype)
# FIELDS.OWNERSHIP:
# description = "Ownership"
# value = Constants.ownershipNames[ownership]
value = Things.data_structure_name.get(thingType, "Unknown") + " : " + str(subtype)
FIELDS.EFFECT_RANGE:
description = "Effect range" # 9-10
value = effectRange
Expand All @@ -135,7 +136,7 @@ func update_placing_tab():
description = "Custom box" # 14
value = boxNumber
FIELDS.CREATURE_NAME:
description = "Name" #Creature name
description = "Unique name"
value = creatureName
FIELDS.CREATURE_GOLD:
description = "Gold held"
Expand Down
65 changes: 29 additions & 36 deletions Scenes/ThingDetails.gd
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,29 @@ func light_details(id):


func thing_details(id):
for i in 16:
for i in 17:
var description = null
var value = null
match i:
0:
description = "ID"
description = "Name"
value = Things.fetch_name(id.thingType, id.subtype)
1:
description = "Type"
value = retrieve_subtype_value(id.thingType, id.subtype)
description = "ID"
value = Things.fetch_id_string(id.thingType, id.subtype)
2:
description = "Type"
value = Things.data_structure_name.get(id.thingType, "Unknown") + " : " + str(id.subtype)
3:
description = "Position"
value = str(id.locationX)+' '+str(id.locationY)+' '+str(id.locationZ)
3:
4:
description = "Ownership"
value = Constants.ownershipNames[id.ownership]
4:
5:
description = "Effect range" # 9-10
value = id.effectRange
5:
6:
description = "Attached to" # 11-12
if id.parentTile != null:
var parentY = int(id.parentTile/M.ySize)
Expand All @@ -136,41 +139,41 @@ func thing_details(id):
value += ' (' + str(parentX) + ','+str(parentY) + ')'
if id.parentTile == 65535:
value = "Manually placed"
6:
7:
description = "Door orientation" # 13
match id.doorOrientation:
0: value = "E/W"
1: value = "N/S"
7:
8:
description = "Level" # 14
value = id.creatureLevel
8:
9:
description = "Gate #" # 14
value = id.herogateNumber
9:
10:
description = "Custom box" # 14
value = id.boxNumber
10:
11:
description = "Door locked" # 14
value = id.doorLocked
# FX extended fields
11:
12:
description = "Health %"
value = id.creatureInitialHealth
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
12:
13:
description = "Gold held"
value = id.creatureGold
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
13:
description = "Name" # Creature name
14:
description = "Unique name"
value = id.creatureName
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
14:
15:
description = "Gold value"
value = id.goldValue
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
15:
16:
description = "Orientation"
value = id.orientation
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
Expand Down Expand Up @@ -209,27 +212,17 @@ func _on_thing_portrait_mouse_entered(nodeId):
# Name
value = Things.fetch_name(portraitThingType, portraitSubtype)
if value != null:
oThingListData.add_item(str(value),"")
oThingListData.add_item("Name", str(value))

value = Things.fetch_id_string(portraitThingType, portraitSubtype)
if value != null:
oThingListData.add_item("ID", str(value))

value = null
if portraitThingType != Things.TYPE.EXTRA:
value = retrieve_subtype_value(portraitThingType, portraitSubtype)
value = Things.data_structure_name.get(portraitThingType, "Unknown") + " : " + str(portraitSubtype)
if value != null:
oThingListData.add_item(str(value),"")

func retrieve_subtype_value(t_type, s_type):
match t_type:
Things.TYPE.NONE: return "None" + " : " + str(s_type)
Things.TYPE.OBJECT: return "Object" + " : " + str(s_type)
Things.TYPE.CREATURE: return "Creature" + " : " + str(s_type)
Things.TYPE.EFFECTGEN: return "EffectGen" + " : " + str(s_type)
Things.TYPE.TRAP: return "Trap" + " : " + str(s_type)
Things.TYPE.DOOR: return "Door" + " : " + str(s_type)
Things.TYPE.EXTRA: return null
# match s_type:
# 1: return "Action point : " + str(s_type)
# 2: return "Light : " + str(s_type)
return "Unknown"
oThingListData.add_item("Type", str(value))


# Fixes an obscure issue where it would continue to show what you've highlighted in the Thing Window inside of the Properties' Thing column.
#func _on_PropertiesTabs_tab_changed(tab):
Expand Down
31 changes: 21 additions & 10 deletions Scenes/TwoColumnData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -126,28 +126,42 @@ func add_item(leftString, rightString):
var orientIndex = Constants.listOrientations.find(int(rightString))
if orientIndex != -1:
nodeRightColumn.selected = orientIndex
"Name": #Creature name
"Unique name": #Creature name
nodeRightColumn = LineEdit.new()
nodeRightColumn.placeholder_text = "Default"
nodeRightColumn.placeholder_alpha = 0.33
nodeRightColumn.text = rightString #Utils.strip_special_chars_from_string(rightString)
nodeRightColumn.connect("text_changed", self, "_on_property_value_changed", [nodeRightColumn, leftString])
#nodeRightColumn.add_font_override("font", preload("res://Theme/StokeSmaller.tres"))
_:
nodeRightColumn = Label.new()
nodeRightColumn.autowrap = true
nodeRightColumn.rect_min_size.x = columnRightSize
#if name == "ColumnListData": nodeRightColumn.rect_min_size.x = columnRightSize-50
# This is for when highlighting something in the Thing Window
if rightString == "":
nodeRightColumn.rect_min_size.x = 0
nameDesc.autowrap = false

nodeRightColumn.text = rightString
nodeRightColumn.size_flags_vertical = Control.SIZE_EXPAND# + Control.SIZE_SHRINK_END # To handle the other side's autowrap text
nodeRightColumn.align = HALIGN_LEFT

var largest_word_width = get_largest_word_width(nodeRightColumn.text, nodeRightColumn.get_font("font", "Label"))
if largest_word_width >= 198: # EFFECTGENERATOR_ENTRANCE_ is slightly too large
nodeRightColumn.add_font_override("font", preload("res://Theme/StokeTiny.tres"))
elif largest_word_width >= 101: # "DARK_MISTRESS" is slightly too large
nodeRightColumn.add_font_override("font", preload("res://Theme/StokeSmaller.tres"))

add_child(nodeRightColumn)


func get_largest_word_width(text: String, font: Font) -> float:
var words = text.split(" ")
var largest_word_width = 0.0

for word in words:
var word_width = font.get_string_size(word).x
if word_width > largest_word_width:
largest_word_width = word_width

return largest_word_width

func _on_property_value_entered(new_val, callingNode): # When pressing Enter on LineEdit, lose focus
oEditor.mapHasBeenEdited = true
callingNode.release_focus()
Expand Down Expand Up @@ -217,7 +231,7 @@ func update_property_value(callingNode, leftString):
"Point range":
property_name = "pointRange"
value = clamp(float(value), 0, 255)
"Name":
"Unique name":
property_name = "creatureName"
# String, so no clamping
"Gold held":
Expand Down Expand Up @@ -329,6 +343,3 @@ func delete_children(node):
for n in node.get_children():
node.remove_child(n) #important to do this otherwise the margins get messed up
n.queue_free()



11 changes: 11 additions & 0 deletions Theme/StokeSmaller.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]

[ext_resource path="res://Theme/Stoke-Light.ttf" type="DynamicFontData" id=1]

[resource]
size = 14
use_mipmaps = true
use_filter = true
extra_spacing_top = 2
extra_spacing_char = -1
font_data = ExtResource( 1 )
11 changes: 11 additions & 0 deletions Theme/StokeTiny.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]

[ext_resource path="res://Theme/Stoke-Light.ttf" type="DynamicFontData" id=1]

[resource]
size = 12
use_mipmaps = true
use_filter = true
extra_spacing_top = 3
extra_spacing_char = -1
font_data = ExtResource( 1 )
1 change: 0 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ config/name="Unearth"
run/main_scene="res://Scenes/Main.tscn"
boot_splash/image="Skip-loading-screen"
config/icon="res://Art/icon/UnearthIcon256x256.png"
config/windows_native_icon="res://Art/icon/UnearthIcon.ico"

[autoload]

Expand Down

0 comments on commit bfc063c

Please sign in to comment.