Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
- slabs.dat/slabs.clm/slabs.tng are now loaded directly from DK directory. Copies will no longer be kept in /unearthdata/.
- "/" will always be used instead of "\" in filepaths. Just cosmetic.
  • Loading branch information
rainlizard committed May 5, 2022
1 parent 5924444 commit e45fb09
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 70 deletions.
21 changes: 19 additions & 2 deletions Scenes/DkSlabs.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
extends Node
onready var oGame = Nodelist.list["oGame"]

var CODETIME_START

var dat = [] # 1304 sets of 9 column indexes
Expand All @@ -19,7 +21,8 @@ var floorTexture = []
func clm_asset():
CODETIME_START = OS.get_ticks_msec()

var buffer = Filetypes.file_path_to_buffer(Settings.unearthdata.plus_file("slabs.clm"))
var filePath = dk_data_get_filepath("SLABS.CLM")
var buffer = Filetypes.file_path_to_buffer(filePath)

buffer.seek(0)
var numberOfClmEntries = buffer.get_u16()
Expand Down Expand Up @@ -51,7 +54,8 @@ func clm_asset():
func dat_asset():
CODETIME_START = OS.get_ticks_msec()

var buffer = Filetypes.file_path_to_buffer(Settings.unearthdata.plus_file("slabs.dat"))
var filePath = dk_data_get_filepath("SLABS.DAT")
var buffer = Filetypes.file_path_to_buffer(filePath)
buffer.seek(2)
var numberOfSets = 1304
dat.resize(numberOfSets)
Expand All @@ -63,3 +67,16 @@ func dat_asset():
dat[i][subtile] = value

print('Created DAT asset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')


func dk_data_get_filepath(lookForFileName):
var dir = Directory.new()
if dir.open(oGame.DK_DATA_DIRECTORY) == OK:
dir.list_dir_begin(true, false)
var fileName = dir.get_next()
while fileName != "":
if dir.current_is_dir() == false:
if fileName.to_upper() == lookForFileName.to_upper(): # Get file regardless of case (case insensitive)
return oGame.DK_DATA_DIRECTORY.plus_file(fileName)
fileName = dir.get_next()
return ""
8 changes: 7 additions & 1 deletion Scenes/GenerateBorderWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ onready var oNoisePeriod = Nodelist.list["oNoisePeriod"]
onready var oNoisePersistence = Nodelist.list["oNoisePersistence"]
onready var oNoiseLacunarity = Nodelist.list["oNoiseLacunarity"]
onready var oOverheadGraphics = Nodelist.list["oOverheadGraphics"]
onready var oDataClm = Nodelist.list["oDataClm"]

var noise = OpenSimplexNoise.new()

Expand All @@ -20,10 +21,15 @@ func _process(delta):

func _on_NoiseButtonApply_pressed():
var CODETIME_START = OS.get_ticks_msec()
print(oCurrentMap.path)

# If a map is open, then clear it (remove objects and ownership and such)
if oCurrentMap.path != "":
oCurrentMap._on_ButtonNewMap_pressed()

# If field is black (no map has been opened), then we need something to start with
if oDataClm.cubes.empty() == true:
oCurrentMap._on_ButtonNewMap_pressed()

# Make fully rock and clear previous
for x in range(1, 84):
for y in range(1, 84):
Expand Down
62 changes: 29 additions & 33 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2653,12 +2653,9 @@ visible = true
margin_left = -976.0
margin_top = 672.0
margin_right = -293.0
margin_bottom = 900.0
margin_bottom = 886.0
window_title = "About"
script = ExtResource( 119 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ScrollContainer" type="ScrollContainer" parent="Ui/UiSystem/AboutWindow"]
anchor_right = 1.0
Expand All @@ -2667,16 +2664,13 @@ margin_left = 20.0
margin_top = 20.0
margin_right = -20.0
margin_bottom = -20.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="VBoxContainer" type="VBoxContainer" parent="Ui/UiSystem/AboutWindow/ScrollContainer"]
margin_right = 640.0
margin_right = 616.0
margin_bottom = 174.0

[node name="AboutDescriptionLabel" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer"]
margin_right = 640.0
margin_right = 616.0
margin_bottom = 21.0
size_flags_horizontal = 3
size_flags_vertical = 7
Expand All @@ -2687,7 +2681,7 @@ __meta__ = {

[node name="Control" type="Control" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer"]
margin_top = 25.0
margin_right = 640.0
margin_right = 616.0
margin_bottom = 49.0
rect_min_size = Vector2( 24, 24 )
__meta__ = {
Expand All @@ -2696,7 +2690,7 @@ __meta__ = {

[node name="AboutGridContainer" type="GridContainer" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer"]
margin_top = 53.0
margin_right = 640.0
margin_right = 616.0
margin_bottom = 174.0
columns = 2
__meta__ = {
Expand All @@ -2710,7 +2704,7 @@ text = "Github"

[node name="LinkButton1" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_left = 75.0
margin_right = 640.0
margin_right = 544.0
margin_bottom = 21.0
text = "https://github.com/rainlizard/Unearth"
__meta__ = {
Expand All @@ -2726,61 +2720,55 @@ text = "Itch.io"
[node name="LinkButton2" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_left = 75.0
margin_top = 25.0
margin_right = 640.0
margin_right = 544.0
margin_bottom = 46.0
focus_mode = 2
text = "https://rainlizard.itch.io/unearth"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label3" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
[node name="Label" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_top = 50.0
margin_right = 71.0
margin_bottom = 71.0
text = "Forum"

[node name="LinkButton3" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
[node name="LabelBlank" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_left = 75.0
margin_top = 50.0
margin_right = 640.0
margin_right = 544.0
margin_bottom = 71.0
focus_mode = 2
text = "https://keeperklan.com/threads/7321-Unearth-DK1-map-editor"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label4" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
[node name="Label3" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_top = 75.0
margin_right = 71.0
margin_bottom = 96.0
text = "Discord"
text = "Forums"

[node name="LinkButton4" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
[node name="LinkButton3" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_left = 75.0
margin_top = 75.0
margin_right = 640.0
margin_right = 544.0
margin_bottom = 96.0
focus_mode = 2
text = "https://discord.com/invite/zKTjfDh"
text = "https://keeperklan.com/forums/22-DK1-Mapmaking"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label5" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
[node name="Label4" type="Label" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_top = 100.0
margin_right = 71.0
margin_bottom = 121.0
text = "Email"
text = "Discord"

[node name="LinkButton5" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
[node name="LinkButton4" type="LinkButton" parent="Ui/UiSystem/AboutWindow/ScrollContainer/VBoxContainer/AboutGridContainer"]
margin_left = 75.0
margin_top = 100.0
margin_right = 640.0
margin_right = 544.0
margin_bottom = 121.0
focus_mode = 2
text = "ludorverr@gmail.com"
text = "https://discord.com/invite/zKTjfDh"
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down Expand Up @@ -4421,7 +4409,7 @@ margin_left = -2945.0
margin_top = -1513.0
margin_right = -1665.0
margin_bottom = -793.0
window_title = "Slabset"
window_title = "Slabset [WIP]"
resizable = true
script = ExtResource( 132 )

Expand Down Expand Up @@ -4541,6 +4529,14 @@ size_flags_horizontal = 6
size_flags_vertical = 4
columns = 3

[node name="SlabsetButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/VBoxContainer/HBoxContainer/ScrollContainer/VBoxContainer"]
margin_left = 5.0
margin_top = 177.0
margin_right = 163.0
margin_bottom = 204.0
size_flags_horizontal = 4
text = "Export slabs.dat"

[node name="SlabsetHelpButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/VBoxContainer/HBoxContainer/ScrollContainer/VBoxContainer"]
margin_left = 114.0
margin_top = 693.0
Expand Down
21 changes: 12 additions & 9 deletions Scenes/Menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func _ready():
oMenuButtonView.get_popup().connect("id_pressed",self,"_on_ViewSubmenu_Pressed")
oMenuButtonHelp.get_popup().connect("id_pressed",self,"_on_HelpSubmenu_Pressed")

func _on_RecentSubmenu_Pressed(pressedID):
var map = recentlyOpenedPopupMenu.get_item_text(pressedID)
oOpenMap.open_map(map)

func add_recent(map):
var findExisting = recentlyOpened.find(map)
if findExisting == -1:
Expand All @@ -59,20 +63,19 @@ func add_recent(map):
else:
recentlyOpened.push_front(recentlyOpened.pop_at(findExisting))

recentlyOpenedPopupMenu.clear()
for i in recentlyOpened:
recentlyOpenedPopupMenu.add_item(i)
populate_recently_opened()

Settings.write_cfg("recently_opened", recentlyOpened)

func _on_RecentSubmenu_Pressed(pressedID):
var map = recentlyOpenedPopupMenu.get_item_text(pressedID)
oOpenMap.open_map(map)

func initialize_recently_opened(value):
recentlyOpened = value
for i in recentlyOpened:
recentlyOpenedPopupMenu.add_item(i)
populate_recently_opened()

func populate_recently_opened():
recentlyOpenedPopupMenu.clear()
for filePath in recentlyOpened:
filePath = filePath.replace("\\", "/")
recentlyOpenedPopupMenu.add_item(filePath)


func _process(delta):
Expand Down
9 changes: 7 additions & 2 deletions Scenes/OpenMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ func start():
#open_map("G:/Games/Dungeon Keeper/campgns/keeporig/map00003.slb")
#open_map("G:/Games/Dungeon Keeper/campgns/ancntkpr/map00001.slb")
#open_map("G:/Games/Dungeon Keeper/ADiKtEd/levels/map00001.slb")
open_map("G:/Games/Dungeon Keeper/levels/personal/map00001.slb")

#open_map("G:/Games/Dungeon Keeper/campgns/UndivineD/map00001.slb")
pass
open_map("G:/Games/Dungeon Keeper/levels/personal/map00001.slb")
#oCurrentMap.clear_map()
#pass
else:
oCurrentMap.clear_map()

Expand All @@ -63,6 +65,9 @@ func _on_files_dropped(_files, _screen):

func open_map(filePath): # auto opens other files

# This will replace \ with /, just for the sake of fixing ugliness
filePath = filePath.replace("\\", "/")

# Prevent opening any maps under any circumstance if you haven't set the dk exe yet. (Fix to launching via file association)
if oGame.EXECUTABLE_PATH == "":
oMessage.quick("Error: Cannot open map because executable path is not set")
Expand Down
7 changes: 4 additions & 3 deletions Scenes/ThingsOnSlabs.gd
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
extends Node
var CODETIME_START
onready var oDkSlabs = Nodelist.list["oDkSlabs"]

var CODETIME_START
var tngIndex = []
var tngObject = []
var numberOfThings = 0

func slabtng_assets():

var buffer = Filetypes.file_path_to_buffer(Settings.unearthdata.plus_file("slabs.tng"))
var filePath = oDkSlabs.dk_data_get_filepath("SLABS.TNG")
var buffer = Filetypes.file_path_to_buffer(filePath)

buffer.seek(0)
numberOfThings = buffer.get_u16() # It says 359, however there are actually 362 entries in the file.
Expand Down
Binary file removed unearthdata/slabs.clm
Binary file not shown.
Binary file removed unearthdata/slabs.dat
Binary file not shown.
Binary file removed unearthdata/slabs.obj
Binary file not shown.
20 changes: 0 additions & 20 deletions unearthdata/slabs.obj.import

This file was deleted.

Binary file removed unearthdata/slabs.tng
Binary file not shown.

0 comments on commit e45fb09

Please sign in to comment.