Skip to content

Commit 4f89793

Browse files
authored
Merge pull request #8 from PieterVdc/add-players
add extra players
2 parents b43f89d + 149a36e commit 4f89793

File tree

282 files changed

+3074
-322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

282 files changed

+3074
-322
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ custom_slabs.cfg
77
custom_objects.cfg
88

99
unearthdata/tmapa0*
10+
unearthdata/tmapb0*
1011
textures
1112

1213
### Godot ###

Autoload/Constants.gd

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
extends Node
22
const TILE_SIZE = 96
33
const SUBTILE_SIZE = 32
4-
5-
const ownerFloorCol = [Color8(132,44,0,255), Color8(136,112,148,255), Color8(52,92,4,255), Color8(188,156,0,255), Color8(207,207,207,255), Color8(52,36,4,255)] #Color8(180,160,124,255)
6-
const ownerRoomCol = [Color8(156,48,0,255), Color8(160,136,180,255), Color8(56,112,12,255), Color8(228,212,0,255), Color8(242,242,242,255), Color8(0,0,0,0)] #Color8(188,168,132,255)
7-
const ownershipNames = ["Red","Blue","Green","Yellow","White","None"]
4+
const PLAYERS_COUNT = 9
5+
# red blue green yellow white neutral Purple Black Orange
6+
const ownerFloorCol = [Color8(132,44,0,255), Color8(136,112,148,255), Color8(52, 92, 4,255), Color8(188,156,0,255), Color8(207,207,207,255), Color8(52,36,4,255), Color8(171, 80,120,255), Color8(32,32,32,255), Color8(188,108,53,255)] #Color8(180,160,124,255)
7+
const ownerRoomCol = [Color8(156,48,0,255), Color8(160,136,180,255), Color8(56,112,12,255), Color8(228,212,0,255), Color8(242,242,242,255), Color8(0,0,0,0), Color8(200,104,164,255), Color8(1,1,1,255), Color8(211,132,72,255)] #Color8(188,168,132,255)
8+
const ownershipNames = ["Red","Blue","Green","Yellow","White","None","Purple","Black","Orange"]
89

910
const listOrientations = [
1011
0, # ANGLE_NORTH

Autoload/Cube.gd

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ enum {
1515
NONE = 5
1616
}
1717
const ownedCube = {
18-
"FloorMarker" : [192,193,194,195,199,198],
19-
"WallMarker" : [67,68,69,70,71,4],
20-
"PortalMarker" : [382,422,423,424,426,425],
21-
"HeartMarker" : [382,422,423,424,426,425],
22-
"BarracksFlag" : [393,427,428,429,431,430],
23-
"BannerLeft" : [160,410,413,416,419,77],
24-
"BannerMiddle" : [161,411,414,417,420,77],
25-
"BannerRight" : [162,412,415,418,421,77],
18+
"FloorMarker" : [192,193,194,195,199,198,455,462,469],
19+
"WallMarker" : [67, 68, 69, 70, 71, 448,454,461,468],
20+
"PortalMarker" : [382,422,423,424,426,425,452,459,466],
21+
"HeartMarker" : [382,422,423,424,426,425,452,459,466],
22+
"BarracksFlag" : [393,427,428,429,431,430,453,460,467],
23+
"BannerLeft" : [160,410,413,416,419,445,449,456,463],
24+
"BannerMiddle" : [161,411,414,417,420,446,450,457,464],
25+
"BannerRight" : [162,412,415,418,421,447,451,458,465],
2626
}
2727

2828
const rngCube = {

Autoload/Things.gd

+8
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,14 @@ var DATA_OBJECT = {
332332
134 : ["Armageddon", null,null, preload("res://dk_images/keepower_64/armagedn_std.png"), null, TAB_SPELL],
333333
135 : ["Possess", null,null, preload("res://dk_images/keepower_64/possess_std.png"), null, TAB_SPELL],
334334
136 : ["Gold Bag (100)", null,null, preload("res://dk_images/valuables/gold_sack_tp/r1frame01.png"), null, TAB_GOLD],
335+
161 : ["White Flag", null,null, preload("res://dk_images/furniture/flagpole_whiteflag_tp/AnimFlagpoleWhite.tres"), null, TAB_FURNITURE],
336+
162 : ["White Heart Flame", null,null, preload("res://edited_images/heartflames/heartflame_white/AnimWhiteHeartFlame.tres"), null, TAB_FURNITURE],
337+
164 : ["Purple Flag", null,null, preload("res://dk_images/furniture/flagpole_purpleflag_tp/AnimFlagpolePurple.tres"), null, TAB_FURNITURE],
338+
165 : ["Purple Heart Flame", null,null, preload("res://edited_images/heartflames/heartflame_purple/AnimPurpleHeartFlame.tres"), null, TAB_FURNITURE],
339+
166 : ["Black Flag", null,null, preload("res://dk_images/furniture/flagpole_blackflag_tp/AnimFlagpoleBlack.tres"), null, TAB_FURNITURE],
340+
167 : ["Black Heart Flame", null,null, preload("res://edited_images/heartflames/heartflame_black/AnimBlackHeartFlame.tres"), null, TAB_FURNITURE],
341+
168 : ["Orange Flag", null,null, preload("res://dk_images/furniture/flagpole_orangeflag_tp/AnimFlagpoleOrange.tres"), null, TAB_FURNITURE],
342+
169 : ["Orange Heart Flame", null,null, preload("res://edited_images/heartflames/heartflame_orange/AnimOrangeHeartFlame.tres"), null, TAB_FURNITURE],
335343
}
336344

337345
var LIST_OF_BOXES = {

Autoload/Version.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extends Node
22

3-
var major_minor = "0.44"
3+
var major_minor = "0.45"
44
var patch = "0000"
55
var full = ""
66
var unearth_map_format_version:float = 1.05

Scenes/CurrentTextures.gd

+79-40
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ onready var oColumnEditorVoxelView = Nodelist.list["oColumnEditorVoxelView"]
1717
onready var oMapProperties = Nodelist.list["oMapProperties"]
1818

1919
const IMAGE_FORMAT = Image.FORMAT_RGB8
20-
const textureWidth = 256
21-
const textureHeight = 2176
20+
2221
enum {
2322
LOADING_NOT_STARTED
2423
LOADING_IN_PROGRESS
@@ -45,6 +44,7 @@ func _notification(what: int):
4544
yield(get_tree(),'idle_frame')
4645
oMapProperties._on_MapProperties_visibility_changed() # Refresh list of styles if it's visible
4746

47+
4848
func _on_ReloadTextureMapsButton_pressed():
4949
if texturesLoadedState != LOADING_IN_PROGRESS: # Don't do anything if it's already doing something
5050
oMessage.quick("Reloading tilesets")
@@ -96,6 +96,7 @@ func start():
9696
if oDataSlab.get_cell(0,0) != -1:
9797
set_current_texture_pack()
9898

99+
99100
func scan_dk_data_directory():
100101
var path = oGame.DK_DATA_DIRECTORY
101102
var dictionary = {}
@@ -105,7 +106,7 @@ func scan_dk_data_directory():
105106
var fileName = dir.get_next()
106107
while fileName != "":
107108
if dir.current_is_dir() == false:
108-
if fileName.to_upper().begins_with("TMAPA") == true: # Get file regardless of case (case insensitive)
109+
if fileName.to_upper().begins_with("TMAP") == true: # Get file regardless of case (case insensitive)
109110
if fileName.to_upper().get_extension() == "DAT":
110111
if fileName.to_upper().begins_with("TMAPANIM") == false:
111112
var getModifiedTime = File.new().get_modified_time(path.plus_file(fileName))
@@ -121,25 +122,33 @@ func convert_tmapa_to_image(tmapaDatPath):
121122
var file = File.new()
122123
if file.open(tmapaDatPath, File.READ) == OK:
123124
CODETIME_START = OS.get_ticks_msec()
125+
var imageSize = file.get_len() # (Width * Height)
124126

125-
var img = Image.new()
126-
img.create(textureWidth, textureHeight, false, IMAGE_FORMAT)
127-
file.seek(0)
128-
img.lock()
129-
for y in textureHeight:
130-
for x in textureWidth:
131-
var paletteIndex = file.get_8()
132-
img.set_pixel(x,y,paletteData[paletteIndex])
133-
img.unlock()
134-
135-
print('Converted tmapa*.dat to image in: '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')
127+
var dkTextureData = file.get_buffer(imageSize)
136128
file.close()
137129

130+
var data = PoolByteArray()
131+
data.resize(256 * 2176 * 3)
132+
data.fill(0) # Any space that goes beyond the size of tmapb will be set to black
133+
134+
var idx = 0
135+
for i in imageSize:
136+
var color = paletteData[dkTextureData[i]]
137+
data[idx] = color.r8
138+
data[idx + 1] = color.g8
139+
data[idx + 2] = color.b8
140+
idx += 3
141+
142+
var img = Image.new()
143+
img.create_from_data(256, 2176, false, IMAGE_FORMAT, data)
144+
145+
print("Converted " + str(tmapaDatPath.get_file()) + " to image in: " + str(OS.get_ticks_msec() - CODETIME_START) + "ms")
138146
return img
139147
else:
140148
print("Failed to open file.")
141149
return null
142150

151+
143152
func save_image_as_png(img, inputPath):
144153
var fileName = inputPath.get_file().get_basename().to_lower() + ".png"
145154

@@ -152,57 +161,77 @@ func save_image_as_png(img, inputPath):
152161

153162
func load_cache_filename(path):
154163
var fileName = path.get_file().get_basename().to_lower()
155-
var cachePath = Settings.unearthdata.plus_file(fileName + ".png")
164+
165+
if(fileName.to_lower().find("tmapa") == -1):
166+
return
167+
168+
var cachePathtmapa = Settings.unearthdata.plus_file(fileName + ".png")
169+
var cachePathtmapb = Settings.unearthdata.plus_file(fileName.replace("tmapa","tmapb") + ".png")
156170
var tmapaNumber = int(fileName.to_lower().trim_prefix("tmapa")) # Get the specific position to create within the array
157-
158-
if File.new().file_exists(cachePath) == true:
171+
172+
if File.new().file_exists(cachePathtmapa) == true:
159173
# Need to call load() on an Image class if I want the save and load to work correctly (otherwise it saves too fast and doesn't load or something)
160-
var img = Image.new()
161-
img.load(cachePath)
162-
load_image_into_cache(img, tmapaNumber)
174+
var imgA = Image.new()
175+
imgA.load(cachePathtmapa)
176+
var imgB = Image.new()
177+
imgB.load(cachePathtmapb)
178+
load_image_into_cache(imgA, imgB, tmapaNumber)
163179
#print('Loaded cache file: ' + cachePath)
164180
return OK
165181
else:
166-
print('Cache file not found: ' + cachePath)
182+
print('Cache file not found: ' + cachePathtmapa)
167183
cachedTextures.clear()
168184
return FAILED
169185

170-
func load_image_into_cache(img, tmapaNumber):
186+
187+
func load_image_into_cache(imgA, imgB, tmapaNumber):
171188
tmapaNumber = int(tmapaNumber)
172189
while cachedTextures.size() <= tmapaNumber: # Fill all array positions, in case a tmapa00#.dat file inbetween is deleted
173190
cachedTextures.append([null, null])
174-
cachedTextures[tmapaNumber] = convert_img_to_two_texture_arrays(img)
191+
cachedTextures[tmapaNumber] = convert_img_to_two_texture_arrays(imgA,imgB)
192+
175193

176194
# SLICE COUNT being too high is the reason TextureArray doesn't work on old PC. (NOT IMAGE SIZE, NOT MIPMAPS EITHER)
177195
# RES files might actually take longer to generate a TextureArray from than PNG, not sure.
178-
func convert_img_to_two_texture_arrays(img):
179-
if img.get_format() != IMAGE_FORMAT:
180-
img.convert(IMAGE_FORMAT)
181-
196+
func convert_img_to_two_texture_arrays(imgA,imgB):
197+
if imgA.get_format() != IMAGE_FORMAT:
198+
imgA.convert(IMAGE_FORMAT)
199+
if imgB.get_format() != IMAGE_FORMAT:
200+
imgB.convert(IMAGE_FORMAT)
201+
182202
var twoTextureArrays = [
183203
TextureArray.new(),
184204
TextureArray.new(),
205+
TextureArray.new(),
206+
TextureArray.new(),
185207
]
186208
var xSlices = 8
187209
var ySlices = 34
188210
var sliceWidth = 32 #img.get_width() / xSlices;
189211
var sliceHeight = 32 #img.get_height() / ySlices;
190212
twoTextureArrays[0].create(sliceWidth, sliceHeight, xSlices*ySlices, IMAGE_FORMAT, TextureLayered.FLAG_MIPMAPS+TextureLayered.FLAG_ANISOTROPIC_FILTER)
191213
twoTextureArrays[1].create(sliceWidth, sliceHeight, xSlices*ySlices, IMAGE_FORMAT, TextureLayered.FLAG_MIPMAPS+TextureLayered.FLAG_ANISOTROPIC_FILTER)
214+
twoTextureArrays[2].create(sliceWidth, sliceHeight, xSlices*ySlices, IMAGE_FORMAT, TextureLayered.FLAG_MIPMAPS+TextureLayered.FLAG_ANISOTROPIC_FILTER)
215+
twoTextureArrays[3].create(sliceWidth, sliceHeight, xSlices*ySlices, IMAGE_FORMAT, TextureLayered.FLAG_MIPMAPS+TextureLayered.FLAG_ANISOTROPIC_FILTER)
192216

193-
for i in 2:
217+
for i in 4:
194218
var yOffset = 0
195-
if i == 1:
219+
if i == 1 or i == 3:
196220
yOffset = 34
197221

198222
for y in ySlices:
199223
for x in xSlices:
200-
var slice = img.get_rect(Rect2(x*sliceWidth, (y+yOffset)*sliceHeight, sliceWidth, sliceHeight))
224+
var slice
225+
if i < 2:
226+
slice = imgA.get_rect(Rect2(x*sliceWidth, (y+yOffset)*sliceHeight, sliceWidth, sliceHeight))
227+
else:
228+
slice = imgB.get_rect(Rect2(x*sliceWidth, (y+yOffset)*sliceHeight, sliceWidth, sliceHeight))
201229
slice.generate_mipmaps() #Important otherwise it's black when zoomed out
202230
twoTextureArrays[i].set_layer_data(slice, (y*xSlices)+x)
203231

204232
return twoTextureArrays
205233

234+
206235
func set_current_texture_pack():
207236
var value = oDataLevelStyle.data
208237

@@ -215,29 +244,39 @@ func set_current_texture_pack():
215244

216245
# 2D
217246
if oOverheadGraphics.arrayOfColorRects.size() > 0:
218-
oOverheadGraphics.arrayOfColorRects[0].get_material().set_shader_param("dkTextureMap_Split_A", cachedTextures[value][0])
219-
oOverheadGraphics.arrayOfColorRects[0].get_material().set_shader_param("dkTextureMap_Split_B", cachedTextures[value][1])
247+
oOverheadGraphics.arrayOfColorRects[0].get_material().set_shader_param("dkTextureMap_Split_A1", cachedTextures[value][0])
248+
oOverheadGraphics.arrayOfColorRects[0].get_material().set_shader_param("dkTextureMap_Split_A2", cachedTextures[value][1])
249+
oOverheadGraphics.arrayOfColorRects[0].get_material().set_shader_param("dkTextureMap_Split_B1", cachedTextures[value][2])
250+
oOverheadGraphics.arrayOfColorRects[0].get_material().set_shader_param("dkTextureMap_Split_B2", cachedTextures[value][3])
220251

221252
# 3D
222253
if oGame3D.materialArray.size() > 0:
223-
oGame3D.materialArray[0].set_shader_param("dkTextureMap_Split_A", cachedTextures[value][0])
224-
oGame3D.materialArray[0].set_shader_param("dkTextureMap_Split_B", cachedTextures[value][1])
254+
oGame3D.materialArray[0].set_shader_param("dkTextureMap_Split_A1", cachedTextures[value][0])
255+
oGame3D.materialArray[0].set_shader_param("dkTextureMap_Split_A2", cachedTextures[value][1])
256+
oGame3D.materialArray[0].set_shader_param("dkTextureMap_Split_B1", cachedTextures[value][2])
257+
oGame3D.materialArray[0].set_shader_param("dkTextureMap_Split_B2", cachedTextures[value][3])
225258

226259
for nodeID in get_tree().get_nodes_in_group("VoxelViewer"):
227260
if nodeID.oAllVoxelObjects.mesh != null:
228-
nodeID.oAllVoxelObjects.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_A", cachedTextures[value][0])
229-
nodeID.oAllVoxelObjects.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_B", cachedTextures[value][1])
261+
nodeID.oAllVoxelObjects.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_A1", cachedTextures[value][0])
262+
nodeID.oAllVoxelObjects.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_A2", cachedTextures[value][1])
263+
nodeID.oAllVoxelObjects.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_B1", cachedTextures[value][2])
264+
nodeID.oAllVoxelObjects.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_B2", cachedTextures[value][3])
230265
if nodeID.oSelectedVoxelObject.mesh != null:
231-
nodeID.oSelectedVoxelObject.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_A", cachedTextures[value][0])
232-
nodeID.oSelectedVoxelObject.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_B", cachedTextures[value][1])
266+
nodeID.oSelectedVoxelObject.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_A1", cachedTextures[value][0])
267+
nodeID.oSelectedVoxelObject.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_A2", cachedTextures[value][1])
268+
nodeID.oSelectedVoxelObject.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_B1", cachedTextures[value][2])
269+
nodeID.oSelectedVoxelObject.mesh.surface_get_material(0).set_shader_param("dkTextureMap_Split_B2", cachedTextures[value][3])
233270

234271
assign_textures_to_slab_window(value)
235272

236273

237274
func assign_textures_to_slab_window(value): # Called by SlabStyleWindow
238275
for nodeID in get_tree().get_nodes_in_group("SlabDisplay"):
239-
nodeID.get_material().set_shader_param("dkTextureMap_Split_A", cachedTextures[value][0])
240-
nodeID.get_material().set_shader_param("dkTextureMap_Split_B", cachedTextures[value][1])
276+
nodeID.get_material().set_shader_param("dkTextureMap_Split_A1", cachedTextures[value][0])
277+
nodeID.get_material().set_shader_param("dkTextureMap_Split_A2", cachedTextures[value][1])
278+
nodeID.get_material().set_shader_param("dkTextureMap_Split_B1", cachedTextures[value][2])
279+
nodeID.get_material().set_shader_param("dkTextureMap_Split_B2", cachedTextures[value][3])
241280

242281

243282

Scenes/GenerateTerrainOLD.gd

+4-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ func create_surface_materials():
239239

240240
var mat = ShaderMaterial.new()
241241
mat.shader = preload("res://Shaders/display_texture_3d.shader")
242-
mat.set_shader_param("dkTextureMap_Split_A", oTextureCache.cachedTextures[map][0])
243-
mat.set_shader_param("dkTextureMap_Split_B", oTextureCache.cachedTextures[map][1])
242+
mat.set_shader_param("dkTextureMap_Split_A1", oTextureCache.cachedTextures[map][0])
243+
mat.set_shader_param("dkTextureMap_Split_A2", oTextureCache.cachedTextures[map][1])
244+
mat.set_shader_param("dkTextureMap_Split_B1", oTextureCache.cachedTextures[map][2])
245+
mat.set_shader_param("dkTextureMap_Split_B2", oTextureCache.cachedTextures[map][3])
244246
mat.set_shader_param("animationDatabase", preload("res://Shaders/textureanimationdatabase.png"))
245247

246248
materialArray.append(mat)

Scenes/GenericGridItem.gd

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
extends PanelContainer
2+
3+
signal pressed
4+
5+
var img_normal setget set_image_normal
6+
var img_pressed
7+
var img_hover
8+
var img_margin = 0
9+
var orig_backcol
10+
11+
func _ready():
12+
if img_normal:
13+
$TextureRect.texture = img_normal
14+
orig_backcol = get_stylebox("panel").bg_color
15+
16+
17+
get_stylebox("panel").content_margin_left = img_margin
18+
get_stylebox("panel").content_margin_right = img_margin
19+
get_stylebox("panel").content_margin_top = img_margin
20+
get_stylebox("panel").content_margin_bottom = img_margin
21+
22+
func _on_GenericGridItem_mouse_entered():
23+
if img_hover:
24+
$TextureRect.texture = img_hover
25+
26+
get_stylebox("panel").bg_color = orig_backcol * 1.25
27+
28+
func _on_GenericGridItem_mouse_exited():
29+
if img_normal:
30+
$TextureRect.texture = img_normal
31+
32+
get_stylebox("panel").bg_color = orig_backcol
33+
34+
func _on_GenericGridItem_gui_input(event):
35+
if event is InputEventMouseButton:
36+
if event.pressed and event.button_index == BUTTON_LEFT:
37+
if img_pressed:
38+
$TextureRect.texture = img_pressed
39+
emit_signal("pressed")
40+
else:
41+
$TextureRect.texture = img_normal
42+
43+
func set_image_normal(setVal):
44+
$TextureRect.texture = setVal
45+
img_normal = setVal

Scenes/GenericGridItem.tscn

+35-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
1-
[gd_scene format=2]
1+
[gd_scene load_steps=3 format=2]
22

3-
[node name="GenericGridItem" type="TextureButton"]
4-
anchor_right = 1.0
5-
anchor_bottom = 1.0
6-
focus_mode = 0
3+
[ext_resource path="res://Scenes/GenericGridItem.gd" type="Script" id=1]
4+
5+
[sub_resource type="StyleBoxFlat" id=1]
6+
resource_local_to_scene = true
7+
content_margin_left = 0.0
8+
content_margin_right = 0.0
9+
content_margin_top = 0.0
10+
content_margin_bottom = 0.0
11+
bg_color = Color( 0.20976, 0.1932, 0.23, 1 )
12+
border_width_left = 1
13+
border_width_top = 1
14+
border_width_right = 1
15+
border_width_bottom = 1
16+
border_color = Color( 1, 1, 1, 0.25098 )
17+
shadow_color = Color( 0.117647, 0.113725, 0.133333, 1 )
18+
shadow_size = 1
19+
shadow_offset = Vector2( 8, 8 )
20+
21+
[node name="GenericGridItem" type="PanelContainer"]
22+
mouse_filter = 1
23+
size_flags_horizontal = 3
24+
size_flags_vertical = 3
25+
custom_styles/panel = SubResource( 1 )
26+
script = ExtResource( 1 )
27+
28+
[node name="TextureRect" type="TextureRect" parent="."]
29+
mouse_filter = 2
30+
size_flags_horizontal = 3
31+
size_flags_vertical = 3
732
expand = true
8-
stretch_mode = 5
33+
stretch_mode = 6
34+
35+
[connection signal="gui_input" from="." to="." method="_on_GenericGridItem_gui_input"]
36+
[connection signal="mouse_entered" from="." to="." method="_on_GenericGridItem_mouse_entered"]
37+
[connection signal="mouse_exited" from="." to="." method="_on_GenericGridItem_mouse_exited"]

0 commit comments

Comments
 (0)