Skip to content

Commit

Permalink
#307 - Last item forge
Browse files Browse the repository at this point in the history
  • Loading branch information
FrutyX authored Jan 21, 2025
2 parents 240ecd2 + c3375c5 commit f6f412c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
4 changes: 3 additions & 1 deletion source/core/locale/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ gca_languages['cs'] = {
unknown_scrolls_share_code : "Můj kód pro sdílení neznámých svitků",
use_share_code : "Použít kód pro sdílení",
use_share_code_description : "Vložte kód sdílení jiného hráče, pro zobrazení svitků které již znají:",
invalid_share_code : "Vložený kód je neplatný"
invalid_share_code : "Vložený kód je neplatný",
add_last_item : "Přidat poslední předmět"
},

// Merchants
Expand Down Expand Up @@ -477,6 +478,7 @@ gca_languages['cs'] = {
category_forge$horreum_select_meterials : "[Stodola] Zvolit surovinu kliknutím",
category_forge$double_click_select : "[Tavírna/Pracovní stůl] Vybrat předmět dvojitým kliknutím",
category_forge$forge_notepad : "Přidat nové pole pro poznámky",
category_forge$add_last_item : "Přidat tlačítko pro poslední předmět",
// Settings - Arena
category_arena$ignore_attack_confirmations : "Ignorovat potvrzení pro útoky (přes 5 útoků zpráva apd.)",
category_arena$show_simulator_imagelink : "Zobrazovat obrázkový odkaz do simulátoru (simulator.dinodevs.com)",
Expand Down
4 changes: 3 additions & 1 deletion source/core/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ gca_languages["en"] = {
use_share_code : "Use share code",
use_share_code_description : "Paste a gladiator's share code to see which scrolls they know:",
invalid_share_code : "Invalid share code",
add_last_item : "Add last item"
},

// Merchants
Expand Down Expand Up @@ -488,7 +489,8 @@ gca_languages["en"] = {
category_forge$horreum_remember_options : "[Horreum] Remember last selected store settings",
category_forge$horreum_select_meterials : "[Horreum] Select material on click",
category_forge$double_click_select : "[Smelt/Repair] Select item with double click",
category_forge$forge_notepad : "Add an extra notes field",
category_forge$forge_notepad : "Add an extra notes field",
category_forge$add_last_item : "Add last item button",
// Settings - Arena
category_arena$ignore_attack_confirmations : "Ignore attack confirmations (over 5 attacks message etc)",
category_arena$show_simulator_imagelink : "Show an image-link to the simulator (simulator.dinodevs.com)",
Expand Down
69 changes: 69 additions & 0 deletions source/core/source/forge.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ var gca_forge = {
(gca_options.bool("forge","forge_notepad") &&
this.forgeNotepad.inject());

// Add last item button
(gca_options.bool("forge","add_last_item") &&
this.LastCraftedItemBtn.inject());

// Add Gladiatus tools links
this.gladiatusTools.inject();

Expand Down Expand Up @@ -274,6 +278,71 @@ var gca_forge = {
});
}
},

LastCraftedItemBtn: {
inject: function() {
this.addLastItemButton();
this.saveOriginalButton();
},
// Save data
saveSettings: function() {
const prefix = document.getElementById('prefix0').value;
const item = document.getElementById('basic0').value;
const suffix = document.getElementById('suffix0').value;

localStorage.setItem('gladiatusCrazyAddonData_LastItem', JSON.stringify({ prefix, item , suffix }));
gca_notifications.success(gca_locale.get("general", "ok"));
},
// Load data
loadSettings: function() {
const settings = localStorage.getItem('gladiatusCrazyAddonData_LastItem');
if (settings) {
try {
const parsedSettings = JSON.parse(settings);
if (parsedSettings && parsedSettings.prefix && parsedSettings.item && parsedSettings.suffix) {
document.getElementById('prefix0').value = parsedSettings.prefix;
document.getElementById('basic0').value = parsedSettings.item;
document.getElementById('suffix0').value = parsedSettings.suffix;
gca_notifications.success(gca_locale.get("general", "ok"));
} else {
gca_notifications.error(gca_locale.get("general", "error"));
}
} catch (error) {
gca_notifications.error(gca_locale.get("general", "error"));
}
} else {
gca_notifications.error(gca_locale.get("general", "error"));
}
},
// Create Last Item button
addLastItemButton: function() {
const rentButton = document.querySelector('.awesome-button[data-rent="2"]');
if (rentButton) {
const lastItemButton = document.createElement('button');
lastItemButton.textContent = gca_locale.get('forge', 'add_last_item');
lastItemButton.className = 'awesome-button';
lastItemButton.style.marginLeft = '9px';
lastItemButton.style.height = '24px';
lastItemButton.style.width = '134px';
lastItemButton.style.fontSize = '11px';
lastItemButton.style.marginTop = '5px';
lastItemButton.style.cursor = 'pointer';

// Event listener
lastItemButton.addEventListener('click', () => this.loadSettings());

// Add button
rentButton.parentElement.appendChild(lastItemButton);
}
},
// Save settings with forge button
saveOriginalButton: function() {
const rentButton = document.querySelector('.awesome-button[data-rent="2"]');
if (rentButton) {
rentButton.addEventListener('click', () => this.saveSettings());
}
}
},

// Show available items on each quality
showAvailableItemsOnQuality : {
Expand Down
4 changes: 3 additions & 1 deletion source/core/source/gca.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,9 @@ gca_options.data = {
// Double click to select
"double_click_select" : true,
// Add a notepad
"forge_notepad" : true
"forge_notepad" : true,
// Add last item button
"add_last_item" : true
},

// Arena
Expand Down
4 changes: 3 additions & 1 deletion source/core/source/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,9 @@ var gca_settings = {
// Double click to select
"double_click_select" : true,
// Add a notepad
"forge_notepad" : true
"forge_notepad" : true,
// Add last item button
"add_last_item" : true
},

// Arena
Expand Down

0 comments on commit f6f412c

Please sign in to comment.