Skip to content

Commit 0835ecd

Browse files
ricksterhd123Inder00Disinterpreter
authored
hedit: add button to delete handlings (#360)
* Make grid a little smaller to add delete button and shift other buttons slightly upwards * Add message for successful delete (only english) * Create function to delete node from save file * Correct the debug messages * Add Arabic translation by [SW]Falcon * Add Turkish translation by ᴏᴠ | Gürkan * Update polish.lua * Added Russian translation by Google Translate * Add Spanish translation by Fantome * Refactor variable * Update russian.lua * ru fix typo * Revert "Add Spanish translation by Fantome" This reverts commit 76388a6. * Revert "Added Russian translation by Google Translate" This reverts commit e5ec614. * Revert "Update polish.lua" This reverts commit 703da78. * Revert "Add Turkish translation by ᴏᴠ | Gürkan" This reverts commit 3653216. * Revert "Add Arabic translation by [SW]Falcon" This reverts commit a318b2b. * Revert "Update russian.lua" This reverts commit 62919c9. Co-authored-by: Inder00 <[email protected]> Co-authored-by: Konstantin <[email protected]>
1 parent b09bd68 commit 0835ecd

File tree

8 files changed

+63
-4
lines changed

8 files changed

+63
-4
lines changed

[gameplay]/hedit/client/gui/languages/arabic.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ guiLanguage.arabic = {
3636

3737
successSave = "تم حفظ اعدادات وزانيتك بنجاح",
3838
successLoad = "تم تحميل اعدادات وزانيتك بنجاح",
39+
successDelete = "",
3940

4041
wantTheSettings = "هل انت متاكد من انك تريد تطبيق هذه الاعدادات ? معدل وزانيات سيتم اعادة تشغيله",
4142

[gameplay]/hedit/client/gui/languages/english.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ guiLanguage.english = {
3636

3737
successSave = "Successfully saved your handling settings!",
3838
successLoad = "Successfully loaded your handling settings!",
39+
sucessDelete = "Successfully deleted your handling settings!",
3940

4041
wantTheSettings = "Are you sure you would like to apply these settings? The handling editor will restart.",
4142

@@ -154,6 +155,7 @@ guiLanguage.english = {
154155
descriptionLabel = "Description",
155156
saveButton = "Save",
156157
loadButton = "Load",
158+
deleteButton = "Delete",
157159
grid = "",
158160
nameEdit = "",
159161
descriptionEdit = ""

[gameplay]/hedit/client/gui/languages/polish.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ guiLanguage.polish = {
3636

3737
successSave = "Pomyslnie zapisano twoje ustawienia",
3838
successLoad = "Pomyslnie wczytano twoje ustawienia!",
39-
39+
sucessDelete = "",
40+
4041
wantTheSettings = "Czy na pewno chcesz zastosowac te ustawienia? Edytor uruchomi sie ponownie.",
4142

4243
vehicle = "Pojazd",

[gameplay]/hedit/client/gui/languages/russian.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
successSave = "Вы успешно сохранили ваш хэндлинг!",
3838
successLoad = "Вы успешно загрузили ваш хэндлинг!",
39+
sucessDelete = "",
3940

4041
wantTheSettings = "Вы уверены, что хотите применить эти настройки? Редактор хэндлинга будет перезагружен.",
4142

[gameplay]/hedit/client/gui/languages/spanish.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
successSave = "Se guardo el handling con exito!",
4242
successLoad = "Se cargo el handling con exito!",
43+
sucessDelete = "",
4344

4445
confirmVersionReset = "Estas seguro de que deseas establecer la version del editor a la de este servidor? Tus handlings guardados pueden llegar a ser incompatibles.",
4546
successVersionReset = "La version de editor se ha actualizado.",

[gameplay]/hedit/client/gui/languages/turkish.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ guiLanguage.turkish = {
3636

3737
successSave = "Başarıyla işleme ayarlarını kurtardı!",
3838
successLoad = "Başarıyla senin kullanımı ayarlarını yüklenen!",
39+
sucessDelete = "",
3940

4041
wantTheSettings = "Bu ayarları uygulamak istiyorum emin misiniz? Taşıma editörü yeniden başlar.",
4142

[gameplay]/hedit/client/gui/templates/default.lua

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ template.viewcontents = {
658658
grid = {
659659
type = "gridlist",
660660
pos = { 72, 83 },
661-
size = { 285, 246 },
661+
size = { 285, 220 },
662662
runfunction = function ( this )
663663
guiGridListAddColumn ( this, "Name", 0.5 )
664664
guiGridListAddColumn ( this, "Model", 0.4 )
@@ -782,7 +782,7 @@ template.viewcontents = {
782782
},
783783
saveButton = {
784784
type = "button",
785-
pos = { 289, 334 },
785+
pos = { 289, 309 },
786786
size = { 68, 25 },
787787
events = {
788788
onClick = function ( this )
@@ -813,7 +813,7 @@ template.viewcontents = {
813813

814814
loadButton = {
815815
type = "button",
816-
pos = { 289, 359 },
816+
pos = { 289, 334 },
817817
size = { 68, 25 },
818818
events = {
819819
onClick = function ( this )
@@ -838,6 +838,31 @@ template.viewcontents = {
838838
end
839839
end
840840
}
841+
},
842+
843+
deleteButton = {
844+
type = "button",
845+
pos = { 289, 359 },
846+
size = { 68, 25 },
847+
events = {
848+
onClick = function ( this )
849+
local content = heditGUI.viewItems.save.guiItems
850+
local row,col = guiGridListGetSelectedItem ( content.grid )
851+
852+
if row ~= -1 and col ~= -1 then
853+
local name = string.lower ( guiGridListGetItemText ( content.grid, row, col ) )
854+
855+
local function func ( )
856+
if deleteClientHandling ( pVehicle, name ) then
857+
guiCreateWarningMessage ( getText ( "sucessDelete" ), 3 )
858+
end
859+
end
860+
861+
guiCreateWarningMessage ( getText ( "confirmDelete" ), 2, {func} )
862+
return true
863+
end
864+
end
865+
}
841866
}
842867
}
843868
},

[gameplay]/hedit/client/utils.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,33 @@ function loadClientHandling ( vehicle, name )
307307
return true
308308
end
309309

310+
function deleteClientHandling ( vehicle, name )
311+
if not isValidVehicle ( vehicle ) then
312+
if DEBUGMODE then
313+
error ( "Invalid vehicle element at 'deleteClientHandling'! ["..tostring(vehicle).."]", 2 )
314+
end
315+
316+
return false
317+
end
318+
319+
if not isClientHandlingExisting ( name ) then
320+
if DEBUGMODE then
321+
error ( "Handling name given at 'deleteClientHandling' does not exist! ["..tostring(name).."]", 2 )
322+
end
323+
324+
return false
325+
end
326+
327+
name = string.lower ( name )
328+
local handling = xmlCache.clientsaves[name].saveNode
329+
330+
xmlDestroyNode ( handling )
331+
xmlSaveFile ( xmlFile[client_handling_file] )
332+
333+
xmlCache.clientsaves[name] = nil
334+
335+
return true
336+
end
310337

311338
-- Imports a handling line in handling.cfg format, given a proper method.
312339
-- Valid methods: III, VC, SA, and IV

0 commit comments

Comments
 (0)