Skip to content

Commit

Permalink
hedit: add button to delete handlings (#360)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Nov 22, 2021
1 parent b09bd68 commit 0835ecd
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 4 deletions.
1 change: 1 addition & 0 deletions [gameplay]/hedit/client/gui/languages/arabic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ guiLanguage.arabic = {

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

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

Expand Down
2 changes: 2 additions & 0 deletions [gameplay]/hedit/client/gui/languages/english.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ guiLanguage.english = {

successSave = "Successfully saved your handling settings!",
successLoad = "Successfully loaded your handling settings!",
sucessDelete = "Successfully deleted your handling settings!",

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

Expand Down Expand Up @@ -154,6 +155,7 @@ guiLanguage.english = {
descriptionLabel = "Description",
saveButton = "Save",
loadButton = "Load",
deleteButton = "Delete",
grid = "",
nameEdit = "",
descriptionEdit = ""
Expand Down
3 changes: 2 additions & 1 deletion [gameplay]/hedit/client/gui/languages/polish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ guiLanguage.polish = {

successSave = "Pomyslnie zapisano twoje ustawienia",
successLoad = "Pomyslnie wczytano twoje ustawienia!",

sucessDelete = "",

wantTheSettings = "Czy na pewno chcesz zastosowac te ustawienia? Edytor uruchomi sie ponownie.",

vehicle = "Pojazd",
Expand Down
1 change: 1 addition & 0 deletions [gameplay]/hedit/client/gui/languages/russian.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

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

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

Expand Down
1 change: 1 addition & 0 deletions [gameplay]/hedit/client/gui/languages/spanish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

successSave = "Se guardo el handling con exito!",
successLoad = "Se cargo el handling con exito!",
sucessDelete = "",

confirmVersionReset = "Estas seguro de que deseas establecer la version del editor a la de este servidor? Tus handlings guardados pueden llegar a ser incompatibles.",
successVersionReset = "La version de editor se ha actualizado.",
Expand Down
1 change: 1 addition & 0 deletions [gameplay]/hedit/client/gui/languages/turkish.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ guiLanguage.turkish = {

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

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

Expand Down
31 changes: 28 additions & 3 deletions [gameplay]/hedit/client/gui/templates/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ template.viewcontents = {
grid = {
type = "gridlist",
pos = { 72, 83 },
size = { 285, 246 },
size = { 285, 220 },
runfunction = function ( this )
guiGridListAddColumn ( this, "Name", 0.5 )
guiGridListAddColumn ( this, "Model", 0.4 )
Expand Down Expand Up @@ -782,7 +782,7 @@ template.viewcontents = {
},
saveButton = {
type = "button",
pos = { 289, 334 },
pos = { 289, 309 },
size = { 68, 25 },
events = {
onClick = function ( this )
Expand Down Expand Up @@ -813,7 +813,7 @@ template.viewcontents = {

loadButton = {
type = "button",
pos = { 289, 359 },
pos = { 289, 334 },
size = { 68, 25 },
events = {
onClick = function ( this )
Expand All @@ -838,6 +838,31 @@ template.viewcontents = {
end
end
}
},

deleteButton = {
type = "button",
pos = { 289, 359 },
size = { 68, 25 },
events = {
onClick = function ( this )
local content = heditGUI.viewItems.save.guiItems
local row,col = guiGridListGetSelectedItem ( content.grid )

if row ~= -1 and col ~= -1 then
local name = string.lower ( guiGridListGetItemText ( content.grid, row, col ) )

local function func ( )
if deleteClientHandling ( pVehicle, name ) then
guiCreateWarningMessage ( getText ( "sucessDelete" ), 3 )
end
end

guiCreateWarningMessage ( getText ( "confirmDelete" ), 2, {func} )
return true
end
end
}
}
}
},
Expand Down
27 changes: 27 additions & 0 deletions [gameplay]/hedit/client/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,33 @@ function loadClientHandling ( vehicle, name )
return true
end

function deleteClientHandling ( vehicle, name )
if not isValidVehicle ( vehicle ) then
if DEBUGMODE then
error ( "Invalid vehicle element at 'deleteClientHandling'! ["..tostring(vehicle).."]", 2 )
end

return false
end

if not isClientHandlingExisting ( name ) then
if DEBUGMODE then
error ( "Handling name given at 'deleteClientHandling' does not exist! ["..tostring(name).."]", 2 )
end

return false
end

name = string.lower ( name )
local handling = xmlCache.clientsaves[name].saveNode

xmlDestroyNode ( handling )
xmlSaveFile ( xmlFile[client_handling_file] )

xmlCache.clientsaves[name] = nil

return true
end

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

0 comments on commit 0835ecd

Please sign in to comment.